Reputation: 44
i have an error and i can't resolve it the error is the title i have already tested in other situations
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))
Upvotes: 0
Views: 4364
Reputation: 60954
Commands in a cog are still methods of an instance of the cog. The first argument passed to them is always the instance
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")
Upvotes: 1