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

TypeError: Cannot convert undefined or null to object

I get this error after trying to run my build (Typescript) - it only happened when I updated my typescript package to 5.5.4 ``` C:\Users\Lemons\Documents\GitHub\Pixie-beta(typescript)\node_modules@sapphire\shapeshift\dist\cjs\index.cjs:2765 this.enumKeys = Object.keys(enumShape).filter((key) => { ^...

Complete Temlate Error

Created a new Project via CLI (used the complete template) didnt chagned anything and cant run the project now, becuase of this error: ``` src/listeners/mentionPrefixOnly.ts:8:26 - error TS2339: Property 'send' does not exist on type 'DMChannel | ...' Property 'send' does not exist on type 'PartialGroupDMChannel'....
No description

Discordjs and TypeScript typescript error

Hello, someone else has this same failure, all the embeds in the send section are failing, the bot was working fine until a few hours ago.
No description

serialize a bigint Plugins

``` 2024-09-03 11:22:15 - FATAL - TypeError: Do not know how to serialize a BigInt 2024-09-03 11:22:15 - FATAL - at JSON.stringify (<anonymous>) 2024-09-03 11:22:15 - FATAL - at _ApiResponse.json (/home/x/SwBot/node_modules/@sapphire/plugin-api/dist/cjs/lib/structures/api/ApiResponse.cjs:101:75) 2024-09-03 11:22:15 - FATAL - at [HTTP-GET] (/home/x/SwBot/dist/routes/answers.js:20:25)...

Overriding message command listeners

Is it possible to virtually load a piece (listener) to override the default CorePreMessageParser? I'd prefer not to do this by adding it to my listeners folder but rather in my command manager

Fetch not calling JSON.stringify for body objects.

Hey, i'm currently using @sapphire/fetch and trying to send a POST request for a API with a object on the body. The thing is: the object is not being stringified and the API is receiving [object Object]. I went through the @sapphire/fetch source code and, apparently, the function that determines if a body should be stringified or not (shouldJsonStringify) is returning false for my object. (https://github.com/sapphiredev/utilities/blob/main/packages/fetch/src/lib/fetch.ts#L191-L208) And just to make it clear, the object that i'm trying to send is in fact...a object, because using typeof theObject returns object lol, but its doesn't have a toJSON function or a Object constructor, in fact it has a [Function: Object] constructor, which is not included in the shouldJsonStringify function....

preconditions implementation

So i have some preconditions that check the database if the user is a staff or something. but each of them fetch the database, and it's useless to do 3 requests for the same data can i somehow specify some data to the precondition or is there a way like i fetch the data on the interaction run the run the preconditions?...

File Names

So I was told to ask this here; I am working on a slash command that is supposed to have the same name in multiple guilds but perform different functions, can I use the same name for the file names if they are in different folders for different guilds or? Hopefully that's understandable what i'm trying to ask. I have made a similar question before but this one is about whether the names can be the same of the files.
Solution:
yes, but you'll have to set the name property in the options in the constructor / ApplyOptions. Furthermore, you will either have to use bulk overwrite or be very sure that you're tracking idHints otherwise you'll get name clashes when Sapphire attempts to do a comparison analysis to check for new data

Coodown

Can i reset the cooldown for a specific command for a specific user?
Solution:
not with the built in cooldown. You will have to make your own precondition.

How do I make my bot "greet" a new member?

So I have this projeect structure. ``` src/ commands/ ping.js - WORKING command...

build version not working

i've used typescript to make the bot and after building it using tsc, it said 0 commands found, like no commands available to use. so i just need the dist folder for production, right? do i need .sapphirerc.json too? or anything else am i missing?
Solution:
nvm sorry for opening this post. the answer for my question is already in another post my bad i should've read other posts before opening one.

Why is ActivityType.Custom excluded from the presence ActivityOptions[]?

See code here in index.d.ts: ```ts export interface ActivityOptions { name?: string; url?: string;...
Solution:
Update: the exclusion has been removed and typescript is no longer mad at me. ```ts export interface ActivityOptions { name: string; state?: string;...

node_modules eror

node_modules@napi-rs\canvas
No description

Using sapphire paginator is it possible to customize the pages names ?

Solution:
```typescript import { PaginatedMessage } from "@sapphire/discord.js-utilities"; import { Command } from "@sapphire/framework"; import { inlineCodeBlock } from "@sapphire/utilities";...
No description

APIInteractionGuildMember missing properties

It seems like member has to have to properties like nickname, but they're not accessible. I haven't beed using discord.js in a while as well as @sapphire/framework, were there changes that could cause that? If not, please, do enlighten me on the matter, thanks.
Solution:
First of all, I set your nickname. Please do not set an unmentionable nickname/display name As for your question, interaction.member is DJS code, see https://discord.js.org/docs/packages/discord.js/14.15.3/CommandInteraction:Class#member If you hover over member you will see that intellisense tells you it's a union of GuildMember|APIInteractionGuildMember and you need to specify that the guild is cached, or cast the type. This has been a thing since....... idk djs v14? I cant quite recall but a long long time anyway...
No description

Will the custom path in a store apply also when using cogs (or modules)?

If I have the following code that changes the stores path:
this.stores.get('arguments').registerPath(join(this.rootData.root, 'options'));
this.stores.get('interaction-handlers').registerPath(join(this.rootData.root, 'interactions'));
this.stores.get('arguments').registerPath(join(this.rootData.root, 'options'));
this.stores.get('interaction-handlers').registerPath(join(this.rootData.root, 'interactions'));
...
Solution:
missing some path elements there arent ya

drizzle orm

i can't use postgres with drizzle orm with sapphire/cli

events not firing

i copied the listener tutorial from the docs and the event wont fire ``` "dependencies": { "@sapphire/framework": "^5.2.1",...

cli question

are we required to use commonjs module from CLI example ? (its like that in package.json) and what whill happen if i change it to module
Solution:
Required: no What will happen: the same as with converting anything CJS to ESM. You'll have to update your imports to have extensions or use import mapping and you can't use require, __dirname, __filename and some other globals anymore. See https://nodejs.org/api/esm.html...

Weird string argument behaviour

If the message has ":" in it then the bot takes the last slice of the message after ":". This may be due to how my command is made for example the URL remover code (kind of lazy) but it really shouldn't. ```ts public async messageRun(message: CardinalCommand.Message, args: CardinalCommand.Args) { await args.repeat('url', { times: 50 }).catch(() => null); // remove urls from the message...
Solution:
anyway just use string then do ```ts const urlRegex = /https?://(www.)?[-a-zA-Z0-9@:%.+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%+.~#?&//=]*)/g; afkMessage.replaceAll(urlRegex, '').replaceAll(/\s{2,}/g, ' ').trim();...
No description