【问题标题】:Discord.py rewrite cog kick command not working anymoreDiscord.py 重写 cog kick 命令不再起作用
【发布时间】:2021-05-14 00:14:27
【问题描述】:

我正在用 discord.py rewrite 制作一个机器人并开始使用 cogs 我有一个可以完美运行的 kick 命令现在一旦我把它变成一个 cog 就完全不能工作了这是我的代码:

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)

是的,我在底部放了 bot.add_cog(Moderation(bot))

当我尝试运行它时出现此错误

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "kick" is not found

谢谢!

【问题讨论】:

  • 你真的在注册 cog 吗?我也看到你错过了self
  • 我需要在某处添加自我吗?
  • 在函数参数中?它在一个类中
  • 我加了还是不行
  • 你还没有回答我的第一个问题。你在注册 cog 吗?

标签: python python-3.x discord.py


【解决方案1】:
class Moderation(commands.Cog):
  def __init__ (self, bot):
    self.bot = bot

需要添加自己。

【讨论】:

    猜你喜欢
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 1970-01-01
    • 2021-06-29
    • 2021-01-05
    • 2020-08-07
    • 1970-01-01
    相关资源
    最近更新 更多