Can't register application command.

I have followed docs here to create ping command but when using slash there no my app ping command. Do I need to something else to register command https://www.sapphirejs.dev/docs/Guide/getting-started/creating-a-basic-app-command
Sapphire Framework
Creating a basic slash command | Sapphire
This section covers the absolute minimum for setting up a slash command. We have an entire "Application Commands"
57 Replies
Alex
Alex2y ago
It can take a minute or two for Discord to "see" new registered commands
Đá Cục Không Phải Cục Đá
I have wait about 15 mins but nothing show up
Đá Cục Không Phải Cục Đá
I see it only debug log but not found
Đá Cục Không Phải Cục Đá
Do I need to provide bot permission Or active something on developer portal
Alex
Alex2y ago
You shouldn't have to do anything special, really
Đá Cục Không Phải Cục Đá
😦 But I don't see my slash command on it just other bot about hindId how to pass it There no example about it
Đá Cục Không Phải Cục Đá
Is it like this ?
Alex
Alex2y ago
it is, yea
Đá Cục Không Phải Cục Đá
😦 Still don't see my slash Do I need setting something for it on server ?
Krish
Krish2y ago
For development purpose you must use guild specific slash commands
Ben
Ben2y ago
You dont have to use guild specific commands for development. I have been developing with just fine.
Đá Cục Không Phải Cục Đá
What do you mean
Đá Cục Không Phải Cục Đá
I see that when try log client.application?.commands.cache is show 0
Đá Cục Không Phải Cục Đá
But debug say it does register success Do you have idea what wrong with me
Ben
Ben2y ago
You're logging the commands cache before the commands are registered, thats why its empty. Have you reloaded your client since the commands were first created?
Đá Cục Không Phải Cục Đá
yes I try to do it Still 0
Ben
Ben2y ago
Can you push your code to github or send it some other way?
Đá Cục Không Phải Cục Đá
What code you want to know @Ben855
Ben
Ben2y ago
All of it
Đá Cục Không Phải Cục Đá
import { CatCommand } from '@customs/sapphire/CatCommand';
import { ApplyOptions } from '@sapphire/decorators';
import { send } from '@sapphire/plugin-editable-commands';
import type { Message } from 'discord.js';
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import type { ChatInputCommand, Command} from '@sapphire/framework';

@ApplyOptions<CatCommand.Options>({
name: 'general.ping.name',
example: 'general.ping.example',
aliases: ['ping'],
description: 'general.ping.description',
hidden: true
})
export class PingCommand extends CatCommand {
public async messageRun(message: Message) {
// throw new Error
const msg = await send(message, 'Ping?');

const content = `Pong! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
(msg.editedTimestamp || msg.createdTimestamp) - (message.editedTimestamp || message.createdTimestamp)
}ms.`;

return send(message, content);
}

public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('ping').setDescription('Ping bot to see if it is alive')
);
}
public async chatInputRun(interaction: Command.ChatInputInteraction) {
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 { CatCommand } from '@customs/sapphire/CatCommand';
import { ApplyOptions } from '@sapphire/decorators';
import { send } from '@sapphire/plugin-editable-commands';
import type { Message } from 'discord.js';
import { isMessageInstance } from '@sapphire/discord.js-utilities';
import type { ChatInputCommand, Command} from '@sapphire/framework';

@ApplyOptions<CatCommand.Options>({
name: 'general.ping.name',
example: 'general.ping.example',
aliases: ['ping'],
description: 'general.ping.description',
hidden: true
})
export class PingCommand extends CatCommand {
public async messageRun(message: Message) {
// throw new Error
const msg = await send(message, 'Ping?');

const content = `Pong! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
(msg.editedTimestamp || msg.createdTimestamp) - (message.editedTimestamp || message.createdTimestamp)
}ms.`;

return send(message, content);
}

public override registerApplicationCommands(registry: ChatInputCommand.Registry) {
registry.registerChatInputCommand((builder) =>
builder.setName('ping').setDescription('Ping bot to see if it is alive')
);
}
public async chatInputRun(interaction: Command.ChatInputInteraction) {
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 :(');
}
}
Krish
Krish2y ago
Waiting for the slash commands to register isnt fun ;( anyways haven't worked with slash commands for a long while maybe discord does it quickly now
Đá Cục Không Phải Cục Đá
It is private repo now @Ben855 Can you give me github UserName
Ben
Ben2y ago
Its on my profile
Ben
Ben2y ago
It seems to work perfectly for me At least the ping command does. I got some errors because I didnt I dont have access to some of the git repos youre linking in but that doesnt matter for the ping command
Đá Cục Không Phải Cục Đá
Maybe cause my test bot have 18 server?
Ben
Ben2y ago
That shouldn't affect anything
Đá Cục Không Phải Cục Đá
can I register ping command on local server instead global Cause maybe global take too long to appear?
Ben
Ben2y ago
I can give it a shot. I dont think it should take that long though. Like I said it worked for me with no modifications other than plopping in my test bots token.
Đá Cục Không Phải Cục Đá
You want to try my token ?
Ben
Ben2y ago
No I dont
Đá Cục Không Phải Cục Đá
I can renew it after you try
Ben
Ben2y ago
Doesn't matter, I dont want access to stuff that I dont controll
Đá Cục Không Phải Cục Đá
But in ur log it show 0 logged at ready.ts right ?
Ben
Ben2y ago
Yeah but thats just because your logging it before anything gets registered
Đá Cục Không Phải Cục Đá
What I need to do now cause my slash command is broken even second times it still 0
Ben
Ben2y ago
Registered in sapphire, not in discord. Stuff gets registered in sapphire when it prints out all those debug statements saying its comparing command. Your logging happens before that
Đá Cục Không Phải Cục Đá
Oh I see Sadly I don't know that happen to my bot now @Ben855 I just go other server I show my bot slash command But not the main server You have any idea
Ben
Ben2y ago
I dont understand what you mean
Đá Cục Không Phải Cục Đá
I mean other server work but not 1 server Server that not work don't have bot integrate How to integrate bot to server ?
Ben
Ben2y ago
Wait is your bot even in the server where you want the slash command to work?
Đá Cục Không Phải Cục Đá
Yes I have admin permission too
Ben
Ben2y ago
If the bot doesnt show up in the integrations tab then its not in the server
Đá Cục Không Phải Cục Đá
I can sure it in server and have a role
Ben
Ben2y ago
idk then. If its in the server but not in the integrations tab then it seems like its a discord issue since I'm pretty sure thats not supposed to ever happen.
Đá Cục Không Phải Cục Đá
yeah Maybe discord have a bug let me try to work on another server
Ben
Ben2y ago
I'm not sure. You could maybe try having it leave and re-join but if that doesnt work then I'm out of ideas.
Đá Cục Không Phải Cục Đá
Try to kick and invites not working Anyway tks for help Just wait for people who know what happen to me
clownn
clownn2y ago
same problem happening for me but in my case i'm using a cli-generated component Discord is not "seeing" the slash command
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
description: 'A basic slash command'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
);
}

public override async chatInputRun(interaction: Command.ChatInputInteraction) {
return await interaction.reply({ content: 'Hello world!' });
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';

@ApplyOptions<Command.Options>({
description: 'A basic slash command'
})
export class UserCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName(this.name)
.setDescription(this.description)
);
}

public override async chatInputRun(interaction: Command.ChatInputInteraction) {
return await interaction.reply({ content: 'Hello world!' });
}
}
@Đá Cục Không Phải Cục Đá you found any solution? (sorry for disturbing)
Đá Cục Không Phải Cục Đá
not yet That is discord bug Slash is register at other server not server I test
Krish
Krish2y ago
Permissions..?
Sean
Sean2y ago
with slashies V2 they removed the cache time. it should now be instant
Krish
Krish2y ago
woah
Favna
Favna2y ago
@Đá Cục Không Phải Cục Đá just a wild idea but if the bot does by now show in the integrations tab, shows in the user list, shows it is online, and you can assign roles but typing / doesn't show anything then could it maybe be that you have an ancient discord client version that simply doesn't support slash commands (or more likely, using an alternative or modded client) or if this is specific to the one server, and again it doesn't show up in the one specific server then I'm not sure. I also don't know what CatCommand does in terms of code.
Want results from more Discord servers?
Add your server