I'm making a Discord bot but just ran into a problem.
I want to modify a role. A specific role. I know how to do that with edit_role
, but I need to get the Role object to edit it. Now, that's the problem.
How do I get a Role object by the role's id? Or can I use the id in the Role argument?
The ID for the everyone role is the Guild ID. Now to mention everyone, all you need is to send the string @everyone: message.channel. send("@everyone"); To obtain the ID for the everyone role, you need to have the guild, which you get on some events like: message , guildCreate , and others.
In the Modules Settings section, click on the Autoroles option from the left side menu. In the main window, click on the drop-down and select the role you want to add for auto-assign. Choose the length of time necessary for new members to acquire this role in the Delay (minutes) box.
On Android press and hold the Server name above the channel list. You should see the last item on the drop-down menu: 'Copy ID'. Click Copy ID to get the ID.
Follow these steps to find your Server ID: In Discord, open your User Settings by clicking the Settings Cog next to your user name on the bottom. Go to Appearance and enable Developer Mode under the Advanced section, then close User Settings. Open your Discord server, right-click on the server name, then select Copy ID.
You can use discord.utils.get
to loop through Guild.roles
and get the one you're looking for:
from discord.utils import get
role_id = 123
role = get(guild.roles, id=role_id)
You can simply use Guild.get_role(role_id)
to get the role if you have the id.
role_id = 2134532534
role = my_server.get_role(role_id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With