Compare commits
2 commits
dd33315e16
...
7c0ab73ac0
Author | SHA1 | Date | |
---|---|---|---|
7c0ab73ac0 | |||
b943ba276f |
1 changed files with 27 additions and 7 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)
|
||||||
|
@ -598,9 +620,8 @@ class Suggestions(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
||||||
def __init__(self, old_interaction, message):
|
def __init__(self, message):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.old_interaction: discord.Interaction = old_interaction
|
|
||||||
self.message: discord.Message = message
|
self.message: discord.Message = message
|
||||||
|
|
||||||
reason = discord.ui.TextInput(
|
reason = discord.ui.TextInput(
|
||||||
|
@ -612,7 +633,7 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
cog = self.old_interaction.client.get_cog('Suggestions')
|
cog = interaction.client.get_cog('Suggestions')
|
||||||
if self.reason.value != "":
|
if self.reason.value != "":
|
||||||
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, True, self.reason.value)
|
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, True, self.reason.value)
|
||||||
else:
|
else:
|
||||||
|
@ -620,9 +641,8 @@ class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
||||||
await interaction.response.send_message(content="Suggestion approved!", ephemeral=True)
|
await interaction.response.send_message(content="Suggestion approved!", ephemeral=True)
|
||||||
|
|
||||||
class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
|
class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
|
||||||
def __init__(self, old_interaction, message):
|
def __init__(self, message):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.old_interaction: discord.Interaction = old_interaction
|
|
||||||
self.message: discord.Message = message
|
self.message: discord.Message = message
|
||||||
|
|
||||||
reason = discord.ui.TextInput(
|
reason = discord.ui.TextInput(
|
||||||
|
@ -634,7 +654,7 @@ class SuggestionDenyModal(discord.ui.Modal, title="Denying suggestion..."):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
cog = self.old_interaction.client.get_cog('Suggestions')
|
cog = interaction.client.get_cog('Suggestions')
|
||||||
if self.reason.value != "":
|
if self.reason.value != "":
|
||||||
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, False, self.reason.value)
|
await Suggestions._interaction_finish_suggestion(cog, interaction, self.message, False, self.reason.value)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue