How to properly mention roles in Discord bot using discord.py?

I’m having trouble with role mentions in my Discord bot. When I try to ping a role, it shows up as a mention in the message but doesn’t actually send notifications to users with that role. It’s like a ghost ping where the role appears mentioned but nobody gets pinged.

@bot.tree.command(name="alert", description="notify staff members to join duty")
@discord.app_commands.checks.has_permissions(manage_roles=True)
async def notify_staff(ctx: discord.Interaction):
    await ctx.response.send_message(f"<@&1234567890123456789>, Please join the server duty")

I’ve tested several approaches but can’t get the actual ping functionality to work correctly. The role mention appears visually but users don’t receive notifications. Is there a specific way to make role mentions work properly in discord.py?

The problem’s probably with how you’re getting the role ID. If you’re hardcoding it like in your example, double-check it’s actually correct for your server. People mess this up all the time by copying IDs from different servers or using old ones. Try role = discord.utils.get(ctx.guild.roles, name="YourRoleName") then role.mention instead of hardcoding. Also check if your bot has the right permissions in that specific channel - sometimes channel permissions mess with role mentions even when the bot has server-wide perms.

Had this same problem a few months ago. Your bot needs “Mention Everyone” permission to actually ping roles. Without it, the role shows as mentioned but nobody gets notified. Go to Server Settings > Roles and make sure “Mention Everyone” is turned on for your bot. Also check that the role you’re pinging is below your bot’s role in the hierarchy - Discord blocks it otherwise, even with the right permissions.

make sure the role has “Allow anyone to @mention this role” enabled. without that, there won’t be any notifications even if you’re mentioning it right in the code. it’s likely a settings issue, your code seems fine!