misc(suggestions): improved code structure
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
480ff5915f
commit
b74569e4eb
1 changed files with 9 additions and 17 deletions
|
@ -47,7 +47,7 @@ class Suggestions(commands.Cog):
|
|||
else:
|
||||
return f"{user.name}#{user.discriminator}"
|
||||
|
||||
async def red_delete_data_for_user(self, *, requester, user_id):
|
||||
async def red_delete_data_for_user(self, *, requester, user_id: discord.User.id):
|
||||
# per guild suggestions
|
||||
for guild in self.bot.guilds:
|
||||
for suggestion_id in range(1, await self.config.guild(guild).next_id()):
|
||||
|
@ -136,7 +136,7 @@ class Suggestions(commands.Cog):
|
|||
reason: typing.Optional[str],
|
||||
):
|
||||
"""Approve a suggestion."""
|
||||
await self._finish_suggestion(ctx, suggestion_id, True, reason, ctx.author)
|
||||
await self._finish_suggestion(ctx, suggestion_id, True, reason)
|
||||
|
||||
@checks.admin()
|
||||
@commands.command()
|
||||
|
@ -150,7 +150,7 @@ class Suggestions(commands.Cog):
|
|||
reason: typing.Optional[str],
|
||||
):
|
||||
"""Deny a suggestion. Reason is optional."""
|
||||
await self._finish_suggestion(ctx, suggestion_id, False, reason, ctx.author)
|
||||
await self._finish_suggestion(ctx, suggestion_id, False, reason)
|
||||
|
||||
@checks.admin()
|
||||
@commands.command()
|
||||
|
@ -394,7 +394,7 @@ class Suggestions(commands.Cog):
|
|||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_reaction_add(self, reaction, user):
|
||||
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Message):
|
||||
message = reaction.message
|
||||
if user.id == self.bot.user.id:
|
||||
return
|
||||
|
@ -409,7 +409,7 @@ class Suggestions(commands.Cog):
|
|||
):
|
||||
await message_reaction.remove(user)
|
||||
|
||||
async def _get_results(self, ctx, message):
|
||||
async def _get_results(self, ctx: commands.Context, message: discord.Message):
|
||||
up_emoji, down_emoji = await self._get_emojis(ctx)
|
||||
up_count = 0
|
||||
down_count = 0
|
||||
|
@ -422,7 +422,7 @@ class Suggestions(commands.Cog):
|
|||
|
||||
return f"{up_count}x {up_emoji}\n{down_count}x {down_emoji}"
|
||||
|
||||
async def _get_emojis(self, ctx):
|
||||
async def _get_emojis(self, ctx: typing.Union[commands.Context, discord.Interaction]):
|
||||
up_emoji = self.bot.get_emoji(await self.config.guild(ctx.guild).up_emoji())
|
||||
if not up_emoji:
|
||||
up_emoji = "✅"
|
||||
|
@ -431,8 +431,9 @@ class Suggestions(commands.Cog):
|
|||
down_emoji = "âŽ"
|
||||
return up_emoji, down_emoji
|
||||
|
||||
async def _finish_suggestion(self, ctx, suggestion_id, approve, reason, author):
|
||||
async def _finish_suggestion(self, ctx: commands.Context, suggestion_id: int, approve: bool, reason: str):
|
||||
server = ctx.guild.id
|
||||
author = ctx.author
|
||||
old_channel = ctx.guild.get_channel(
|
||||
await self.config.guild(ctx.guild).suggest_id()
|
||||
)
|
||||
|
@ -510,7 +511,7 @@ class Suggestions(commands.Cog):
|
|||
)
|
||||
await ctx.tick()
|
||||
|
||||
async def _interaction_get_results(self, interaction: discord.Interaction, message):
|
||||
async def _interaction_get_results(self, interaction: discord.Interaction, message: discord.Message):
|
||||
up_emoji, down_emoji = await self._get_emojis(interaction)
|
||||
up_count = 0
|
||||
down_count = 0
|
||||
|
@ -523,15 +524,6 @@ class Suggestions(commands.Cog):
|
|||
|
||||
return f"{up_count}x {up_emoji}\n{down_count}x {down_emoji}"
|
||||
|
||||
async def _interaction_get_emojis(self, interaction: discord.Interaction):
|
||||
up_emoji = self.bot.get_emoji(await self.config.guild(interaction.guild).up_emoji())
|
||||
if not up_emoji:
|
||||
up_emoji = "✅"
|
||||
down_emoji = self.bot.get_emoji(await self.config.guild(interaction.guild).down_emoji())
|
||||
if not down_emoji:
|
||||
down_emoji = "âŽ"
|
||||
return up_emoji, down_emoji
|
||||
|
||||
async def _interaction_finish_suggestion(self, interaction: discord.Interaction, message: discord.Message, approve: bool, reason: str = None):
|
||||
embed = message.embeds
|
||||
title = embed[0].title
|
||||
|
|
Loading…
Reference in a new issue