Skip to content

Commit

Permalink
Simplify some overcomplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
yiays committed Oct 16, 2024
1 parent ea644d9 commit 38dd10b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
4 changes: 0 additions & 4 deletions extensions/confessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def __init__(self, bot:MerelyBot):
print(" - WARN: Without `confessions_moderation` enabled, vetting channels won't work")

self.crypto.key = self.config['secret']
self.ignore = set()
self.confession_cooldown = dict()

self.confess_reply = app_commands.ContextMenu(
Expand Down Expand Up @@ -251,9 +250,6 @@ async def on_confession_review(self, inter:discord.Interaction):
async def confession_request(self, msg:discord.Message):
""" Handle plain DM messages as confessions """
if isinstance(msg.channel, discord.DMChannel) and msg.author != self.bot.user:
if msg.channel in self.ignore:
self.ignore.remove(msg.channel)
return
if msg.author in self.confession_cooldown and\
self.confession_cooldown[msg.author] > time.time():
return
Expand Down
13 changes: 3 additions & 10 deletions extensions/confessions_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def __init__(
self.origin = origin
self.parent = parent
self.matches = matches
self.selection = matches[0][0]
self.confession = confession
self.soleguild = matches[0][0].guild if all((m.guild for m,_ in matches)) else None
self.update_list()
Expand Down Expand Up @@ -250,15 +251,7 @@ async def channel_selector(self, inter:discord.Interaction, this:discord.ui.Sele
await inter.response.send_message(self.parent.bot.babel(inter, 'error', 'wronguser'))
return
self.send_button.disabled = False
try:
self.selection = await self.parent.bot.fetch_channel(int(this.values[0]))
except discord.Forbidden:
self.send_button.disabled = True
await inter.response.edit_message(
content=self.parent.babel(inter, 'missingchannelerr')+' (select)',
view=self
)
return
self.selection = self.parent.bot.get_channel(int(this.values[0]))
self.update_list()
guildchannels = get_guildchannels(self.parent.config, self.selection.guild.id)
vetting = findvettingchannel(guildchannels)
Expand All @@ -270,7 +263,7 @@ async def channel_selector(self, inter:discord.Interaction, this:discord.ui.Sele
),
view=self)

@discord.ui.button(disabled=True, style=discord.ButtonStyle.primary)
@discord.ui.button(disabled=False, style=discord.ButtonStyle.primary, emoji='📨')
async def send_button(self, inter:discord.Interaction, _:discord.Button):
""" Send the confession """
if self.selection is None or self.done:
Expand Down

0 comments on commit 38dd10b

Please sign in to comment.