L
L
LirikDEV2022-03-06 18:09:21
Python
LirikDEV, 2022-03-06 18:09:21

How to fix a bug with issuing a role in a python discord bot?

There is a server and there when you write a command the role should be given.
Throws the error
discord.ext.commands.errors.MissingRequiredArgument: self is a required argument that is missing.

@bot.command()
async def PasL134(ctx, self):
    author = ctx.message.author
    guild = self.get_guild(тут айди сервера) 
    role = guild.get_role(тут айди роли)


    await author.add_roles(role)
    await message.channel.send(f"{author.mention}, пасхальная роль выдана!")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-03-06
@Vindicar

what else is self.get_guild(), and why can't you take guild from ctx?
Discord.py currently expects self to be passed as a parameter when the user invokes the command.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question