我为什么会收到此错误命令on_message已经是现有命令或别名

时间:2020-10-09 14:34:00

标签: python discord discord.py

我在使用此代码时遇到麻烦(抱歉,它的代码太多了):

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)

不要说关于令牌不存在的任何信息,我知道它不存在。

但随后我收到此错误消息:

回溯(最近通话最近): 在第137行的文件“ main.py”中 异步定义on_message(消息,成员:discord.Member,*,作用:discord.Role): 在装饰器中的文件“ /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py”,行1246 self.add_command(结果) 在add_command的第1138行中,文件“ /opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py” 引发CommandRegistrationError(command.name) discord.ext.commands.errors.CommandRegistrationError:命令on_message已经是现有命令或别名。

我不知道这意味着什么,请一个比我了解更多的人,请指导我完成此LOL。

1 个答案:

答案 0 :(得分:1)

Blockquote 尝试将其命名为on_message1 on_message2,依此类推:async def on_message1(message, member: discord.member, *, role: discord.Role)-雅各布·加拉姆(Jacob galam)

感谢雅各布代码现在可以正常工作!

相关问题