fix(suggestions): implemented interaction variants of get_results and get_emojis
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
b943ba276f
commit
7c0ab73ac0
1 changed files with 23 additions and 1 deletions
|
@ -511,6 +511,28 @@ class Suggestions(commands.Cog):
|
||||||
)
|
)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
|
async def _interaction_get_results(self, interaction: discord.Interaction, message):
|
||||||
|
up_emoji, down_emoji = await self._get_emojis(interaction)
|
||||||
|
up_count = 0
|
||||||
|
down_count = 0
|
||||||
|
|
||||||
|
for reaction in message.reactions:
|
||||||
|
if reaction.emoji == up_emoji:
|
||||||
|
up_count = reaction.count - 1 # minus the bot
|
||||||
|
if reaction.emoji == down_emoji:
|
||||||
|
down_count = reaction.count - 1 # minus the bot
|
||||||
|
|
||||||
|
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):
|
async def _interaction_finish_suggestion(self, interaction: discord.Interaction, message: discord.Message, approve: bool, reason: str = None):
|
||||||
embed = message.embeds
|
embed = message.embeds
|
||||||
title = embed[0].title
|
title = embed[0].title
|
||||||
|
@ -557,7 +579,7 @@ class Suggestions(commands.Cog):
|
||||||
icon_url=footer[1]
|
icon_url=footer[1]
|
||||||
)
|
)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Results", value=await self._get_results(await commands.Context.from_interaction(interaction), old_msg), inline=False
|
name="Results", value=await self._interaction_get_results(interaction, old_msg), inline=False
|
||||||
)
|
)
|
||||||
if reason:
|
if reason:
|
||||||
embed.add_field(name="Reason", value=reason, inline=False)
|
embed.add_field(name="Reason", value=reason, inline=False)
|
||||||
|
|
Loading…
Reference in a new issue