Answer the question
In order to leave comments, you need to log in
How to replace client in cogs?
I tried to make the command unbanned, but it gives an error:
Command raised an exception: NameError: name 'client' is not defined
@commands.command(
aliases = ["разбан"],
name = "unban",
brief = "Разбанить пользователя",
usage = "unban <user>"
)
async def unban(ctx, id: int):
user = await client.fetch_user(id)
await ctx.guild.unban(user)
Answer the question
In order to leave comments, you need to log in
Solved the problem. The code I used:
@commands.command(
aliases = ["разбан"],
name = "unban",
brief = "Разбанить пользователя",
usage = "unban <user>"
)
async def unban(self, ctx, id: int):
user = await self.client.fetch_user(user_id=id)
await ctx.guild.unban(user)
You can write the id type not int, but discord.Member, if I'm not confused. Then fetch_user() won't be needed either.
PS: But the unban command is rather useless, it's faster to do it through the discord interface. =p
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question