我正在使用 discord.py 重写一个机器人并开始使用 cogs 我有一个 kick 命令运行完美,现在一旦我把它变成一个 cog 就根本无法工作,这里是我的代码:
>fullPath = path + os.sep + 'Word_freq' + os.sep + file + '.csv'
是的,我在底部放了 bot.add_cog(Moderation(bot))
当我尝试运行它时出现此错误
class Moderation(commands.Cog):
@commands.command(name = "Kick", brief = "Kicks a Member from the Guild", help = ".Kick @User")
async def kick(ctx, Member : discord.Member, *, reason=None):
if ctx.message.author.guild_permissions.kick_members:
await discord.Member.kick(reason=reason)
em = discord.Embed(title = "**Moderation**", description = f"{Member} was banned because {reason}", colour = discord.Colours.red())
await ctx.send(embed = em)
else:
em = discord.Embed(title = "Permissions Required!", description = f"{ctx.author.name} You do not have the required Permissions to use this command", color = discord.Colour.red())
await ctx.send(embed=em)
谢谢!
答案 0 :(得分:0)
class Moderation(commands.Cog):
def __init__ (self, bot):
self.bot = bot
需要添加自己。