feat(forums): fleshed out the resolved buttons
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Seaswimmer 2023-09-07 19:17:42 -04:00
parent 96ced7982e
commit 4709af1146
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -40,17 +40,37 @@ class Forums(commands.Cog):
self.ctx: commands.Context = passed_info['ctx'] self.ctx: commands.Context = passed_info['ctx']
self.match: bool = passed_info['match'] self.match: bool = passed_info['match']
self.msg: discord.Message = passed_info['msg'] self.msg: discord.Message = passed_info['msg']
if passed_info['reason']: if 'reason' in passed_info:
self.reason: str = passed_info['reason'] self.reason: str = passed_info['reason']
self.config = Config.get_conf(None, cog_name='Forums', identifier=2352711325) self.config = Config.get_conf(None, cog_name='Forums', identifier=2352711325)
@ui.button(label="Yes", style=discord.ButtonStyle.success, emoji="") @ui.button(label="Yes", style=discord.ButtonStyle.success, emoji="")
async def resolved_button_yes(self, button: ui.Button, interaction: discord.Interaction): async def resolved_button_yes(self, button: ui.Button, interaction: discord.Interaction):
channel = self.ctx.channel match = any(role_id in interaction.user.roles for role_id in await self.config.guild(interaction.guild).request_roles())
await interaction.response.defer() if match or interaction.user.id == interaction.channel.owner_id:
await channel.edit(locked=True, archived=True, applied_tags=channel.applied_tags + await self.config.guild(channel.guild).forum_tag()) channel = self.ctx.channel
await self.msg.delete() await interaction.response.defer()
await self.ctx.message.add_reaction("") if self.reason:
response_reason = f"Thread closed by {interaction.user.mention} with reason: {self.reason}"
reason = f"Thread closed by {interaction.user.name} ({interaction.user.id}) with reason: {self.reason}"
else:
response_reason = f"Thread closed by {interaction.user.mention}"
reason = f"Thread closed by {interaction.user.name} ({interaction.user.id})"
await channel.edit(locked=True, archived=True, applied_tags=channel.applied_tags + await self.config.guild(channel.guild).forum_tag(), reason=reason)
await self.msg.edit(content=response_reason, view=None)
await self.ctx.message.add_reaction("")
else:
await interaction.response.send_message(content="You cannot close this thread!", ephemeral=True)
@ui.button(label="No", style=discord.ButtonStyle.success, emoji="")
async def resolved_button_no(self, button: ui.Button, interaction: discord.Interaction):
match = any(role_id in interaction.user.roles for role_id in await self.config.guild(interaction.guild).request_roles())
if match or interaction.user.id == interaction.channel.owner_id:
await interaction.response.defer()
await self.msg.delete()
await self.ctx.message.delete()
else:
await interaction.response.send_message(content="You cannot close this thread!", ephemeral=True)
@commands.group(name='forumconfig', invoke_without_command=True, aliases=['forumsset']) @commands.group(name='forumconfig', invoke_without_command=True, aliases=['forumsset'])
@commands.guild_only() @commands.guild_only()