Compare commits
No commits in common. "7c0ab73ac052762a254b29f1c0b35ac090532b6a" and "dd33315e166fcce7c28065ec56a6378529ba4468" have entirely different histories.
7c0ab73ac0
...
dd33315e16
1 changed files with 7 additions and 27 deletions
|
@ -511,28 +511,6 @@ 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
|
||||||
|
@ -579,7 +557,7 @@ class Suggestions(commands.Cog):
|
||||||
icon_url=footer[1]
|
icon_url=footer[1]
|
||||||
)
|
)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Results", value=await self._interaction_get_results(interaction, old_msg), inline=False
|
name="Results", value=await self._get_results(await commands.Context.from_interaction(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)
|
||||||
|
@ -620,8 +598,9 @@ class Suggestions(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
class SuggestionApproveModal(discord.ui.Modal, title="Approving suggestion..."):
|
||||||
def __init__(self, message):
|
def __init__(self, old_interaction, 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(
|
||||||
|
@ -633,7 +612,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 = interaction.client.get_cog('Suggestions')
|
cog = self.old_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:
|
||||||
|
@ -641,8 +620,9 @@ 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, message):
|
def __init__(self, old_interaction, 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(
|
||||||
|
@ -654,7 +634,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 = interaction.client.get_cog('Suggestions')
|
cog = self.old_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