Skip to content

Commit

Permalink
fix non-ephemeral translation + /stats command
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Oct 22, 2023
1 parent 6028c81 commit 60dc55e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion lang/en-US/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"need_more_info": "You need to have either a description or title for an embed."
},
"stats": {
"footer": "Made with love",
"usage": "%COMMAND% has ran %USE% times.",
"top_ten": "Top 10 most used commands:",
"not_found": "The command `%COMMAND%` doesn't exist!"
Expand Down
18 changes: 11 additions & 7 deletions src/commands/bot/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ export const command: SlashCommand = {
{ name: "Operating System", value: version },
)
.setFooter({
text: interaction.strings().command.stats.footer,
text: "Made with love",
iconURL: image,
});
interaction
.reply({ embeds: [embed], fetchReply: true })
.then((message: Message) => message.deleteButton());
})
.set("command", async (interaction: ChatInputCommandInteraction, client: Client) => {
.set("command", async (interaction: ChatInputCommandInteraction) => {
//if the command args are provided and the command does not exist in commandsProcessed:
if (
interaction.options.getString("command") &&
client.commandsProcessed.get(interaction.options.getString("command")) === undefined
interaction.client.commandsProcessed.get(interaction.options.getString("command")) ===
undefined
)
return interaction.reply({
ephemeral: true,
Expand All @@ -92,14 +93,17 @@ export const command: SlashCommand = {
.command.stats.usage.replace("%COMMAND%", interaction.options.getString("command"))
.replace(
"%USE%",
client.commandsProcessed.get(interaction.options.getString("command")).toString() ??
"0",
interaction.client.commandsProcessed
.get(interaction.options.getString("command"))
.toString() ?? "0",
),
);
interaction.reply({ ephemeral: true, embeds: [embed], fetchReply: true });
interaction.reply({ ephemeral: true, embeds: [embed] });
} else {
//sorts commands by usage: 4,3,2,1
const sorted = new Map([...client.commandsProcessed.entries()].sort((a, b) => b[1] - a[1]));
const sorted = new Map(
[...interaction.client.commandsProcessed.entries()].sort((a, b) => b[1] - a[1]),
);
const data = [[...sorted.keys()], [...sorted.values()]];

const embed = new EmbedBuilder()
Expand Down

0 comments on commit 60dc55e

Please sign in to comment.