|
@@ -25,8 +25,8 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
|
|
|
super().__init__(config, database_file, loop=loop)
|
|
|
self.discord_client = client
|
|
|
client.event(self.on_message)
|
|
|
- if secrets["discord"].get("enable_react_notifs", False):
|
|
|
- client.event(self.on_reaction_add)
|
|
|
+ client.event(self.on_reaction_add)
|
|
|
+ self.missing_pings = []
|
|
|
|
|
|
def read_config(self, key: str) -> Any:
|
|
|
cfg = secrets
|
|
@@ -45,6 +45,28 @@ class DiscordBot(rollbot.Rollbot[discord.Message]):
|
|
|
async def on_reaction_add(
|
|
|
self, reaction: discord.Reaction, user: discord.Member | discord.User
|
|
|
):
|
|
|
+ try:
|
|
|
+ if (
|
|
|
+ not isinstance(reaction.emoji, str)
|
|
|
+ and reaction.emoji.name == "missingping"
|
|
|
+ ):
|
|
|
+ if not self.missing_pings:
|
|
|
+ # note this probably breaks if used across multiple servers...
|
|
|
+ await client.fetch_guild(reaction.message.guild.id)
|
|
|
+ self.missing_pings = [
|
|
|
+ discord.utils.get(client.emojis, name=name)
|
|
|
+ for name in (
|
|
|
+ "missingping2",
|
|
|
+ "missingping3",
|
|
|
+ "missingping4",
|
|
|
+ "missingping5",
|
|
|
+ )
|
|
|
+ ]
|
|
|
+ for ping in self.missing_pings:
|
|
|
+ await reaction.message.add_reaction(ping)
|
|
|
+ except Exception:
|
|
|
+ self.context.logger.exception("Failed to do the funny missing ping bit")
|
|
|
+
|
|
|
sender_id = getattr(reaction.message.author, "id", None)
|
|
|
if (
|
|
|
str(sender_id) not in secrets["discord"].get("wants_react_notifs", [])
|