diff options
| author | 2020-07-12 13:38:02 +0200 | |
|---|---|---|
| committer | 2020-07-12 13:38:02 +0200 | |
| commit | 57e210ccfcc91132182029f1d931118e715439b2 (patch) | |
| tree | a64848414a5ced98f469ae105a9d6fd287b3f153 | |
| parent | Ping @Moderators in ModLog (diff) | |
Allow role pings in Syncers and help_channels.py
Now that we're running Discord 1.4.0a, we need to explicitely allow all
the role mentions for sends that don't use ping one of the globally
whitelisted role pings, which are Moderators, Admins and Owners.
We were pinging roles other than Mods+ in exactly two cases:
- Inside the Syncers, whenever we ask for sync confirmation (if the
number of roles or users to sync is unusually high)
- In the help_channels.py system, whenever we max out help channels and
are unable to create more.
This commit addresses both of these.
GitHub #1038
https://github.com/python-discord/bot/issues/1038
| -rw-r--r-- | bot/cogs/help_channels.py | 4 | ||||
| -rw-r--r-- | bot/cogs/sync/syncers.py | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 187adfe51..fd1a449c1 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -624,11 +624,13 @@ class HelpChannels(Scheduler, commands.Cog): 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/sync/syncers.py b/bot/cogs/sync/syncers.py index 536455668..f7ba811bc 100644 --- a/bot/cogs/sync/syncers.py +++ b/bot/cogs/sync/syncers.py @@ -5,6 +5,7 @@ import typing as t 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 @@ class Syncer(abc.ABC): ) 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) |