parent
f965eaacde
commit
f244e85b27
3 changed files with 23 additions and 6 deletions
@ -1,14 +1,28 @@ |
|||||||
import {Interaction} from "discord.js"; |
import {Interaction} from "discord.js"; |
||||||
import {Command} from "../command"; |
import {Command} from "../command"; |
||||||
|
import {UEMEloBot} from "../bot"; |
||||||
|
|
||||||
class Add extends Command { |
class Add extends Command { |
||||||
constructor() { |
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) { |
async execute(interaction: Interaction) { |
||||||
|
if (!interaction.isChatInputCommand()) |
||||||
|
return; |
||||||
|
|
||||||
if (interaction.isRepliable()) |
let client = interaction.client as UEMEloBot; |
||||||
await interaction.reply("Pong!"); |
|
||||||
|
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