What am I supposed to trust, the basic slash command registering? Or the Wiki's Commands section?

Stuff under Creating a basic slash command seems to be heavily outdated, it says the type is Command.Registry in some parts, but vscode is never actually auto completing to that. Instead it auto completes to ApplicationCommandRegistery type, and Awaitable stuff as the return of registerApplicationCommands, it started to be totally different approach here, then I saw fetchReply is also outdated, and the new one, which is withResponse is no where similar to be usable in isMessageInstance, is it basically an outdated guide from start to end? So I should only continue with next pages? Commands examples under Commands section also uses ApplicationCommandRegistry rather than stuff under Command namespace
37 Replies
Favna
Favna2mo ago
erm... oops? haha. You can use @sapphire/cli to generate a template
afterglow
afterglowOP2mo ago
Yeah this seems better, but again, even template differs from examples or how to's in documentation, the very first difference I noticed was use of @ApplyOptions decorators that is no where mentioned under Commands section.
Favna
Favna4w ago
that's intentional because we automatically convert TS samples to ESM and CJS and that would mess with decorators but whatever goes in ApplyOptions maps 1:1 with command options you can also check out some of the public repos:
Spinel
Spinel4w ago
Discord Bots using @sapphire/framework v5.x - Gemboard ᴱ ᴰ - Skyra ᴱ ᴬ ᴰ - Dragonite ᴱ ᴰ - Archangel ᴱ ᴰ - Official Bot Examples ᴱ ᴰ ᴶˢ - KBot ᴱ ᴬ ᴰ - Perpetual Mechanical Array ᴰ - Birthdayy ᴰ - Sapphire Application Commands Examples ᴱ Legend for the identifiers : 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.
Phil
Phil2d ago
none of these go into detail how to deal with the deprecation notice and #isMessageInstance
Favna
Favna2d ago
that seems to be a completely separate question. Please create your own thread.
Phil
Phil2d ago
and the new one, which is withResponse is no where similar to be usable in isMessageInstance
Favna
Favna2d ago
oh well point still stands that I replied to afterglow though
Phil
Phil2d ago
ok.. but im trying to say is that the example bots are not helpful, cause they also have not been updated
Favna
Favna2d ago
gemboard, skyra, dragonite, archangel, and sapphire application commands examples all have been the others youll have to bugger their creators, not us
Phil
Phil2d ago
ok actually.. dont make sure of this
Favna
Favna2d ago
huh?
Phil
Phil2d ago
- const msg = await interaction.reply({ content: `Ping?`, fetchReply: true, flags: 'Ephemeral' });
+ const msg = await interaction.reply({ content: `Ping?`, withResponse: true, flags: 'Ephemeral' });
- const msg = await interaction.reply({ content: `Ping?`, fetchReply: true, flags: 'Ephemeral' });
+ const msg = await interaction.reply({ content: `Ping?`, withResponse: true, flags: 'Ephemeral' });
and then you run into the issue that the reply is no longer a Message type but a InteractionCallbackResponse type utility func would that be, instead of using #isMessageInstance
Favna
Favna2d ago
Look at it this way, this is a good learning experience of reading documentation and trial and error. You learn nothing from getting everything spoonfed on a silver platter.
const callbackResponse = await interaction.reply({ content: `Ping?`, withResponse: true, flags: 'Ephemeral' });
const msg = callbackResponse.resource?.message;
const callbackResponse = await interaction.reply({ content: `Ping?`, withResponse: true, flags: 'Ephemeral' });
const msg = callbackResponse.resource?.message;
Favna
Favna2d ago
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Phil
Phil2d ago
well thanks for the learning experience. but the code is from the guide..
Favna
Favna2d ago
took me a whole 2 seconds to find that property because typescript autocompleted it for me though and ive never used this bit of code before i didnt even know that was put in between by djs just did a very quick variable. to see what intellisense pops up as options for what is available as properties anyway
Favna
Favna2d ago
be the change you want to see, make a PR to https://github.com/sapphiredev/website to update the guides
GitHub
GitHub - sapphiredev/website: Documentation for Sapphire Project
Documentation for Sapphire Project. Contribute to sapphiredev/website development by creating an account on GitHub.
Phil
Phil2d ago
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"
Favna
Favna2d ago
You have to understand that it's not like we get paid to keep everything up to date (as much as we wish we would) and it's extremely tiresome work that none of us (that is to say, the maintainers) really want to constantly do, let alone have time to do. We all have full time jobs and/or studies in IT as developers and generally after a full day of working we just want to relax and do our own things instead of even more coding. We don't have the advantage of youth anymore.
Phil
Phil2d ago
i get that.. but documentation should be up to date, and if it is not, a notice will do. or even just for which version it is. cause that is not very aparent
Favna
Favna2d ago
which is why we recommend people to make pull requests quite frankly, do you have any idea what it would take to document which discordjs version something is written for on every single page and constantly keep that up to date and accurate? I don't think you realise the scope of what you're asking.
Phil
Phil2d ago
understandable.. will be making one when i think I figured it out... tbh.. i never worked typescript in bigger ecosystems before so its new to me its not like you need to touch older version-guides but thats just how it has to be done...
Favna
Favna2d ago
We only have 1 version of the guide though. As you can see on the website, there is no version picker. Does Docusaurus support versioning guides? yes. Does that also require a lot of configuration and careful file management? also yes
Phil
Phil2d ago
ok I get that it might be an overhead but i can tell you, as a first time user this is very frustrating... If i would have at least known that the guide is not for my version, I woulnd have lost so much time
Favna
Favna2d ago
I would love it if I had the motivation to do this and so many other things but I just dont. I'm just 1 person and it's a massive project.
Phil
Phil2d ago
yea... i know that from somewhere
Favna
Favna2d ago
to give another example, if you go through the help channel you will notice that a good 95% of the questions are answered by me and me alone. I've been clammoring for years for the other developers to take this channel more serious and also answer questions but nothing has ever come from it.
Phil
Phil2d ago
a project is finished, when you end it.. thats how I see it. never found anyone to help out with mine, help with support or take it over
Favna
Favna2d ago
sadly sapphire is never finished because discord api always changes and therefore discordjs always changes and yeah if there would be other people supporting it wouldnt be so bad but there arent occassionally we've had a person do a few contributions but people never stick around
Phil
Phil2d ago
would love to help, but I'm not a good js/ts dev and maintain way too much myself already as well
Favna
Favna2d ago
im confident if there would be a team of at least 2-3 others who are active on the development then we'd all motivate each other and sapphire would move forward much more efficiently. I need only look at the project I work on for work as evidence for that. I mean that's how sapphire got where it is now, with Kyra, Vladdy and I doing a lot and quickly.
Phil
Phil2d ago
im gald you found someone ^^' im still a one man show, really.. while its ntoht e most complex projects.. I do have a few of them im using const msg = await interaction.fetchReply(); now.. seems more common also with your bots
await interaction.reply({ content: `Ping?`, flags: 'Ephemeral' });
const msg = await interaction.fetchReply();

if (!isMessageInstance(msg)) return interaction.editReply('Failed to retrieve ping :(');

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.)`);
await interaction.reply({ content: `Ping?`, flags: 'Ephemeral' });
const msg = await interaction.fetchReply();

if (!isMessageInstance(msg)) return interaction.editReply('Failed to retrieve ping :(');

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.)`);
Favna
Favna2d ago
ah btw just my 2 cents but I wouldnt add a /ping in your final bot once you're all done 😉 Just add a /info similar to the ones that bots here have. You can add more info in it and it's actually useful for users. Ping was nice with message based commands because you can kinda hide it but really it's primarily a developer facing command and not really useful to end users. Because users already have loads and slash commands on their server / user, adding a fairly useless one to that is just bloat.
Phil
Phil2d ago
im just messing around with commands at the moment, trying to understand stuff atm...
Favna
Favna2d ago
mhm yeah that's why I said when you're all done
Phil
Phil2d ago
i actually dont recall ever making a ping command on a production bot 😄 nvm... it do be there... yea i dont need it.. cause its not really a good latency test anyways. and my status page handels latency records

Did you find this page helpful?