Skip to content

Commit

Permalink
Allow chat mod team leads to bypass perm deny req
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBSG committed May 20, 2024
1 parent 5fd98fe commit 2934f56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self):

async def setup_hook(self):
await self.load_extension('jishaku')
await self.load_extension('cogs.modmail')

async def on_ready(self):
logging.info(f'Parakarry ModMail Bot - Now Logged in as {self.user} ({self.user.id})')
Expand All @@ -44,5 +43,7 @@ async def on_ready(self):
await g.chunk(cache=True)
logging.info(f'Chunked members for guild: {g.name} ({g.id})')

await self.load_extension('cogs.modmail')


asyncio.run(Parakarry().start(config.token))
6 changes: 4 additions & 2 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self, bot):
self.bot = bot
self.closeQueue = {}

self.leadModRole = self.bot.get_guild(config.guild).get_role(config.leadModRole)

self.openContextMenu = app_commands.ContextMenu(name='Open a Modmail', callback=self._open_context)
self.reportContextMenu = app_commands.ContextMenu(name='Report this Message', callback=self._message_report)
self.bot.tree.add_command(self.openContextMenu, guild=discord.Object(id=config.guild))
Expand Down Expand Up @@ -148,7 +150,7 @@ async def _reply(self, interaction: discord.Interaction, content, attachment, an
elif interaction.guild.owner == interaction.user:
responsibleModerator = f'*(Server Owner)* **{interaction.user}**'

elif self.bot.get_guild(config.guild).get_role(config.leadModRole) in interaction.user.roles:
elif self.leadModRole in interaction.user.roles:
responsibleModerator = f'*(Lead Moderator)* **{interaction.user}**'

else:
Expand Down Expand Up @@ -393,7 +395,7 @@ async def _appeal_deny(
durationUserStr = f'You may appeal again after __<t:{delayDate}:f> (approximately <t:{delayDate}:R>)__. In the meantime you have been kicked from the Ban Appeals server. When you are able to appeal again you may rejoin with this invite: {config.appealInvite}\n\nReason given by moderators:\n```{reason}```'

else:
if punsDB.count_documents({'user': user.id, 'type': 'appealdeny'}) < 2:
if self.leadModRole not in interaction.user.roles and punsDB.count_documents({'user': user.id, 'type': 'appealdeny'}) < 2:
# User has not met the minimum appeal denials to be permanently denied
return await interaction.response.send_message(
':x: To permanently deny a ban appeal, the user must have been denied at least 2 times previously'
Expand Down

0 comments on commit 2934f56

Please sign in to comment.