import { ApplyOptions } from '@sapphire/decorators';
import { ChatInputCommand, Command } from '@sapphire/framework';
import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
import { createEmbed } from '../../lib/utils';
@ApplyOptions<Command.Options>({
description: 'Show user balance'
})
export class UserBalance extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) => {
builder
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) => option.setName('user').setDescription('The user to check').setRequired(false));
});
}
public override async chatInputRun(interaction: ChatInputCommandInteraction, _context: ChatInputCommand.RunContext) {
return this.sendInfo(interaction);
}
private async sendInfo(interaction: Command.ChatInputCommandInteraction) {
const user = interaction.options.getUser('user') ?? interaction.user;
const embed: EmbedBuilder = createEmbed('Balance', `balance of ${user.username}`);
await interaction.reply({ embeds: [embed] });
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { ChatInputCommand, Command } from '@sapphire/framework';
import { ChatInputCommandInteraction, EmbedBuilder } from 'discord.js';
import { createEmbed } from '../../lib/utils';
@ApplyOptions<Command.Options>({
description: 'Show user balance'
})
export class UserBalance extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) => {
builder
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) => option.setName('user').setDescription('The user to check').setRequired(false));
});
}
public override async chatInputRun(interaction: ChatInputCommandInteraction, _context: ChatInputCommand.RunContext) {
return this.sendInfo(interaction);
}
private async sendInfo(interaction: Command.ChatInputCommandInteraction) {
const user = interaction.options.getUser('user') ?? interaction.user;
const embed: EmbedBuilder = createEmbed('Balance', `balance of ${user.username}`);
await interaction.reply({ embeds: [embed] });
}
}