1
votes

I am having trouble with this code(sorry its huge):

import discord, random, asyncio, datetime, time, os
from discord.utils import get
from discord.ext import commands
from discord.ext.commands import bot
import json 

bot = commands.Bot(command_prefix="aag!", case_insensitive=True)

@bot.event
async def on_ready():
  await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="dick pills"))
  print("gay")

@bot.event
async def on_guild_join(guild):
  for channel in guild.text_channels:
    if channel.permissions_for(guild.me).send_messages:
      await channel.send('**Hello I am AAG Bot! Here are some of my features:                          **__AAG Ultimate Team:__** _To get started with AAG UT start with the command_ `aag!UT`                           **__Signing Method:__** _Give all credit to @Doggy for making this part possible!_                           **__Economy Commands for UT:__** _to start using economy use command_ `aag!signup`')
      break

@bot.check
async def __before_invoke(ctx):
    if not ctx.message.author.bot:
        return True

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':ARI1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Arizona Cardinals**")
      await bot.add_roles(member, role="@Arizona Cardinals")
      await bot.say(f"**{member.mention} Signed to Arizona Cardinals**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':ATL1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Atlanta Falcons**")
      await bot.add_roles(member, role="@Atlanta Falcons")
      await bot.say(f"**{member.mention} Signed to Atlanta Falcons**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':BAL1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Baltimore Ravens**")
      await bot.add_roles(member, role="@Baltimore Ravens")
      await bot.say(f"**{member.mention} Signed to Baltimore Ravens**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':BUF1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Buffalo Bills**")
      await bot.add_roles(member, role="@Buffalo Bills")
      await bot.say(f"**{member.mention} Signed to Buffalo Bills**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':CAR1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Carolina Panthers**")
      await bot.add_roles(member, role="@Carolina Panthers")
      await bot.say(f"**{member.mention} Signed to Carolina Panthers**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':CIN1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Cincinnati Bengals**")
      await bot.add_roles(member, role="@Cincinnati Bengals")
      await bot.say(f"**{member.mention} Signed to Cincinnati Bengals**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':CHI1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Chicago Bears**")
      await bot.add_roles(member, role="@Chicago Bears")
      await bot.say(f"**{member.mention} Signed to Chicago Bears**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':CLE1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Cleveland Browns**")
      await bot.add_roles(member, role="@Cleveland Browns")
      await bot.say(f"**{member.mention} Signed to Cleveland Browns**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':DAL1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Dallas Cowboys**")
      await bot.add_roles(member, role="@Dallas Cowboys")
      await bot.say(f"**{member.mention} Signed to Dallas Cowboys**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':DEN1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Denver Broncos**")
      await bot.add_roles(member, role="@Denver Broncos")
      await bot.say(f"**{member.mention} Signed to Denver Broncos**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':DET1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Detroit Lions**")
      await bot.add_roles(member, role="@Detroit Lions")
      await bot.say(f"**{member.mention} Signed to Detroit Lions**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':GB1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Green Bay Packers**")
      await bot.add_roles(member, role="@Green Bay Packers")
      await bot.say(f"**{member.mention} Signed to Green Bay Packers**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':HOU1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Houston Texans**")
      await bot.add_roles(member, role="@Houston Texans")
      await bot.say(f"**{member.mention} Signed to Houston Texans**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':IND1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Indianapolis Colts**")
      await bot.add_roles(member, role="@Indianapolis Colts")
      await bot.say(f"**{member.mention} Signed to Indianapolis Colts**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':KC1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Kansas City Chiefs**")
      await bot.add_roles(member, role="@Kansas City Chiefs")
      await bot.say(f"**{member.mention} Signed to Kansas City Chiefs**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':LAC1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Los Angeles Chargers**")
      await bot.add_roles(member, role="@Los Angeles Chargers")
      await bot.say(f"**{member.mention} Signed to Los Angeles Chargers**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':LAR1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Los Angeles Rams**")
      await bot.add_roles(member, role="@Los Angeles Rams")
      await bot.say(f"**{member.mention} Signed to Los Angeles Rams**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':JAX1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Jacksonville Jaguars**")
      await bot.add_roles(member, role="@Jacksonville Jaguars")
      await bot.say(f"**{member.mention} Signed to Jacksonville Jaguars**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':MIA1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Miami Dolphins**")
      await bot.add_roles(member, role="@Miami Dolphins")
      await bot.say(f"**{member.mention} Signed to Miami Dolphins**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':MIN1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Minnesota Vikings**")
      await bot.add_roles(member, role="@Minnesota Vikings")
      await bot.say(f"**{member.mention} Signed to Minnesota Vikings**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':NE1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to New England Patriots**")
      await bot.add_roles(member, role="@New England Patriots")
      await bot.say(f"**{member.mention} Signed to New England Patriots**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':NO1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to New Orleans Saints**")
      await bot.add_roles(member, role="@New Orleans Saints")
      await bot.say(f"**{member.mention} Signed to New Orleans Saints**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':NYG1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to New York Giants**")
      await bot.add_roles(member, role="@New York Giants")
      await bot.say(f"**{member.mention} Signed to New York Giants**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':NYJ1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to New York Jets**")
      await bot.add_roles(member, role="@New York Jets")
      await bot.say(f"**{member.mention} Signed to New York Jets**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':LV1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Las Vegas Raiders**")
      await bot.add_roles(member, role="@Las Vegas Raiders")
      await bot.say(f"**{member.mention} Signed to Las Vegas Raiders**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':PHI1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Philadelphia Eagles**")
      await bot.add_roles(member, role="@Philadelphia Eagles")
      await bot.say(f"**{member.mention} Signed to Philadelphia Eagles**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':SF1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to San Francisco 49ers**")
      await bot.add_roles(member, role="@San Francisco 49ers")
      await bot.say(f"**{member.mention} Signed to San Francisco 49ers**")

@bot.command()
async def on_message(message, member: discord.Member, *, role: discord.Role):
  if bot.user.id != message.author.id:
    if f':SEA1: sign {member.mention}' in message.content:
      await bot.say(f"**Signing {member.mention} to Seattle Seahawks**")
      await bot.add_roles(member, role="@Seattle Seahawks")
      await bot.say(f"**{member.mention} Signed to Seattle Seahawks**")

#keep_alive.keep_alive()
token = os.environ.get("TOKEN")
bot.run(token, bot=True)

Dont say anything about the token not being there I know that it isn't there.

But then I get this error message:

Traceback (most recent call last): File "main.py", line 137, in async def on_message(message, member: discord.Member, *, role: discord.Role): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1246, in decorator self.add_command(result) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1138, in add_command raise CommandRegistrationError(command.name) discord.ext.commands.errors.CommandRegistrationError: The command on_message is already an existing command or alias.

I do not know what this means please someone with more knowledge than me please guide me through this LOL.

1
I think you need different names for different functions - jacob galam
so you mean for the async def on_message(message, member: discord.Member, *, role: discord.Role) use different functions inside the parenthesis? - augustincampagna
try call it on_message1, on_message2 and so on: async def on_message1(message, member: discord.Member, *, role: discord.Role) - jacob galam
Okay thanks Ill give it a shot! - augustincampagna
Are you using repl.it version of discord.py? There's no bot.say in rewrite. - Nurqm

1 Answers

1
votes

Blockquote try call it on_message1 on_message2 and so on: async def on_message1(message, member: discord.member, *, role: discord.Role) - jacob galam

thanks jacob the code works now!