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

How to use windows env variables using skyra env utilities

i am trying to use CD for hosting and i have env variables set on windows, how do i access them with skyra/env-utilities.
Solution:
I am gonna pass my token explicitly from process.env thats the only solution i found.

Pattern for fetching all registered slash commands

I have some slash commands and some with subcommands and and want to introduce a /help slash command that shows all the available guild commands and their description? I want to get the names and descriptions for all the slash commands. I realize I can use the raw discord client to fetch that registered commands and parse then use that. However, I'm trying to see if it's possible to avoid making those additional network calls. Thanks....
Solution:
You can get all your command classes from the commands store. Thats accessed using client.stores.get('commands')

Precondition with Slash Command

How to report precondition failure w/ clash command? If I use this.error({ message: 'error' }); in precondition, it does nothing. ```js...

How to use skyra env utilities with the cli generated project?

I want to use env variables to store my mongo uri, but due to skyra utilities being their i cant use dotenv How am i supposed to use it?
MONGO=URI
MONGO=URI
...

How to get the current channel a slash command was used in

I took a look at the following post https://discord.com/channels/737141877803057244/1061609301556346921 and
const target= await interaction.guild?.channels.cache.get('id');
const target= await interaction.guild?.channels.cache.get('id');
comes up as undefined. I am needing to get returned as if I were running client.channels.fetch(process.env.BOT_REPORT_CHANNEL_ID)...
Solution:

Preventing Commands in DMs

How do you prevent commands from being used in DMs? Message commands.
Solution:
Add runIn: 'GUILD_ANY' to your command options. This will only the command to be run in guild channels. If you want to specify a type of channel there are opttions for that

autoModerationActionExecution Event

Does Sapphire not emit the Discord.js autoModerationActionExecution event? The following code doesn't seem to trigger: autoModerationActionExecution.ts ```ts...
Solution:
Right just looked at Intents in case I was missing anything obvious and apparently AUTO_MODERATION_EXECUTION is a completely separate intent https://discord.com/developers/docs/topics/gateway#gateway-intents

Help canceling a command

Here the code I have for a simple reminder command.https://pastebin.com/crRSdjEn. It works but id like to be able to cancel a specific reminder / list the current active reminders. Can someone explain how the code is being run? My current thought would be that the class only has one instance but the async method can have multiple independent instances. How would I go about soring a list of all of the current reminders / canceling said reminders
Solution:
reminders like that won't work at all because you need to reply within 3 seconds and even if you defer then you need to reply within 15 minutes so a reminder could never be longer than that. You need to completely rework this and use a proper queuing/scheduling system, use an external database to store reminders and write some way to check if a reminder has expired and only then send it to the user.

What parameter do I pass to the run method in my GuildCreate listener?

Solution:
something like guild: public run(guild: Guild) {} ?

Problem with this.container.stores.get().get();

Code:
Solution:
The error means you're probably not running this code in a piece (listener, command, etc), so this.container doesn't exist. Instead, import container from @sapphire/framework directly.

InteractionCreate file

Can I easily create a listener for interactionCreate? I need it for some UI Abilities, and I am not sure if it overrides something...
Solution:
you can but you probably want to use interaction handlers the core even that trigger interaction handlers does barely anything really https://github.com/sapphiredev/framework/blob/main/src/listeners/CoreInteractionCreate.ts#L7...

How to Create Threads?

I dont get how to create threads programmatically. Please help

Command info

does sapphire have a built in command info funtions so we can get for example the aliases of a command?

args.pick("member")

using args.pick("member"), is it intended to get the member even if you just provide 1 letter of their username? if yes, is there any way to prevent it?
Solution:
Yes and no respectively. Can be added, make a GH issue. Sidenote that slash commands are overall better and you don't need custom args picking there....

why does this not work in sapphire

index.js ```js const { util } = require("./utils"); const { container } = require("@sapphire/framework"); ...
Solution:
That would be:
const util = require("./utils");
const util = require("./utils");
...

This code is not running on sapphire

```js const { Listener } = require("@sapphire/framework"); const { ActivityType } = require("discord.js"); const ms = require("ms"); ...
Solution:
figured it out, to anyone else that has this problem just add async before the run and also add this code before the async run(client) {} part ```js constructor(context, options) { super(context, {...

Bot stalls while registering commands

My bot was working fine yesterday after noticing the new Cog section of the documentation (really cool thank you it worked perfectly.) After I changed to the cog system I noticed the updates to the packages in Announcements. I ran npm upgrade and started receiving the channel errors noted in another thread which I was able to fix. The bot now just stalls when registering commands, any idea what I can change? The registrations match the documentation as far as I can tell. Log: https://pastebin.com/BrPAYDa3 Package.json: https://pastebin.com/rRQyYjWA register snippet: https://pastebin.com/xeiryjk8...

How to edit an Embed(Documentation isn't working)

Hi. Trying to make a discord bot that will send a message to a specific channel on startup. I have the message sent to the specific channel on startup, however, when I try to edit it a error is thrown saying message.edit is not a function. I am following the direct steps from the documentation and it is not working. Why and how do I fix this issue? ```ts...

Schdeduler SQS Options in index.ts

Where can I find what options I have to pass for the SQS Version of the Scheduled Task? I cant seem to find it in the guide