Basic Bot setup
This commit is contained in:
42
src/commands/economy/balance.ts
Normal file
42
src/commands/economy/balance.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { ApplicationCommandOptionType, ApplicationFlags, Client, CommandInteraction} from "discord.js"
|
||||
import User from "../../models/User";
|
||||
import CommandInterface from "../../utils/commandInterface";
|
||||
|
||||
const command: CommandInterface = {
|
||||
name: "balance",
|
||||
description: "Zeigt deinen Aktuellen Kontostand",
|
||||
onlyServerCommand: true,
|
||||
options: [
|
||||
{
|
||||
name: "user",
|
||||
description: "Der User von dem du das Konto sehen möchtest!",
|
||||
type: ApplicationCommandOptionType.Mentionable,
|
||||
}
|
||||
],
|
||||
|
||||
callback: async (client: Client<true>, interaction: CommandInteraction) => {
|
||||
await interaction.deferReply();
|
||||
|
||||
const userOption = await interaction.options.get("user")?.value?.toString();
|
||||
let targetUser = await interaction.guild?.members.fetch(interaction.user.id);
|
||||
if(userOption){
|
||||
targetUser = await interaction.guild?.members.fetch(userOption);
|
||||
}
|
||||
|
||||
const query = {
|
||||
userId: targetUser?.id,
|
||||
guildId: interaction.guild?.id
|
||||
}
|
||||
|
||||
let user = await User.findOne(query);
|
||||
|
||||
if(!user){
|
||||
await interaction.editReply(`${targetUser?.displayName} hat 0$ auf dem Konto!`);
|
||||
}
|
||||
else{
|
||||
await interaction.editReply(`${targetUser?.displayName} hat ${user.balance}$ auf dem Konto!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export = command;
|
||||
Reference in New Issue
Block a user