Skip to content

Commit

Permalink
feat: localize suggestions commands #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Skelmis committed Nov 23, 2022
1 parent d1cd3c9 commit 38a7a0e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
39 changes: 30 additions & 9 deletions suggestions/cogs/suggestion_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@ async def suggest(

try:
embed: disnake.Embed = disnake.Embed(
description=f"Hey, {interaction.author.mention}. Your suggestion has been sent "
f"to {channel.mention} to be voted on!\n\n"
f"Please wait until it gets approved or rejected by a staff member.\n\n"
f"Your suggestion ID (sID) for reference is **{suggestion.suggestion_id}**.",
description=self.bot.get_locale(
"SUGGEST_INNER_SUGGESTION_SENT", interaction.locale
).format(
interaction.author.mention,
channel.mention,
suggestion.suggestion_id,
),
timestamp=self.state.now,
color=self.bot.colors.embed_color,
)
Expand All @@ -237,15 +240,20 @@ async def suggest(
icon_url=icon_url,
)
embed.set_footer(
text=f"Guild ID: {interaction.guild_id} | sID: {suggestion.suggestion_id}"
text=self.bot.get_locale(
"SUGGEST_INNER_SUGGESTION_SENT_FOOTER", interaction.locale
).format(interaction.guild_id, suggestion.suggestion_id)
)
user_config: UserConfig = await UserConfig.from_id(
interaction.author.id, self.bot.state
)
if user_config.dm_messages_disabled or guild_config.dm_messages_disabled:
await interaction.send(embed=embed, ephemeral=True)
else:
await interaction.send("Thanks for your suggestion!", ephemeral=True)
await interaction.send(
self.bot.get_locale("SUGGEST_INNER_THANKS", interaction.locale),
ephemeral=True,
)
await interaction.author.send(embed=embed)
except disnake.HTTPException as e:
log.debug(
Expand Down Expand Up @@ -307,7 +315,12 @@ async def approve(
guild_config=guild_config,
)

await interaction.send(f"You have approved **{suggestion_id}**", ephemeral=True)
await interaction.send(
self.bot.get_locale("APPROVE_INNER_MESSAGE", interaction.locale).format(
suggestion_id
),
ephemeral=True,
)
log.debug(
"User %s approved suggestion %s in guild %s",
interaction.author.id,
Expand Down Expand Up @@ -359,7 +372,12 @@ async def reject(
guild_config=guild_config,
)

await interaction.send(f"You have rejected **{suggestion_id}**", ephemeral=True)
await interaction.send(
self.bot.get_locale("REJECT_INNER_MESSAGE", interaction.locale).format(
suggestion_id
),
ephemeral=True,
)
log.debug(
"User %s rejected suggestion %s in guild %s",
interaction.author.id,
Expand Down Expand Up @@ -410,7 +428,10 @@ async def clear(

await suggestion.mark_cleared_by(self.state, interaction.user.id, response)
await interaction.send(
f"I have cleared `{suggestion_id}` for you.", ephemeral=True
self.bot.get_locale("CLEAR_INNER_MESSAGE", interaction.locale).format(
suggestion_id
),
ephemeral=True,
)
log.debug(
"User %s cleared suggestion %s in guild %s",
Expand Down
8 changes: 7 additions & 1 deletion suggestions/locales/en_GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@
"DISPLAY_DATA_INNER_OLD_SUGGESTION_TYPE": "Suggestions using reactions are not supported by this command.",
"DISPLAY_DATA_INNER_NO_VOTERS": "There are no voters to show you for this.",
"VOTER_PAGINATOR_INNER_EMBED_TITLE": "{} for suggestion `{}`",
"VOTER_PAGINATOR_INNER_EMBED_FOOTER": "Page {} of {}"
"VOTER_PAGINATOR_INNER_EMBED_FOOTER": "Page {} of {}",
"APPROVE_INNER_MESSAGE": "You have approved **{}**",
"REJECT_INNER_MESSAGE": "You have rejected **{}**",
"CLEAR_INNER_MESSAGE": "I have cleared `{}` for you.",
"SUGGEST_INNER_SUGGESTION_SENT": "Hey, {}. Your suggestion has been sent to {} to be voted on!\nPlease wait until it gets approved or rejected by a staff member.\nYour suggestion ID (sID) for reference is **{}**.",
"SUGGEST_INNER_SUGGESTION_SENT_FOOTER": "Guild ID: {} | sID: {}",
"SUGGEST_INNER_THANKS": "Thanks for your suggestion!"
}

0 comments on commit 38a7a0e

Please sign in to comment.