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

commands arent working

someone help me, the bot isnt working, it does go online, I dont get any error. ping.ts: ```ts...
Solution:
top of the guide:
No description

registerContextMenuCommand type error

I recently updated all of my packages and I expected some errors to popup and I've managed to fix most of them except this one: Argument of type 'ApplicationCommandType.User' is not assignable to parameter of type 'ContextMenuCommandType'. This error appears on this line: ```ts registry.registerContextMenuCommand(builder => builder.setName('Rob').setType(ApplicationCommandType.User));...
Solution:
This is a known bug of the latest discord.js version To bypass it for the time being, you can either downgrade, or do a little typing trickery like ApplicationCommandType.User as ContextMenuCommandType...
No description

Preconditioning a whole category of commands

Is it possible to apply certain preconditions to a category of commands? if so.. how?

PaginatedMessage actions on a single page

Hi!, I'm currently using the super convenient PaginatedMessage class and calling the .addPageActions() method to add actions with a run() callback to each page. This has been working great, I have however noticed that the run() function is only being called when the total number of pages is more than 1. I checked out the code setting up the collector for the message, and that indeed seems to be the case. I was wondering if there was a way to ensure that custom actions are called in the specific case where the number of pages is exactly 1 while still being able to access the passed context....
Solution:
You'll have to extend the class and overwrite the appropriate method. Our believe is that there is no point to showing a paginated message with page controls when there is only 1 page and in such a case you should write your code so that the embeds / content / component are sent directly. This is to discourage the misuse of the class and potential over engineering....

Sapphire Dynamic Cooldown Per User

Hi! i was wondering if sapphire can use a dynamic cooldown, so i can set a dynamic cooldown per user. Does it possible? let me know. Thanks!

Bun hot module reloading & starting in production with Sapphire

Hey, was curious what special work would need to be done to get HMR working with Bun Was looking at https://github.com/sapphiredev/bun-example/blob/main/package.json and that example doesn't include HMR My understanding of the plugin https://www.npmjs.com/package/@sapphire/plugin-hmr is that it was watching for changes in the outputed files, and since bun just runs the code directly I assume it's incompatible, but figured I'd check...
Solution:
You can use the plugin regardless. It scans the files as they are in the store and with Bun that's TS files. That said, if it doesn't work that might be up to Chokidar, or Bun's compatibility with it. And yes you can still use NODE_ENV with Bun. But if you're so inclined you can also use BUN_ENV. It's arbitrary....

addStringOption applyLocalizedBuilder

Hey, Is it possible to use localizedBuilder on the choices for addStringOption? ```ts...

why my ping.ts doesnt wanna run after being transpiled?

So my slash command doesnt wanna execute after its been transpiled to js even though after I did run it on ts-node, it worked without any issues. ```ts import { CommandInteraction } from 'discord.js'; import { ApplyOptions } from '@sapphire/decorators'; import { Command } from '@sapphire/framework';...
Solution:
it sounds like your passing it the ts code and not the transpiled js

Using HMR in TS

So I am considering writing a bot in TS, but my question is, since sapphire supports it, how would I go over using it, like, in TS you have to transpile files to js but what after you make updates to the .ts files, will HMR detect it and reload or how does it look?
Solution:
you run tsc with the --watch flag in the terminal

Programmatically creating and deleting repeated scheduled tasks

Iā€™m trying to implement daily reminders for events managed by my bot. Iā€™m creating the repeated task using the create method on container.tasks but Iā€™m having trouble fetching the ID of the task because it does not match the job ID set in customJobOptions. I have a feeling Iā€™m doing something incorrectly, but I was curious if anyone else has had look with the scheduled tasks plugin and creating/deleting repeated tasks?...

How to reload a command or multiple slash commands and get their ids

Does anyone know how to reload multiple commands or a slash command and also get them their ids?

error while handling the command application command registry

Hello. I have encountered a (weird) bug on SlashCommandBuilder. This one works, no ExpectedValidationError > s.instance(V) error. ```ts public override registerApplicationCommands(registry: Command.Registry) {...
Solution:
You'll have to report this to discordjs because this is a shapeshift validation error raised in @discordjs/builders. If they direct you back here because it's @sapphire/shapeshift, tell them that it's code in builders and not shapeshift that causes this.
No description

TS Issue

installed freshly using sapphire new
Solution:
This will be fixed in a future version of sapphire. The issue is known.
No description

Slash-Context menu commands with spaces?

Is there any way to create a slash command without dashes like "User Info" or something like it? Haven't tested yet but I want to know, and also if the uppercase will appear as well.

Error compile

Is anyone know what causing this? i tried to re-install the package but still same when trying to build TS
No description

Same command files but in different folders

So is sapphire like going to function well if I were for example have kick.js twice but one in admin folder and one in developer folder? Both set to deploy to different guilds?
Solution:
- department/kick.js - name: 'department/kick' - developer/kick.js - name: 'developer/kick' ...

Manual Scheduled Task not found

I try to manually schedule a task
const payload = { awesome: true };
await container.tasks.create({ name: 'rememberMe', payload }, 5000);
const payload = { awesome: true };
await container.tasks.create({ name: 'rememberMe', payload }, 5000);
...
Solution:
Then the name is RememberTask. By default sapphire will use the file name as the name of the piece. Either you have to specify a different name in the constructor or rename the file. The module augmentation that you do at the bottom is typescript only, and doesn't affect runtime.

Manual Scheduled Task Method Arg Number mismatch with documentation

It's pretty simple: Documentation fo ScheduledTasks plugin says container.tasks.create has 3 arguments as stated in the github readme (https://github.com/sapphiredev/plugins/tree/main/packages/scheduled-tasks): - task ā€“ The task to be scheduled. - payload ā€“ The payload for the task....

messageCommandDenied preventing bot from booting

Hello, I'm using the basic messageCommandDenied code provided in the sapphire docs and it has been working up until today but upon booting up one of my bots I get the following error: ```src/listeners/messageCommandDenied.ts:15:27 - error TS2339: Property 'send' does not exist on type 'DMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<...> | PrivateThreadChannel | VoiceChannel'. Property 'send' does not exist on type 'PartialGroupDMChannel'. ...