discord.ext.command.errors.CommandInvokeError: 命令引发异常: Attri



我有一个错误,我无法解决它错误是标题我已经在其他情况下进行了测试

import discord
from discord.ext import commands
client = discord.Client()
class utility(commands.Cog):
    def __init__(self, client):
        self.client = client
    @commands.Cog.listener()
    async def on_ready(self):
        print("Cog utility pronto!")
    @commands.command()
    async def ping(self, ctx):
        await ctx.send(f"Pong! {round(client.latency * 1000)}ms")
    @commands.command()
    async def clear(ctx, amount=5):
        await ctx.channel.purge(limit=amount)
        await ctx.send(f"{amount}Messaggi eliminati")
def setup(client):
    client.add_cog(utility(client))

齿轮中的命令仍然是齿轮实例的方法。 传递给它们的第一个参数始终是实例

class utility(commands.Cog):
    def __init__(self, client):
        self.client = client
    @commands.Cog.listener()
    async def on_ready(self):
        print("Cog utility pronto!")
    @commands.command()
    async def ping(self, ctx):
        await ctx.send(f"Pong! {round(self.client.latency * 1000)}ms")
    @commands.command()
    async def clear(self, ctx, amount=5):
        await ctx.channel.purge(limit=amount)
        await ctx.send(f"{amount}Messaggi eliminati")

最新更新