Sapphire not getting my commands

Every time i make a command it seems that sapphire doesnt care about them, i put my commands in the commands directory, I am using tsx for my runner (tsx uses esbuild)
No description
Solution:
Every time i make a command it seems that sapphire doesnt care about them, i put my commands in the commands directory, I am using tsx for my runner (tsx uses esbuild)
No description
Jump to solution
20 Replies
yusof
yusof2y ago
Here is some of my code
import config from './config';
import path from 'path';
import { ApplicationCommandRegistries, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions],
baseUserDirectory: path.join(__dirname, 'src')
})

client.login(config.token);

console.log(`[INFO] Started bot`);

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);
import config from './config';
import path from 'path';
import { ApplicationCommandRegistries, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions],
baseUserDirectory: path.join(__dirname, 'src')
})

client.login(config.token);

console.log(`[INFO] Started bot`);

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);
My help.ts while in the making
import { Command, ChatInputCommand } from '@sapphire/framework';
import { isMessageInstance } from '@sapphire/discord.js-utilities';

export class HelpCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, {
...options,

});
}

public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('help').setDescription('Get help for the egg bot')
);
}

public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const msg = await interaction.reply({ content: `Ping?`, ephemeral: true, fetchReply: true });

if (isMessageInstance(msg)) {
const diff = msg.createdTimestamp - interaction.createdTimestamp;
const ping = Math.round(this.container.client.ws.ping);
return interaction.editReply(`Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`);
}

return interaction.editReply('Failed to retrieve ping :(');
}
}
import { Command, ChatInputCommand } from '@sapphire/framework';
import { isMessageInstance } from '@sapphire/discord.js-utilities';

export class HelpCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, {
...options,

});
}

public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('help').setDescription('Get help for the egg bot')
);
}

public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
const msg = await interaction.reply({ content: `Ping?`, ephemeral: true, fetchReply: true });

if (isMessageInstance(msg)) {
const diff = msg.createdTimestamp - interaction.createdTimestamp;
const ping = Math.round(this.container.client.ws.ping);
return interaction.editReply(`Pong 🏓! (Round trip took: ${diff}ms. Heartbeat: ${ping}ms.)`);
}

return interaction.editReply('Failed to retrieve ping :(');
}
}
when I change help.ts tsx doesnt care since its not being used or imported anywhere which tells me sapphire is not picking up my commmands
Favna
Favna2y ago
read the big red block at the top of the guide: https://www.sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire More than we also dont support tsx. You can instead just use tsup package to compile and it has a --onSuccess flag through which you can set pnpm run start to call node dist/index.js
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and
yusof
yusof2y ago
yeah i just switched to tsup after I posted this when I looked at the dragonite bot it has started to work thanks
yusof
yusof2y ago
hey sorry, accidently marked solution right before I wanted to ask something else, although nvm as it still doesnt register my commands, I suppose is it because I need guildid's and how do I make guild id commands
Favna
Favna2y ago
you dont need guildId, without they are registered globally
yusof
yusof2y ago
how long does it take to register since it hasnt registered
Favna
Favna2y ago
instant
yusof
yusof2y ago
weird it hasnt registered anything
Favna
Favna2y ago
check all your code, add logging, etc there are many examples available through running bots
Spinel
Spinel2y ago
Discord bots that use @sapphire/framework v4 - Official Bot Examples ᴱ ᴰ ᴶˢ - Archangel ᴱ ᴰ - Dragonite ᴱ ᴰ - Radon ᴱ ᴬ Discord bots that use @sapphire/framework v3 - Arima ᴱ - Nino ᴱ ᴰ - Operator ᴱ ᴬ ᴰ - Sapphire Application Commands Examples ᴱ - Spectera ᴬ Discord bots that use @sapphire/framework v2 - Materia ᴱ - RTByte ᴱ ᴬ - Skyra ᴬ ᴰ - YliasDiscordBot ᴬ : Uses ESM (if not specified then uses CJS) : Advanced bot (if not specified it is a simple bot, or not graded) : Uses Docker in production ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
Favna
Favna2y ago
and also check the guide, as it explains a lot
yusof
yusof2y ago
aye its radon my friends bot ok still been trying everything and nothings working
Favna
Favna2y ago
cant help without you providing info buddy
Spinel
Spinel2y ago
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stacktraces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
❯ For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines. ❯ For an excellent video that shows how not to ask technical questions is this, watch this YouTube video by LiveOverflow. ❯ Asking technical questions (Clarkson)How to ask questions the smart way (Raymond)
yusof
yusof2y ago
can I give you the source code im uploading it to github rn
yusof
yusof2y ago
GitHub
GitHub - yuzofff/eggbot
Contribute to yuzofff/eggbot development by creating an account on GitHub.
Favna
Favna2y ago
I said read the big red block, you didnt do that
yusof
yusof2y ago
OHHH im so stupid IT WORKED Omg thank
Krish
Krish2y ago
The question itself is marked as solution Mark this message as the solution @yusof
yusof
yusof2y ago
already did
Want results from more Discord servers?
Add your server