Skip to content

Commit

Permalink
Rarity command now works #2273
Browse files Browse the repository at this point in the history
  • Loading branch information
Nargacaura authored and BastLast committed Feb 22, 2024
1 parent 0af578f commit 85cce24
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Discord/src/commands/player/RarityCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket";
import {CommandRarityPacketReq, CommandRarityPacketRes} from "../../../../Lib/src/packets/commands/CommandRarityPacket";
import {DiscordCache} from "../../bot/DiscordCache";
import i18n from "../../translations/i18n";
import {DraftBotEmbed} from "../../messages/DraftBotEmbed";
import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator";
import {ICommand} from "../ICommand";

function getPacket(): CommandRarityPacketReq {
return makePacket(CommandRarityPacketReq, {});
}

export async function handleCommandRarityPacketRes(packet: CommandRarityPacketRes, context: PacketContext): Promise<void> {
const interaction = DiscordCache.getInteraction(context.discord!.interaction);

if (interaction) {
await interaction.reply({
embeds: [new DraftBotEmbed()
.setTitle(i18n.t("commands:rarity.title", {
lng: interaction.channel.language
}
))

Check failure on line 22 in Discord/src/commands/player/RarityCommand.ts

View workflow job for this annotation

GitHub Actions / eslint-discord-module

Unexpected newline before ')'
.setDescription(i18n.t("commands:rarity.rarities", {
common: packet.common,
uncommon: packet.uncommon,
exotic: packet.exotic,
rare: packet.rare,
special: packet.special,
epic: packet.epic,
legendary: packet.legendary,
unique: packet.unique,
lng: interaction.channel.language
}))]
});
}
}

export const commandInfo: ICommand = {
slashCommandBuilder: SlashCommandBuilderGenerator.generateBaseCommand("rarity"),
getPacket,
requirements: {},
mainGuildCommand: false
};
7 changes: 7 additions & 0 deletions Discord/src/packetHandlers/handlers/CommandHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {handleCommandUpdatePacketRes} from "../../commands/player/UpdateCommand"
import { CommandUpdatePacketRes } from "../../../../Lib/src/packets/commands/CommandUpdatePacket";
import {CommandTestPacketReq, CommandTestPacketRes} from "../../../../Lib/src/packets/commands/CommandTestPacket";
import {handleCommandTestPacketRes} from "../../commands/player/TestCommand";
import {CommandRarityPacketRes} from "../../../../Lib/src/packets/commands/CommandRarityPacket";
import {handleCommandRarityPacketRes} from "../../commands/player/RarityCommand";

export default class CommandHandlers {
@packetHandler(CommandPingPacketRes)
Expand Down Expand Up @@ -48,4 +50,9 @@ export default class CommandHandlers {
testRes(socket: WebSocket, packet: CommandTestPacketRes, context: PacketContext): void {
handleCommandTestPacketRes(packet, context).then();
}

@packetHandler(CommandRarityPacketRes)
rarityRes(socket: WebSocket, packet: CommandRarityPacketRes, context: PacketContext): void {
handleCommandRarityPacketRes(packet, context).then();
}
}
4 changes: 4 additions & 0 deletions Lang/en/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
},
"title": "{{effect}} | {{pseudo}} | Level {{level}}"
},
"rarity": {
"title": ":slot_machine: Equipment rarity",
"rarities": ":small_orange_diamond: Basic | Owned at the beginning of the game\n:large_orange_diamond: Common | {{common}}%\n:fire: Uncommon | {{uncommon}}%\n:trident: Exotic | {{exotic}}%\n:comet: Rare | {{rare}}%\n:dizzy: Special | {{special}}%\n:star: Epic | {{epic}}%\n:star2: Legendary | {{legendary}}%\n:gem: Mythical | {{unique}}%"
},
"update": {
"description": "The latest version of the bot's core is **{{coreVersion}}**. The Discord module's version is **{{discordModuleVersion}}**.\n\nInformations about the changelog can be found here:\nhttps://guide.draftbot.com/v/en/lore/change-logs",
"title": ":scroll: Changelog"
Expand Down
4 changes: 4 additions & 0 deletions Lang/en/discordBuilder.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
}
}
},
"rarity": {
"description": "Displays the different equipment rarities.",
"name": "rarity"
},
"update": {
"description": "Displays the bot's latest version.",
"name": "update"
Expand Down
4 changes: 4 additions & 0 deletions Lang/fr/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
},
"title": "{{effect}} | {{pseudo}} | Niveau {{level}}"
},
"rarity": {
"title": ":slot_machine: Rareté des équipements",
"rarities": ":small_orange_diamond: Basique | Possédé en début de jeu\n:large_orange_diamond: Commun | {{common}}%\n:fire: Peu commun | {{uncommon}}%\n:trident: Exotique | {{exotic}}%\n:comet: Rare | {{rare}}%\n:dizzy: Spécial | {{special}}%\n:star: Épique | {{epic}}%\n:star2: Légendaire | {{legendary}}%\n:gem: Mythique | {{unique}}%"
},
"update": {
"description": "La version actuelle du noyau du bot est la **{{coreVersion}}**. Celle du module Discord est la **{{discordModuleVersion}}**.\n\nToutes les informations concernant les mises à jour sont disponibles ici :\nhttps://guide.draftbot.com/lore/historique-des-mises-a-jour",
"title": ":scroll: Mises à jour"
Expand Down
4 changes: 4 additions & 0 deletions Lang/fr/discordBuilder.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
}
}
},
"rarity": {
"description": "Affiche les différentes raretés des équipements.",
"name": "rarete"
},
"update": {
"description": "Affiche la version actuelle du bot.",
"name": "nouveautes"
Expand Down

0 comments on commit 85cce24

Please sign in to comment.