parent
f965eaacde
commit
f244e85b27
3 changed files with 23 additions and 6 deletions
@ -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}); |
||||
} |
||||
} |
||||
|
||||
|
Loading…
Reference in new issue