【发布时间】:2021-08-02 05:15:39
【问题描述】:
导入不和谐 从 discord.ext 导入命令
类错误(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print ('Cog loaded: errors.py')
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(embed=embedVar)
@commands.Cog.listener()
async def command_not_found(self, ctx, error):
embedVar = discord.Embed(title='**DEVELOPER**', description='Error occured:\n error.CommandNotFound', color=7419530)
embedVar.add_field(name='**NOT PARSED**', value='Could not find command.')
if isinstance(error, commands.CommandNotFound):
await ctx.send(embed=embedVar)
@commands.Cog.listener()
async def on_permission_error(self, ctx, error):
embedVar = discord.Embed(title='**DEVELOPER**', description='Error occured:\n error.MissingPermissions', color=7419530)
embedVar.add_field(name='**NOT PARSED**', value='Missing required permissions.')
if isinstance(error, commands.MissingPermissions):
await ctx.send(embed=embedVar)
def 设置(客户端): client.add_cog(错误(客户端))
【问题讨论】:
标签: python discord.py