Sapphire - Imagine a framework

SIA

Sapphire - Imagine a framework

Welcome to the Sapphire Discord server! The next-gen object-oriented Discord.js bot framework can be found here.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

No subcommand was matched with the provided command.

Unable to run any of my settings group commands. Am I setting them up wrong or something? https://pastebin.com/UbS5qrYu...
Solution:
close
No description

Coommands are not registered

I just put my bot in my server, and it does not identify commands anymore. picture of file structure is attached here, please help if you can...
No description

Using slash options as text args

Is there a way to use slash options as text args
Solution:
The answer is still no, slash commands are completely separate from message based commands in Sapphire. You also don't really "define" args for message commands, please see these guide pages: - https://sapphirejs.dev/docs/Guide/arguments/using-arguments - https://sapphirejs.dev/docs/Guide/arguments/using-options - https://sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/registering-chat-input-commands#registering-chat-input-commands-with-options...

Is it possible to style the page returned through routes?

Quick question, was curious if it's possible to have a page that I can style through css? If possible, or can I load an html page?
Solution:
you can send HTML code yes, if you set the proper mime type. But your frontend library/framework will not render it unless you use a variant of dangerously set inner html to avoid potential script injection.

Timezone option for Scheduled Tasks

What timezone format do I need to use for task when creating it? For example I want to run task in ukranian timezone, (UTC+2) what am I supposed to put in? A bit confused because all the time here like different types and kinds of timezones that you need to provide......
Solution:
First of all, it should be noted that timezone only applies if you provide a cron pattern for the pattern option Furthermore, the plugin is mostly just a tiny wrapper around https://bullmq.io. Bullmq passes that timezone, along with the pattern, to https://github.com/harrisiirak/cron-parser which actually handles it. I find it a bit weird that you're asking about UTC+2 because according to https://www.timeanddate.com/worldclock/ukraine the proper timezone is UTC+3 (regardless in fact of whether this is the occupied area or not, but fuck russia, freedom for πŸ‡ΊπŸ‡¦ and all that) ...

IntelliSense autocomplete not showing up exclusively for Sapphire classes?

When trying to extend Command class, as well as other classes like Listener, IntelliSense autocomplete seems not to work in the class definition? Originally, when pressing CTRL + SPACE should show the extended class methods & properties, but it doesn't seems to do so.
Solution:
FIX MERGED πŸŽ‰
No description

Issues with sending messages.

Lately I've been coming across an very odd issue, the application fails to followUp or editReply reaction messages as well as send anything to a logging webhook I have setup. For example I'm current using the ping slash command example that is on the GitHub. It only sends the Ping? and is unable to edit the message after that. Not really sure how to explain this but if anyone would be willing to help me track down this issue it would be greatfull....
Solution:
Nonsense, then it would be more wide spread across many users because everyone is using the same interactionCreate listener. Furthermore the fact that Jonny also has issues sending webhook messages, that's completely devoid of listeners. It's not the first time djs support people point straight back to sapphire Without proper consideration. (cc @vladdy can we, through the staff, do something about this?)...
No description

Folders not initialized when building with Typescript

Hello, I don't know if I missed out something in my tsconfig or node config but I tried making Listeners/Commands with Sapphire but after building with npx tsc and running it with node or bun the only thing that is recognized and initialized is the main index.js file (even tough tsc transpiled every files in the project dir correctly). The bot is logging in correctly and is working normally if I write it in common esm, transpiled esm or ts but when using ts with bun build or tsc with node it doesn't initialize my sub folders classes (the listeners and commands). ...
Solution:
So, I tried and I can say that for now the bun builder (that is in beta) cannot recreate the correct structure of the project because it doesn't see the relationship between the two files (index.ts ready.ts) from its entrypoint (index.ts) as stated in the documentation and thats why I can't see my listeners or commands being initialized. Three options: - the first one is to use tsc to build the structure - and the second one is to not transpile my code and run the ts files directly. - the last one is to build each files separately using the --splitting option....
No description

Slash Command not showing

Hey! so, a previous dev decided to be a dick & let a community hanging. I've never used Sapphire before but making my way along, I just created a new slash command & I'm yet to see them. Why is this? I know for discord.js I would have to provide them all at once, what do I do for sapphire?
No description

Attachment drop box

Is there a way to create a drop box for attachments like that one in slash commands? I want to give users ability to change role icon, so they can click button then this "drop box" will appear and user can drop their local image and then we process it via code...

Is there any ways to allow another bot to run my bot command

I have 2 bots, so i want bot 1 can use bot 2's command in discord channel, is there any ways to do that ?
Solution:
No, bots should never use commands from other bots. That is asking for problems.

Is there a way to make slash commands hidden for people with lower perms?

I know this is possible for a guild only server, how do I do it with Sapphire?
Solution:
if ur using the SlashCommandBuilder, then use the setDefaultMemberPermissions method, otherwise the defaultMemberPermissions property

help with options

how to use options for inputs such as a sentence? i have 2 or 3 different options that requires a sentence as input but with option, it just takes the first arg but not the whole sentence
Solution:
Assuming this is for message commands, wrap the args in quotes. For example !command "this is the first arg" "this is the second arg" That said, the UX of this is far far far far far better when using slash commands...

Error [EMPTY_MODULE]: A compatible class export was not found.

I'm trying to add code to the ready event that runs every "x" minutes. The code is a bit long and that's why I created a second file for the ready event. (Also, I want to have that separately.) I have everything that has to do with the function I want to implement in a folder called: "Extra: and inside you will have the index.js file (which will have the listener ready )and will have another file that will have "channels.js" where you will publish the function and a "functions.js" that will be in charge of making some canvas images. ...
Solution:
Prefix the file names with a _ Every file is expected to be a class export, unless it's skipped with a leading _ Alternatively move the folder out of the listeners folder...

How to reset the command cooldown in JS

I've been searching around in the server and the only solution I found was written in TypeScript, any way to do this in JS?
Solution:
this.container.stores.get('preconditions').get('Cooldown').buckets.delete(this);
this.container.stores.get('preconditions').get('Cooldown').buckets.delete(this);
now the top link code is JS, see how easy it is to remove types....

Logic question

I have a bot that is in about 20k servers and serves somewhere around 21m users. It uses presence intent to give roles to users when they add a specific custom status. My idea was to split the bot up like so due to the fact that i'm getting slammed and won't to even distribute the load of the bot. This was my idea, but I realized would this even work as how would I add the roles to the users from the worker considering I cant use the same shard.
Solution:
If you mean rest as in http server then yes @sapphire/plugin-api but that doesn't take away the above. At the end of the day sapphire and discordjs are going to spawn 1 parent process with 1 token and route everything through that process. For true scalability however you'd want multiple processes.
No description

presenceUpdate require member cache?

I know some libs do this and honestly can't find in src where it's fired off, so was just wondering if this is this is the case here as well.
Solution:
Sapphire is a framework on top of DiscordJS. Sapphire only handles registering and firing commands, listeners, etc based on events and data provided by DiscordJS. That is all to say, this is a DiscordJS matter. And afaik for DiscordJS it does require cache yes...

listener not loading.

I have no idea what the issue is, but the listener just never loads. ```ts import { Listener } from '@sapphire/framework'; ...
Solution:
i've got it, i used virtual pieces rather than the default file system. i assume it has something to do with the nx setup, etc.
No description

Precondition not throwing errors.

I've setup this precondition to make sure the user is in a voice channel, when the user is in a voice channel it runs perfectly fine. But if one of the conditions is not met the error is not thrown and the command does not respond. ```ts import { Precondition } from "@sapphire/framework"; import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";...

Equivalent of z.function from zod in shapeshift?

The title describes the issue
Solution:
there is no function validation yet in sapphire. I tried to add it a month or so ago and I was following instructions from @vladdy and @kyra but I had no idea what they were describing or how to implement it. I think either of them could add it in an afternoon given not procrastinating on it but alas. The equivalent of safeParse is .run(data: unknown): Result: https://github.com/sapphiredev/shapeshift/#rundata-unknown-resultt-error-given-a-validation-you-can-call-this-method-to-check-whether-or-not-the which returns a Result on which you can call .isOk() / isErr() / .unwrap()...