Search code examples
pythondiscordpycord

Why can't i ping the @everyone discord role?


I have a function that writes news to discord, it pings everyone. To ping everyone, I write ctx.send(...), if I write ctx.response.send_message(...), then @everyone does not work @everyone not working. And I need to somehow remove ctx.response

@commands.slash_command(name="news",description="news")
    async def news(self, ctx: discord.ApplicationContext, title, news):
        if ctx.author.top_role.name not in settings['high_admin_role']:
            await ctx.response.send_message("not permission",ephemeral=True)
            return
        else:
            news = ''.join(news).replace(';', '\n')
            embed = discord.Embed(title=f"""{title}""", description=f"""{news}\n\nОт: {ctx.author.mention}""", color=discord.Color.from_rgb(199, 135, 24))
            await ctx.send('||@everyone||', embed=embed)

I tried ctx.defer(), ctx.response.defer(). I tried to send messages via response, but then @everyone doesn't work


Solution

  • The issue here why the role @everyone doesn't receive the ping could have 2 reasons:

    • Missing Bot-rights: Maybe your bot is missing the MENTION EVERYONE permission in the channel, where you're sending your message - that is probably your issue here.
    • Mention the role like it should be: The way you're trying to mention the @everyone role is not wrong, but maybe it is bugged in your discord library. So you could try the official way to mention the role.

    The official way to mention the @everyone role is to get the guild.default_role object first and then mention that object itself. That works like this:

    • await ctx.send(f'||{ctx.guild.default_role.mention}||', embed=embed)

    If that is not working too, your bot is cleary missing the right MENTION EVERYONE in your discord channel. You can change that if you edit the channel permissions and turn that on (ONLY FOR YOUR BOT):


    If that all doesn't help you (which would be weird behaivor), you could try to use discord.AllowedMentions:

    allowed_mentions = discord.AllowedMentions(everyone=True)
    await ctx.send(f'||{ctx.guild.default_role.mention}||', embed=embed, allowed_mentions=allowed_mentions)