How to set custom role name for Discord bot programmatically

I’m working on a Discord bot using disnake and running into an issue with role naming.

Every time I restart my bot through the Discord developer portal, it reverts back to its original role name (which matches the bot’s name). I want to keep a custom role name that I set manually, but the bot keeps going back to the default one after each restart.

Is there a way to programmatically set the bot’s role name through code so it stays consistent?

I’ve searched online but couldn’t find any examples or documentation about changing the bot’s own role name. I only found tutorials about changing the bot’s activity status like “playing” or “watching” something.

Has anyone dealt with this before? Any help would be appreciated!

The bot’s role name keeps reverting because Discord automatically ties the bot’s role name to its application name. Any manual changes get overwritten when the bot restarts. To address this issue, create a separate custom role for your bot, and then remove permissions from the default integrated role. This way, your custom role will retain its name even after the bot reconnects. Alternatively, you can automate the renaming in your bot’s startup code using guild role modification methods, but be cautious as this might conflict with other role management functionalities.

yeah, discord syncs the role name with the bot’s actual name in the dev portal, which is super annoying. i made a custom role for mine, ditched the default one, and it holds its name just fine now. way simpler than trying to change it every time!

Had this exact problem last year with my moderation bot. Discord syncs the bot’s integrated role with whatever name you have in the developer portal, which is annoying. Here’s what worked for me: use guild.me.edit() right after the bot connects. Catch the on_ready event and call await guild.me.edit(nick="YourCustomName") - this changes the display name but only affects the nickname, not the actual role name. For the role itself, grab it with guild.me.top_role then use await role.edit(name="CustomRoleName"). Just remember your bot needs manage roles permission and the custom role has to be below your bot’s highest role in the hierarchy.