我遵循了最新版本的文档,但不了解我的错误处理程序或装入命令中出了什么问题:
import discord
from discord.ext import tasks, commands
bot = commands.Bot(command_prefix='!', description=description)
@bot.command()
@is_me()
@commands.dm_only()
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
@load.error
async def load_error(ctx, error):
if isinstance(error, commands.ExtensionAlreadyLoaded('load')):
print('error load')
await ctx.send("extension allready added!")
如果您想更改使用内置函数的双重检查(@is_me()和dm_only()),也会导致我失败:
def is_me():
def predicate(ctx):
return ctx.message.author.id == admin_id
return commands.check(predicate)
感谢您的帮助!