Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
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
RapLayer
RapLayer12/24/2022
It can take a minute or two for Discord to "see" new registered commands
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
I have wait about 15 mins but nothing show up
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
I see it only debug log but not found
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Do I need to provide bot permission
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Or active something on developer portal
RapLayer
RapLayer12/24/2022
You shouldn't have to do anything special, really
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
😦 But I don't see my slash command on it just other bot
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
about hindId how to pass it
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
There no example about it
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Is it like this ?
RapLayer
RapLayer12/24/2022
it is, yea
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
😦 Still don't see my slash
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Do I need setting something for it on server ?
Krish
Krish12/24/2022
For development purpose you must use guild specific slash commands
Ben855
Ben85512/24/2022
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 Đá
Đá Cục Không Phải Cục Đá12/24/2022
What do you mean
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
I see that when try log client.application?.commands.cache is show 0
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
But debug say it does register success
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Do you have idea what wrong with me
Ben855
Ben85512/24/2022
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 Đá
Đá Cục Không Phải Cục Đá12/24/2022
yes
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
I try to do it
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Still 0
Ben855
Ben85512/24/2022
Can you push your code to github or send it some other way?
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
What code you want to know @465668689920917534
Ben855
Ben85512/24/2022
All of it
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
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
Krish12/24/2022
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 Đá
Đá Cục Không Phải Cục Đá12/24/2022
It is private repo now @465668689920917534
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Can you give me github UserName
Ben855
Ben85512/24/2022
Its on my profile
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Here u are
Ben855
Ben85512/24/2022
It seems to work perfectly for me
Ben855
Ben85512/24/2022
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 Đá
Đá Cục Không Phải Cục Đá12/24/2022
Maybe cause my test bot have 18 server?
Ben855
Ben85512/24/2022
That shouldn't affect anything
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
can I register ping command on local server instead global
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
Cause maybe global take too long to appear?
Ben855
Ben85512/24/2022
I can give it a shot. I dont think it should take that long though.
Ben855
Ben85512/24/2022
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 Đá
Đá Cục Không Phải Cục Đá12/24/2022
You want to try my token ?
Ben855
Ben85512/24/2022
No I dont
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
I can renew it after you try
Ben855
Ben85512/24/2022
Doesn't matter, I dont want access to stuff that I dont controll
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
But in ur log it show 0 logged at ready.ts right ?
Ben855
Ben85512/24/2022
Yeah but thats just because your logging it before anything gets registered
Đá Cục Không Phải Cục Đá
Đá Cục Không Phải Cục Đá12/24/2022
What I need to do now cause my slash command is broken
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy