Discord Bot Role Mentioning

SomeName picture SomeName · Aug 27, 2018 · Viewed 24.4k times · Source

I am making simple Discord bot for my server, because part of one bot doesn't work. But, that bot needs to tag people from one role (let's say that role is "Moderator"). I wanted it to tag everyone from Moderator role, which will be like @Moderator. Here is my code (I am using Python 3.6):

if message.content.startswith('!startbot'):
    msg = '@Moderator, (some message after this)'.format(message)

But, that "@Moderator" doesn't actually tag anyone from Moderator role. It's just blank text like every other message. But, when I as someone real from Discord server type @Moderator, it brings red color (which I set) and it tags Moderator.

Can someone help me please to solve this thing ?

Answer

110Percent picture 110Percent · Aug 28, 2018

Role mentions in Discord are triggered like this:

<@&ROLE_ID>

Where ROLE_ID is the ID of the role you are trying to mention. Get the ID of the Moderators role, add it to the string accordingly and the bot will mention the role as you would from the Discord client.

This method also works for webhooks.