Answer the question
In order to leave comments, you need to log in
How to make a command that gives a role to the one who writes it?
YET THERE IS THIS BUT IF IT IS WRITTEN THE BOT WILL IGNORE
@client.command(name="админ")
async def _admin(ctx):
author = message.author # получаем автора сообщения
guild = self.get_guild(808127714543534111) # получаем объект сервера*
role = guild.get_role(808380458740088873) # получаем объект роли*
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.self, this is a parameter specified in a class method to work with its fields and methods:
In general, this will only work if: a. is a class method. b. in the parameters specified in. there is a method in the class
2. sequentially debug the code - check if the bot sees the message (and not just "ignore", because of the wrong code), finds the guild, finds the role, etc.
guild = self.get_guild(808127714543534111)
_admin
_admin
self
get_guild
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question