Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smallrefactoring + vote command #2417

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Core/src/commands/player/BadgesCommand.ts

This file was deleted.

8 changes: 0 additions & 8 deletions Core/src/commands/player/HelpCommand.ts

This file was deleted.

7 changes: 0 additions & 7 deletions Core/src/commands/player/IdeaCommand.ts

This file was deleted.

7 changes: 0 additions & 7 deletions Core/src/commands/player/VoteCommand.ts

This file was deleted.

7 changes: 2 additions & 5 deletions Discord/src/commands/player/BadgesCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {ICommand} from "../ICommand";
import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket";
import {CommandBadgesPacketReq} from "../../../../Lib/src/packets/commands/CommandBadgesPacket";
import {DraftbotInteraction} from "../../messages/DraftbotInteraction";
import i18n from "../../translations/i18n";
import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator";
Expand All @@ -9,8 +7,7 @@ import {DraftBotEmbed} from "../../messages/DraftBotEmbed";
/**
* Access information about badges
*/
async function getPacket(interaction: DraftbotInteraction): Promise<CommandBadgesPacketReq> {
const packet = makePacket(CommandBadgesPacketReq, {});
async function getPacket(interaction: DraftbotInteraction): Promise<null> {
await interaction.reply({
embeds: [new DraftBotEmbed()
.setTitle(i18n.t("commands:badges.title", {
Expand All @@ -20,7 +17,7 @@ async function getPacket(interaction: DraftbotInteraction): Promise<CommandBadge
lng: interaction.channel.language
}))]
});
return packet;
return null;
}

export const commandInfo: ICommand = {
Expand Down
9 changes: 3 additions & 6 deletions Discord/src/commands/player/HelpCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {ICommand} from "../ICommand";
import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket";
import {CommandHelpPacketReq} from "../../../../Lib/src/packets/commands/CommandHelpPacket";
import {DraftbotInteraction} from "../../messages/DraftbotInteraction";
import i18n from "../../translations/i18n";
import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator";
Expand Down Expand Up @@ -182,8 +180,7 @@ function generateReplacementObjectForHelpCommand(interaction: DraftbotInteractio
/**
* Get the list of available commands and information about what they do
*/
async function getPacket(interaction: DraftbotInteraction): Promise<CommandHelpPacketReq> {
const packet = makePacket(CommandHelpPacketReq, {});
async function getPacket(interaction: DraftbotInteraction): Promise<null> {
const helpMessage = new DraftBotEmbed();
const command = interaction.options.get(i18n.t("discordBuilder:help.options.commandName.name", {lng: Constants.LANGUAGE.ENGLISH}));
const askedCommand = command ? command.value as string : null;
Expand All @@ -201,7 +198,7 @@ async function getPacket(interaction: DraftbotInteraction): Promise<CommandHelpP
await interaction.reply({
embeds: [helpMessage]
});
return packet;
return null;
}

const commandMention = BotUtils.commandsMentions.get(HelpConstants.COMMANDS_DATA[command as keyof typeof HelpConstants.COMMANDS_DATA].NAME);
Expand Down Expand Up @@ -229,7 +226,7 @@ async function getPacket(interaction: DraftbotInteraction): Promise<CommandHelpP
embeds: [helpMessage]
});
}
return packet;
return null;
}

export const commandInfo: ICommand = {
Expand Down
28 changes: 28 additions & 0 deletions Discord/src/commands/player/VoteCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {ICommand} from "../ICommand";
import {DraftbotInteraction} from "../../messages/DraftbotInteraction";
import i18n from "../../translations/i18n";
import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator";
import {DraftBotEmbed} from "../../messages/DraftBotEmbed";

/**
* Shows the embed that redirects to the topGG vote page
*/
async function getPacket(interaction: DraftbotInteraction): Promise<null> {
await interaction.reply({
embeds: [new DraftBotEmbed()
.setTitle(i18n.t("commands:vote.title", {
lng: interaction.channel.language
}))
.setDescription(i18n.t("commands:vote.description", {
lng: interaction.channel.language
}))]
});
return null;
}

export const commandInfo: ICommand = {
slashCommandBuilder: SlashCommandBuilderGenerator.generateBaseCommand("vote"),
getPacket,
requirements: {},
mainGuildCommand: false
};
4 changes: 4 additions & 0 deletions Lang/en/discordBuilder.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"description": "Share with us your idea to improve the game.",
"name": "idea"
},
"vote": {
"description": "Displays the link to vote for the bot.",
"name": "vote"
},
"inventory": {
"description": "Displays the player's inventory.",
"name": "inventory",
Expand Down
4 changes: 4 additions & 0 deletions Lang/fr/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"description": "Vous pouvez proposer des suggestions et voter pour vos idées préférées via ce lien:\nhttps://feedback.draftbot.com/",
"title": ":bulb: Idées"
},
"vote": {
"description": "Voici le lien permettant de soutenir le bot :\nhttps://top.gg/bot/448110812801007618",
"title": ":ballot_box: Voter"
},
"inventory": {
"armors_one": "Armure/Bouclier ({{count}}/{{max}}) :",
"armors_other": "Armures/Boucliers ({{count}}/{{max}}) :",
Expand Down
4 changes: 4 additions & 0 deletions Lang/fr/discordBuilder.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"description": "Affiche des informations sur les badges et leur fonctionnement.",
"name": "badges"
},
"vote": {
"description": "Afficher le lien permettant de voter pour le bot.",
"name": "vote"
},
"idea": {
"description": "Envoyer une suggestion pour améliorer le jeu.",
"name": "suggestion"
Expand Down
4 changes: 0 additions & 4 deletions Lib/src/packets/commands/CommandBadgesPacket.ts

This file was deleted.

4 changes: 0 additions & 4 deletions Lib/src/packets/commands/CommandHelpPacket.ts

This file was deleted.

7 changes: 0 additions & 7 deletions Lib/src/packets/commands/CommandVotePacket.ts

This file was deleted.

Loading