Repository: python-discord/bot

Issue:
Allow role mentions in specific areas
## Description
Since we do not allow the bot to mention roles anymore (b1c0177) except for moderators+ (36330b1) after the [incident](https://seph.club/who-pinged/?utm_medium=social&utm_source=discord&utm_campaign=whopinged), this has created a new issue where the bot cannot ping roles where it is actually needed in certain places. This needs to be fixed.

Some of these places include:
- Mod alerts (pings `@everyone`)
- Mod log (pings `@everyone`)
- The help channel system (pings `@Helpers`)
- Syncers (pings `@PyDis Core Developers`)

There may be some other areas I missed, so please look over the codebase carefully and explicitly allow role mentions where needed.

## Implementation
We can use [`discord.AllowedMentions`](https://discordpy.readthedocs.io/en/latest/api.html?highlight=allowedmentions#discord.AllowedMentions) when sending messages where non-whitelisted role mentions are needed, which will override the global setting. This object can be passed using the [`allowed_mentions`](https://discordpy.readthedocs.io/en/latest/api.html?highlight=allowedmentions#discord.abc.Messageable.send) kwarg.


Discussion:

Resolving patch:
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -614,11 +614,13 @@ async def notify(self) -> None:
 
             channel = self.bot.get_channel(constants.HelpChannels.notify_channel)
             mentions = " ".join(f"<@&{role}>" for role in constants.HelpChannels.notify_roles)
+            allowed_roles = [discord.Object(id_) for id_ in constants.HelpChannels.notify_roles]
 
             message = await channel.send(
                 f"{mentions} A new available help channel is needed but there "
                 f"are no more dormant ones. Consider freeing up some in-use channels manually by "
-                f"using the `{constants.Bot.prefix}dormant` command within the channels."
+                f"using the `{constants.Bot.prefix}dormant` command within the channels.",
+                allowed_mentions=discord.AllowedMentions(everyone=False, roles=allowed_roles)
             )
 
             self.bot.stats.incr("help.out_of_channel_alerts")
diff --git a/bot/cogs/moderation/modlog.py b/bot/cogs/moderation/modlog.py
--- a/bot/cogs/moderation/modlog.py
+++ b/bot/cogs/moderation/modlog.py
@@ -121,7 +121,12 @@ async def send_log_message(
                 content = "@everyone"
 
         channel = self.bot.get_channel(channel_id)
-        log_message = await channel.send(content=content, embed=embed, files=files)
+        log_message = await channel.send(
+            content=content,
+            embed=embed,
+            files=files,
+            allowed_mentions=discord.AllowedMentions(everyone=True)
+        )
 
         if additional_embeds:
             if additional_embeds_msg:
diff --git a/bot/cogs/sync/syncers.py b/bot/cogs/sync/syncers.py
--- a/bot/cogs/sync/syncers.py
+++ b/bot/cogs/sync/syncers.py
@@ -5,6 +5,7 @@
 from collections import namedtuple
 from functools import partial
 
+import discord
 from discord import Guild, HTTPException, Member, Message, Reaction, User
 from discord.ext.commands import Context
 
@@ -68,7 +69,11 @@ async def _send_prompt(self, message: t.Optional[Message] = None) -> t.Optional[
                     )
                     return None
 
-            message = await channel.send(f"{self._CORE_DEV_MENTION}{msg_content}")
+            allowed_roles = [discord.Object(constants.Roles.core_developers)]
+            message = await channel.send(
+                f"{self._CORE_DEV_MENTION}{msg_content}",
+                allowed_mentions=discord.AllowedMentions(everyone=False, roles=allowed_roles)
+            )
         else:
             await message.edit(content=msg_content)
 


Test patch: