【发布时间】:2021-05-26 01:53:50
【问题描述】:
我做了一个帮助命令,当我执行一次命令时它就可以工作,但之后它停止工作,这意味着我必须重新运行整个代码。 (顺便说一句,这是一个齿轮)如果我多次执行命令,我得到的错误是Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "help" is not found
import discord
from discord.ext import commands
class help(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def help(self, ctx, cmd = "help"):
self.client.remove_command("help")
#help
if cmd == "help":
help_help_embed = discord.Embed(title = "Help Command", color = 0x00fd00)
help_help_embed.add_field(name = "**:scroll: Info**", value = "`//help info`", inline = True)
help_help_embed.add_field(name = "**:shield:Moderation**", value = "`//help moderation`", inline = True)
help_help_embed.add_field(name = "**Channel**", value = "`//help channel`", inline = True)
help_help_embed.add_field(name = "**:laughing: Fun**", value = "`//help fun`", inline = True)
help_help_embed.add_field(name = "**:tools: Utility**", value = "`//help utility`", inline = True)
help_help_embed.set_author(name = ctx.author, icon_url = ctx.author.avatar_url)
await ctx.send(embed = help_help_embed)
#info
if cmd == "info":
info_help_embed = discord.Embed(title = "**:scroll: Info Commands**", description = "//help {command}", color = 0x00fd00)
info_help_embed.add_field(name = "Commands:", value = "`help`, `changelog`, `announcements`, `ping`, `credits`", inline = False)
info_help_embed.set_author(name = ctx.author, icon_url = ctx.author.avatar_url)
await ctx.send(embed = info_help_embed)
def setup(client):
client.add_cog(help(client))
【问题讨论】:
标签: python python-3.x discord.py