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

Multiple Clients on one file/instance

I was wondering if its possible to run multiple clients on one file (i.e. .forEach()-ing new Client())? I tried a basic implementation and the commands we're spammed after running one once (see screenshot)...
Solution:
Absolutely not, Sapphire interacts with container which exists as a singleton (only one instance). I don't know why you want to do this, but worker threads or forks are your only way....

How to present Slashcommands?

How can I present the Slashcommands of my bot in his About Me like for example carl.gg does?
Solution:
your bot has to be verified, then it's automatic you dont configure it...

Interaction Handlers

Am I required to specify to sapphire where my interaction handlers directory is? A interaction-handlers directory doesn't seem to be detected. - ├─ Loaded 0 interaction-handlers....
Solution:
For AnswerOverflow: sapphire auto detects the interaction-handlers directory

bot won't get on and connect to discord.

hi, my bot won't turn on. i've coded a lot of bots before with sapphire and they worked just fine, decided to make a new project, coded the structure and everything good but when i run my "yarn watch:start" - "watch:start": "tsc-watch --onSuccess \"node ./dist/index.js\"" it just won't turn on....

How Do I Make a Project in my current Directory?

I want to make the proj in workspaces/DashMate not like workspaces/DashMate/${ProjName}
Solution:
currently not a feature, just create the directory then move the content.

Bot wont go online

when I try to run the script yarn dev I get this problem
Solution:
Hey @Shen (Currently Sick), The port used by the api plugin is already used so cannot connect. Try to change the port use this one 🙂...

GuildDelete Event somehow gets triggered when I restart my Bot

I have no idea whats happening but if my bot (docker container) restarts, this notification gets sent. A lot of information is missing as you can see just the guildID is valid, it’s always the same guildid and the bot has left this server some time ago already. What is going on?...
Solution:
thats what I got on DiscordJS server

TypeError: Class extends value undefined is not a constructor or null

Hey, newbie here in both TypeScript and Sapphire, and I'm trying to build a command but I'm getting the error specified in the title, my code for the constructor is the following: ```ts public constructor(context: CommandContext, options: Command.Options) { super(context, { description: 'Play a song',...
Solution:
Write a proper tsconfig. By default with no target set it compiles to ES3 which doesn't support classes.

THREAD_CREATE event Listener run method arguments

What I want to do: I want to inspect the id of the parent channel where the thread was created. The code I tried: ```typescript...
Solution:
Any event emitted by the discordjs websocket, such as THREAD_CREATE, doesn't receive a discordjs class, such as ThreadChannel, as first parameter. It receives the raw discord API data. If you type it as the type from discord-api-types (dunno which) you'll get the right properties in your code. My guess is that it's an APIThreadChannel https://discord-api-types.dev/api/discord-api-types-v10/interface/APIThreadChannel The ws event also receives only ONE argument which is that APIThreadChannel, there is no second argument NewlyCreated. That gets inserted by DiscordJS....

await args.pick("member");

how to enable this? https://discord.com/channels/737141877803057244/737142071319855105/1078048848255144026 I already updated sapphire framework...
Solution:
args.pick('member', { context: { performFuzzySearch: false }})

Command info command issue

I have a command info command, but when I try to get information on a command called "flags" it returns this error: ```js at ArrayValidator.handle (C:\Users\cmart\Desktop\Sapphire\node_modules@sapphire\shapeshift\dist\index.js:457:70) at ArrayValidator.parse (C:\Users\cmart\Desktop\Sapphire\node_modules@sapphire\shapeshift\dist\index.js:201:88)...
Solution:
there is absolutely no way to tell from that error but something appears to be going wrong with setting embed data. This also isn't Sapphire related, instead it is purely your own code so you're best off fixing it on your own.

Running in production

Hey! What's the recommended method for starting up a node app in production? Specifically for DiscordJS - I was looking into pm2 but would love if anyone has other resources / recommendations - thanks!
Solution:
pm2 works but I would recommend Docker. For one it allows you to mimick your entire environment locally first and not quickly run into unexpected differing environment issues. When you use a docker compose file you can also configure quite a lot of the service(s). I assume @Answer Overflow has some kind of database for example which you can also run in docker. If you run that baremetal right now, you'd have to data dump and data import. Other useful features of docker are - built in limiting of resources per service - built in environmental file or inline loading. ...

speakerName translation in FFXIVIpcChat

Hello everyone, I'm using ffxiv-pcap to read chat messages using the Sapphire Struct for chat messages. /** * Structural representation of the packet sent by the server * carrying chat messages...

Clearing registered slash commands

Hello 👋 I would like to know if there's a system provided by Sapphire to automatically clear previous registered slash commands? Thanks!...
Solution:
Use bulk overwrite as default registry behaviour.

ReferenceError: [ENV] BOT_OWNER_IDS - The key must be an array, but is empty or undefined.

I am using @skyra/env-utilities and when I start up my bot, I get the error reported in the title of this post. I cannot figure out what I am missing. I have a .env.local file in my src directory. It is erroring when it gets to export const OWNERS = envParseArray('BOT_OWNER_IDS'); in my src/lib/constants.ts file. This is the contents of my src/lib/setup.ts file:...
Solution:
Okay so the problem is that files are required in order of lines in the file so index calls setup first, but that also first calls constants because it's above the line that calls setup. Calling constants means that envParseArray gets executed, but because setup hasn't ran yet you get the error that you do. So the fix is to split your constants file in stuff that is needed for env, and stuff that isn't needed. That way you can safely import the former in setup....

How to use `@sapphire/shapeshift ` dateValid & stringRegex

I have a slash command that needs to take in a date input in the format of YYYY-MM-DD. I want to perform validation on this and throw an error if it is not in this format or not a valid date. I was looking at the documenation, but I was hoping to see a code example to help explain the usage. I appreciate the explanation and help.
Solution:
You can't do it all in one validation I think so instead:
s.string.regex(/\d{4}-\d{2}-\d{2}/)
s.string.regex(/\d{4}-\d{2}-\d{2}/)
...

Access extended sapphire client

Following usecase: I extended the sapphire client in order to create custom collections etc. Is there any way I can access the extended client through the container?...
Solution:
container.client, and you need to add module augmentation to add the properties to the Client class from discord.js ```ts declare module 'discord.js' { interface Client { myCustomProperty: any...

Version mismatch between Sapphire and dapi-types

Hi, I was updating my dependencies when I encountered Discord.js' dapi-types error. I copy/pasted their solution in my package.json (https://discord.com/channels/222078108977594368/769862166131245066/1076213839990894604) ```json "overrides": { "discord-api-types": "0.37.20"...
Solution:
Because if so refer to https://discord.com/channels/222078108977594368/769862166131245066/1076213839990894604 and in your own code add proper checks using !isStageChannel (...)

Whats the syntax to require Permission X AND Y OR Z when using requiredUserPermissions

when using requiredUserPermissions. Its an array so Im not sure
Solution:
No, required user permissions does not allow nested arrays and "and/or" logic. I recommend you just implement it in the run function. Or, use the precondition directly: ```ts preconditions: [ { name: 'UserPermissions', context: { permissions: PermissionFlags.Administrator } },...