R
R
RageLord2021-09-14 15:49:42
Python
RageLord, 2021-09-14 15:49:42

How to make the bot create and assign a role to a person, while moving this role as high as possible?

How can I make the bot create a role when using the command, move it as high as it can (that is, the bot's role number from below -1) and issue it to the author of the command?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
micsma, 2021-09-14
@RageLord

I hope helped you.

@bot.command()
async def addrole(ctx, role, color: discord.Color): #в color желательно указывать hex цвета (например #692525)
  member = ctx.message.author #создаём переменную "member" в которую суём автора сообщения
  guild = bot.get_guild(serverid) #предварительно создайте переменную "serverid" и поместите туда id сервера.
  await bot.get_guild(serverid).create_role(name=role, color = color) #создаём на сервере роль и делаем её цветной
  role = discord.utils.get(guild.roles, name = role) #создаём переменную "role" в которую суём роль найденную по имени
  await member.add_roles(role) #добавляем автору сообщения роль

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question