Sapphire - Imagine a Framework

SIA

Sapphire - Imagine a Framework

Sapphire is a next-gen object-oriented Discord.js bot framework.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

uninstlling @sapphire

How do i uninstall this so that it stops loading as a dependency. I've run
npm uninstall @sapphire/framework
npm uninstall @sapphire/framework
multiple times and everytime i run
npm i
npm i
@sapphire is always in the list of node_modules.....

Manual task not executing

Hiya, One of the tasks for a temp ban doesn't seem to execute after the amount of time I specified in the command. I've played around with other tasks that have worked before and still do work, updated the modules that are related to this and also delete the redis database after. I've also looked around and I don't think it's related to this: https://discord.com/channels/737141877803057244/1074660009117499413 because other pattern tasks have been working for a while, and I've gotten other called tasks to execute after 9 seconds....
Solution:
I feel slightly silly with how simple of a problem/fix it was. I used event listeners to find out that tempBan was not found but the name of the file was tempban.ts, so it wouldn't run because the file name was all lowercase.

Registering commands and other paths

Hi guys! I'm having some troubles. When I use sapphire new, everything works as intended. The commands in the commands directory are registered properly. However, if I do not use sapphire new and try to add it to an existing project, without sapphire init, it doesn't register the commands. After looking into it, and logging the stores, I see that the paths should be C:/.../myProject/bin/commands, but the path is showing C:/.../myProject/commands. Even if I copy the .sapphirerc.json from the other working one....
Solution:
Topmost big red block: https://www.sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire Configure the main property in your package.json correctly...

Is it possible to update slash command string options every time the command is ran?

This command acquires data from Firebase and use it as string choices. However, data from Firebase is not constant and will change from the moment the slash command is registered.
Solution:
1. No, commands are registered at the Discord API level. No this is not a Sapphire or DiscordJS limitation, it just just how the Discord API handles slash commands. 2. Instead of pre-defining options you should use auto completion which can be filled dynamically, for example try using /pokedex from @Dragonite which also queries an API for its options....

ts-node giving issues with Sapphire (edit: DO NOT USE TS-NODE)

Solution:
TL;DR: Do not use ts-node, use tsc-watch instead. We very strongly discourage using ts-node because it was never meant to be used for bots. ts-node is designed for REPL purposes. That's short for Read Eval Print Loop....

scheduled jobs randomly stop working

Hello! I have three different scheduled jobs at different intervals. 1 minute 10 minutes 2 minutes...

sharding

hey so i want to use discord hybrid sharding i wanted to ask if there will be issues with using it with your libary like does your libary shard or not
Solution:
sapphire is built on top of discord.js and since discord.js support sharding so sapphire with support it too

port 4000 on cluster

so my bot is in more than 8k servers and it requires clustering so when i start the bot i get this Error: listen EADDRINUSE: address already in use :::4000 i dont want to use any ports at all...
Solution:
In your API options in client options set automaticallyConnect to false and then in some event like ready or similar start it just once and on one shard by calling client.server.start

How to defer reply with Sapphirejs

Yes I know, Sapphire doesn't have this feature built-in, so I was wondering how to do it without it?
Solution:
Sapphire is built on top of discordjs. You still use discordjs methods and methodologies. That is to say, the same way you do as with discordjs.

Default preconditions

I'd like to create a check for all commands before they are run, and I'd like an alternative to pasting a precondition in every command file. Is there another way I can, for example, intercept the interactionCreate event or something?
Solution:
If it's a custom precondition that you wrote yourself add the position option to any value (the higher the value the higher the priority) and it'll turn into a global precondition.

Commands not responding to defaultPrefix

I've setup the defaultPrefix to "!": ``` const client: SapphireClient = new SapphireClient({ "intents": [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages], "loadMessageCommandListeners": true,...
Solution:
you need MessageContent intent

ts not compiling well

I don't know if it's a discord.js/sapphire issue or just a compiling issue, but when compiling normally or with ts-node, bot doesn't run at all but instead shows an error on all command files (picture below) and I dont know how to fix it
Solution:
update your dependencies. Permissions is removed in DJS v14, you need matching versions of all the Sapphire dependencies (their latest versions)

How To Use The Enum Arg?

Hello, I'm trying to use the enum arg in order to accept only one of two strings. How does one pass in the acceptable options for the enum? Could someone provide me with an example?...
Solution:
args.<method>('enum', { enum: ['one', 'two'] })

Let's users have custom folders for pieces

As the title states, I think sapphire should let people place commands, listeners and interaction handlers...etc( all pieces ) in custom folders. Maybe sapphire should let people set the paths of those pieces in SapphireClientOptions.
Solution:
Already possible. You can register a path for a store. If it is for a single store then use ```ts <this>.container.stores.get('mystore').registerPath('path/to/the/folder/here')...

piece.aliases is not iterable

Hi everybody, I was just coding a simple bot, it has only a few, basic commands like ping-pong. I just keep getting this error, and I can't figure out where it comes out from. I got it first when I created a class which extends InteractionHandler, and now even by removing that class I keep getting it. Any help is welcome. This is the class I am talking about. Don't know if I'm missing something or doing something wrong. ```JS...
Solution:
You put the InteractionHandler in the commands folder. It should go in the interaction-handlers folder instead.

guild commands not showing in command lookup

Another thread was posted about this just over a week ago, but the OP deleted his message. Basically, like the thread title says, I have a guild command, generated by the CLI, and it's just not showing in the command picker thing. Here's the code for the command: ```ts...

custom prefix

so i have a normal client just like the example one i was wondering how can i implement the fetch prefix function there

how would you go about logging shard creation in sapphire?

I understand that shards are auto created by default, how would I go about logging it? Does anyone have a bot on github that could show an example? i'm more of a visual learner :)
Solution:
Shards are entirely managed by DiscordJS. Sapphire doesn't do anything shard related. DiscordJS has several event emitters that you can listen to using Sapphire to get information about shards: https://github.com/sapphiredev/gemboard/tree/main/src/listeners/shard/...