diff --git a/src/bot.ts b/src/bot.ts index 0727f24..9ca87a1 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -79,6 +79,7 @@ export class UEMEloBot extends Client { this.players.push(player); console.log(`Added ${player}!`); this.savePlayersToFile(); + return player; } async onReady(readyClient: Client){ diff --git a/src/commands/add.ts b/src/commands/add.ts index 9e0546b..fb8b3b7 100644 --- a/src/commands/add.ts +++ b/src/commands/add.ts @@ -1,14 +1,28 @@ import {Interaction} from "discord.js"; import {Command} from "../command"; +import {UEMEloBot} from "../bot"; class Add extends Command { constructor() { - super("add", "add a player"); + super("add", "Spieler hinzufügen"); + this.data.addStringOption(option => { + return option.setName("riot-id").setDescription("Riot ID: 'Name#Tag'").setRequired(true) + }); } async execute(interaction: Interaction) { + if (!interaction.isChatInputCommand()) + return; - if (interaction.isRepliable()) - await interaction.reply("Pong!"); + let client = interaction.client as UEMEloBot; + + const riotId = interaction.options.getString("riot-id", true); + const [gameName, tagLine] = riotId.split("#"); + + const player = await client.addPlayer(gameName, tagLine); + if (player) + await interaction.reply({content: `${player} Hinzugefügt!`, ephemeral: true}); + else + await interaction.reply({content: "Fehler!", ephemeral: true}); } } diff --git a/src/commands/ping.ts b/src/commands/ping.ts index a7e41f7..a0c4345 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -3,11 +3,13 @@ import {Command} from "../command"; class Ping extends Command { constructor() { - super("ping", "One simple Ping Pong :)"); + super("ping", "Pong"); } async execute(interaction: Interaction) { - if (interaction.isRepliable()) - await interaction.reply("Pong!"); + if (!interaction.isChatInputCommand()) + return; + + await interaction.reply({content: "Pong", ephemeral: true}); } }