Basic Bot setup

This commit is contained in:
2024-04-07 12:11:59 +02:00
commit c2d634d049
21 changed files with 1298 additions and 0 deletions

View 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;