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

Bot wont respond to any command + wont register slashes though it says they are registered

My bot becomes online, responds to mentionPrefixOnly listener but it doesnt respond to any command Dependencies list: ```json { "@kaname-png/plugin-subcommands-advanced": "^2.4.0",...
Solution:
You can use . instead, I think 🤔
No description

how to change the client on the container's type to my custom client

no more details, that's all I want to know really

ApplyOptions

does ApplyOptions from @sapphire/decorators work with JavaScript, if yes, how would that work
Solution:
It doesn't

Lib classes types

Where there is no suggestions for the types in the class to override like Command?

Enable slash command for bot owners only

Is that possible for register a slash command to be visible only for a specific user like the bot owner?
Solution:
it is not, Discord API doesn't allow that. At best you can set preconditions and set required role to Administrator

Global precondition

I'm not able to answer a custom message with global precondition (global.ts) in preconditions folder ```ts //@ts-ignore import { AllFlowsPrecondition, Piece, Result } from "@sapphire/framework";...
Solution:
it is chatInputCommandDenied and contextMenuCommandDenied not commandDenied since v3 of the framework: https://www.sapphirejs.dev/docs/Guide/getting-started/updating-from-v2-to-v3#sapphire-events-added

The inferred type of 'parse' cannot be named without a reference to...

Hey! I am getting this error while trying to create an interaction handler: The inferred type of 'parse' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@sapphire/result'. This is likely not portable. A type annotation is necessary. This is my code:...
Solution:
yeah so basically pnpm doesn't patch typescript to ensure that it considers the folder where it dumps the non hoisted files for the typescript server/compiler. It's a major flaw in pnpm. If you look for example at Yarn which also has a PnP mode (opt in), they do patch TypeScript for this very reason. It's extremely dumb to think that you're non compliant solution will just work OOTB with the whole ecosystem and I honestly blame pnpm devs for this very much. Wouldn't be surprised if they have various open issues on the topic, have never checked. Basically any installed package that then module augments another installed package (transitive or not), will not work with pnpm. In our case, @sapphire/framework has a transitive dependency on @sapphire/pieces and also module augments @sapphire/pieces, and discord.js for that matter....

Bot hosting Service

Hey guys, was wondering if there is a free option for the discord bot to keep running and active. I tried repl.it with Uptimerobot and the keep_alive Code but the bot keeps turning off/on whenever he wants to. Would appreciate all help coming ;)
Solution:
Affordable hosting providers: • Netcup Starting at €2.62/mo for 1 core, 2GB RAM, 20GB SSD (You can get a totally free 10% discount code from @kyra 🩵🩷🤍🩷🩵 or @Favna!) • OVH Starting at $3.35/mo for 1 core, 2GB RAM, 20GB SSD • DigitalOcean Starting at $5/mo for 1 core, 1GB RAM, 25GB SSD • Linode Starting at $5/mo for 1 core, 1GB RAM, 25GB SSD...

Compiling with SWC

I've been trying to compile my code with SWC and it is finding errors in a couple of my files that were created using the CLI. Those files are src/commands/General/Ping.ts and src/listeners/ready.ts These are the errors that are presented: ```
rimraf dist && swc ./src -d dist
...

Constructor

If my file has no options is it safe to remove the constructor?
Solution:
Yes

fetchPrefix not functioning as it should

So i have a default prefix what i am doing is if the author id is x then return a array of prefixes they can use if not just return the default prefix but it's not working as i am only able to use commands with "" meaning no prefix
No description

Does plugin-api support parameters? If so, how can I get tem?

So basically I want to try and have some routes have optional url parameters, I know how this works with express as you can use and get them like this: ```ts const router = express.Router(); router.get('/:id', (request: Request, response: Response) => {...
Solution:
Nevermind, it was as exactly as I thought it might have been!

Bot does not update commands

so i deleted my ping.ts with was generated from the cli and i restarted the bot and it is still having the commands and i waited more then a day
Solution:
is it somehow still in your dist folder? the logging makes it seem like the piece is being loaded.

Upgrading from djs v12 (commando) to djs v14 (and sapphire framework) - Unsure on how to Parse Types

Hello! I have recently started upgrading an outdated open source project, and got stuck for a couple days on a specific aspect (almost done with everything else though). Context: In the configuration command, it takes two arguments, first being the key (or what setting to change), and second being the new value. ...
Solution:
My solution: ```ts const valueType = (serializer.type as any) try { args.restore()...

customJobOptions or bullJobsOptions

Hello I have several tasks repeated and would like to delete them from Redis once they are finished. I found Bull's doc that asks to add removeOnComplete in the job options: https://docs.bullmq.io/guide/queues/auto-removal-of-jobs ...
Solution:
released 8.0.0 @Zaros

plugin-subcommands: subcommands with preconditions

HI, so im creating subcommands with preconditions, but its not working on subcommands, its only working on normal commands (chatInputCommands) - When i run normal chatInputCommands, its working (first pic) - But when i run subComands with preconditions (second pic) - My subcommands code are like this (third pic)...
Solution:
the event name still has to be changed to Subcommand but that'd be a breaking change so it's pending whenever there is more kekw
No description

Using multiple types in args.repeat()

Is it possible to use multiple types in args.repeat()? For example like this: const membersAndRoles = args.repeat('member | role'); // parsing members and roles And then it would parse !command @member1 @member2 @role1 and put all three into membersAndRoles. What would be the best way?...
Solution:
it is not. You'll have to leverage commands like args.finished to check if there are args left to parse and then pick them.

plugin-api: How to access Cookies on incoming requests?

Hi, I can't quite figure out how to access cookies on incoming requests. Thanks for your help :D

How to use `container.logger` ?

I see that there are 4 kinds of loggers: 1. this.container.logger 2. import {container} from '@sapphire/framework'; container.logger 3. import {container} from '@sapphire/pieces'; container.logger 4. import {Logger} from '@sapphire/framework'; const logger = new Logger();...

cli change cli dir

when i use the cli and build a project and want to change the dir of .env
Solution:
Move the file then edit setup.ts