Skip to content

Commit df41d31

Browse files
committed
Block new thread from react to contact when Modmail DM is disabled (new or all).
1 parent 93b0270 commit df41d31

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

bot.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,15 +1238,33 @@ async def on_raw_reaction_add(self, payload):
12381238
if not member.bot:
12391239
message = await channel.fetch_message(payload.message_id)
12401240
await message.remove_reaction(payload.emoji, member)
1241+
await message.add_reaction(emoji_fmt) # bot adds as well
1242+
1243+
if self.config["dm_disabled"] in (
1244+
DMDisabled.NEW_THREADS,
1245+
DMDisabled.ALL_THREADS,
1246+
):
1247+
embed = discord.Embed(
1248+
title=self.config["disabled_new_thread_title"],
1249+
color=self.error_color,
1250+
description=self.config["disabled_new_thread_response"],
1251+
)
1252+
embed.set_footer(
1253+
text=self.config["disabled_new_thread_footer"],
1254+
icon_url=self.guild.icon_url,
1255+
)
1256+
logger.info(
1257+
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
1258+
message.author,
1259+
)
1260+
return await member.send(embed=embed)
12411261

12421262
ctx = await self.get_context(message)
12431263
ctx.author = member
12441264
await ctx.invoke(
12451265
self.get_command("contact"), user=member, manual_trigger=False
12461266
)
12471267

1248-
await message.add_reaction(emoji_fmt) # bot adds as well
1249-
12501268
async def on_raw_reaction_remove(self, payload):
12511269
if self.config["transfer_reactions"]:
12521270
await self.handle_reaction_events(payload)

0 commit comments

Comments
 (0)