Im new to TS and Discord.JS, but I have knowloadge on programming, but this framework is new to me, I need to make different commands, I have create 3 folders, user, admin, games, every dir has it owns games and class (not made all but im there), and this is a simple class Im not sure if this what Im doing is correct, but for organizing it should be.
this is the code I have made if there is a better way of doing this lmk:
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] }); }}
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
S-IaF
Sapphire - Imagine a Framework
Sapphire is a next-gen object-oriented Discord.js bot framework.