added "add" command

main
Benjamin Kraft 9 months ago
parent f965eaacde
commit f244e85b27
  1. 1
      src/bot.ts
  2. 20
      src/commands/add.ts
  3. 8
      src/commands/ping.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<true>){

@ -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});
}
}

@ -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});
}
}

Loading…
Cancel
Save