42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
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; |