fix(forums): fixed role whitelist not working correctly
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
parent
0c9dcba375
commit
eef151d461
1 changed files with 10 additions and 6 deletions
|
@ -20,10 +20,11 @@ class Forums(commands.Cog):
|
||||||
async def resolved(self, ctx: commands.Context, reason: str = None):
|
async def resolved(self, ctx: commands.Context, reason: str = None):
|
||||||
"""Marks a thread as resolved."""
|
"""Marks a thread as resolved."""
|
||||||
if isinstance(ctx.channel, discord.Thread) and ctx.channel.parent_id == await self.config.guild(ctx.guild).forum_channel():
|
if isinstance(ctx.channel, discord.Thread) and ctx.channel.parent_id == await self.config.guild(ctx.guild).forum_channel():
|
||||||
match = any(role_id in ctx.author.roles for role_id in await self.config.guild(ctx.guild).request_roles())
|
request_role_ids = await self.config.guild(ctx.guild).request_roles()
|
||||||
|
request_roles = [ctx.guild.get_role(role_id) for role_id in request_role_ids]
|
||||||
|
match = any(role in ctx.author.roles for role in request_roles)
|
||||||
passed_info = {
|
passed_info = {
|
||||||
"ctx": ctx,
|
"ctx": ctx
|
||||||
"match": match
|
|
||||||
}
|
}
|
||||||
if match and reason:
|
if match and reason:
|
||||||
passed_info.update({"reason": reason})
|
passed_info.update({"reason": reason})
|
||||||
|
@ -39,7 +40,6 @@ class Forums(commands.Cog):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.ctx: commands.Context = passed_info['ctx']
|
self.ctx: commands.Context = passed_info['ctx']
|
||||||
self.match: bool = passed_info['match']
|
|
||||||
self.msg: discord.Message = passed_info['msg']
|
self.msg: discord.Message = passed_info['msg']
|
||||||
if 'reason' in passed_info:
|
if 'reason' in passed_info:
|
||||||
self.reason: str = passed_info['reason']
|
self.reason: str = passed_info['reason']
|
||||||
|
@ -49,7 +49,9 @@ class Forums(commands.Cog):
|
||||||
|
|
||||||
@ui.button(label="Yes", style=discord.ButtonStyle.success, emoji="✅")
|
@ui.button(label="Yes", style=discord.ButtonStyle.success, emoji="✅")
|
||||||
async def resolved_button_yes(self, interaction: discord.Interaction, button: ui.Button):
|
async def resolved_button_yes(self, interaction: discord.Interaction, button: ui.Button):
|
||||||
match = any(role_id in interaction.user.roles for role_id in await self.config.guild(interaction.guild).request_roles())
|
request_role_ids = await self.config.guild(interaction.guild).request_roles()
|
||||||
|
request_roles = [interaction.guild.get_role(role_id) for role_id in request_role_ids]
|
||||||
|
match = any(role in interaction.user.roles for role in request_roles)
|
||||||
if match or interaction.user.id == interaction.channel.owner.id:
|
if match or interaction.user.id == interaction.channel.owner.id:
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
if self.reason:
|
if self.reason:
|
||||||
|
@ -70,7 +72,9 @@ class Forums(commands.Cog):
|
||||||
|
|
||||||
@ui.button(label="No", style=discord.ButtonStyle.danger, emoji="✖️")
|
@ui.button(label="No", style=discord.ButtonStyle.danger, emoji="✖️")
|
||||||
async def resolved_button_no(self, interaction: discord.Interaction, button: ui.Button):
|
async def resolved_button_no(self, interaction: discord.Interaction, button: ui.Button):
|
||||||
match = any(role_id in interaction.user.roles for role_id in await self.config.guild(interaction.guild).request_roles())
|
request_role_ids = await self.config.guild(interaction.guild).request_roles()
|
||||||
|
request_roles = [interaction.guild.get_role(role_id) for role_id in request_role_ids]
|
||||||
|
match = any(role in interaction.user.roles for role in request_roles)
|
||||||
if match or interaction.user.id == interaction.channel.owner.id:
|
if match or interaction.user.id == interaction.channel.owner.id:
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
await self.msg.delete()
|
await self.msg.delete()
|
||||||
|
|
Loading…
Reference in a new issue