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

Is there a way to make precondition in interaction be ephemeral?

cause with the OwnerOnly the CLI gives it throws the error in a regular reply.

Default Permissions

Hello! As i do slash commands only, is it possible to set the Default Permission, so that the guild admins can override perms if they want?
Solution:
```ts import { Command, type ChatInputCommand } from '@sapphire/framework'; import { applyLocalizedBuilder } from '@sapphire/plugin-i18next'; import { PermissionFlagsBits } from 'discord-api-types/v10'; ...

Issue with path aliases not working when using imports (TypeScript)

Not sure what exactly is going on, normally I'm only using TS paths like "@lib/*": ["src/lib/*"] but I wanted to start implementing something similar in my bot to make it so I don't have a bunch of ../../../ and whatnot when I'm having to import certain types/classes/etc.. Never had any issues with this while using NextJS, but I assume this has to be an issue with my tsconfig/package.json files. This is the error I'm getting at the moment: ```...
Solution:
The error is a NodeJS runtime error. Not a TS compile error. TS doesn't recalculate aliases and output resolved paths. You need to also configure your aliases in package.json subpath imports. Note that you also need to switch to # instead of @ then because that's what node requires. https://nodejs.org/api/packages.html#subpath-imports You can look at various examples from /tag bots ( @Spinel command)...

"ChatInputCommandError" listener not firing for subcommands

ChatInputCommandError.ts: ```ts import { ChatInputCommandErrorPayload, Events, Listener } from '@sapphire/framework'; import generalErrorEmbed from '../lib/embed-presets/GeneralError.js'; ...
Solution:
SubcommandPluginEvents

how do you make these using sapphire?

^
Solution:
and requires ur bot to be verified
No description

commands

Is there any way to ignore a command inside the commands folder ?! i have an abstract class that extend Command ! but i do not want to set the abstract class as command , only the child classes that extends the abstract class...
Solution:
move BaseSelfRoleCommand out of the commands folder

Decorators Message Context?

The decorators don't really say, can I use them on top of an interaction? If not, what's the recommended flow to use the decorators e.g. RequiresGuildContext() on things like a command rather than a subcommand?

Scope of Command Classes?

Hi just curious, what's the scope of command classes? Is a class created each time you run the command, or ```py export class ConfigCommand extends Command { supportChannel: Channel | null = null; settingsEmbed: EmbedBuilder | null = null;...
Solution:
An instance is created before the bot logs in and afterwards that same instance is always referenced. Thank god because otherwise perf would be dogshit

Command is not registering

i have a issue with register a translated command.. Current code is ```ts import { ApplyOptions } from '@sapphire/decorators';...
Solution:
@Fabi My current suspicion is that you havent setup @sapphire/plugin-i18next properly. Here is a zip with files that are based on the CLI generated template that show what needs to be done The important parts are: 1. Calling the /register of the plugin 2. Configuring the languages for the plugin (see the config in src/index.ts)...

logger doesn't work properly

Hello, so I faced a logger problem. I registered the plugin in src/index.ts and plugin doesn't register properly, I think. Logs looks like a basic sapphire log without a plugin. How can I fix a problem with logger plugin?
Solution:
"@sapphire/plugin-logger": "^3.0.7",
That's an old version. Please update to v4.0.2 on that note, these also....
No description

Slashcommand Option Translation

Hello! How do i translate slashcommand options?, didnt saw a example. Thanks!

Globally setting the guild in which to register commands by default

Even though I'm setting ApplicationCommandRegistries.setDefaultGuildIds(<GUILD_ID>); before <SapphireClient>.login the commands are still being registered globally. The commands do not have the guildIds option set.

Who is Sapphire for ?

I was reading about the framework. So if I understand, that is basically just adding an opiniated structure to your code? Assuming you have made big bots and know your way with ts/js, is that something that is still commonly used by proficient bot developers, or is it something whos more aimed at helping beginners with their journey?...
Solution:
either way, the point is that either you can choose to maintain a lot of code for command handling yourself (especially if you use slash commands), or use a framework and have that work done for you.

Subcommands Not Working

Hello, I am trying to make my subcommands "tidy" by using separate files, but the functions aren't even running. server.command.ts ```ts import { Subcommand } from "@sapphire/plugin-subcommands";...
Solution:
@Enrique I looked into the issue and I can run subcommands just fine. I created a PR with the changes I made https://github.com/b1nzeex/dvs-discord-bot-v2/pull/1 The notable ones are: - Reinstalling dependencies, part of updating to yarn v4 - Setting up the initial Prisma migration so the schema is created. You connect the database, so you need to make sure Prisma can actually interact with it. Without this the application should just crash at init anyway...
No description

Using JSON to register application commands and add options

Hi there, Is there a way to add all of my application command options in the registerApplicationCommands method on the Command class without using builders? For example, a registerApplicationCommands method might look like this currently, to register options:...
Solution:
Builders serialise to JSON and you can also provide that same JSON. ```ts // Registering with the discord.js options object...

Paginated Message not working

When I run this code, it says "This interaction failed" without any error. ```js const { PaginatedMessage } = require('@sapphire/discord.js-utilities'); const BeemoCommand = require('../../../lib/structures/commands/BeemoCommand'); const { EmbedBuilder } = require('discord.js');...
Solution:
Change messageRun for chatInputRun. You're mixing message based and slash commands.

Formatted Logs

Is there a way to extend the existing logger within Sapphire? I saw that in the logger argument of the client constructor I can pass an instance of ILogger. So, I thought I could just extend the Logger class from @sapphire/framework and pass that to the instance argument. Doesn’t seem to work. It’s not formatting my logs. Seems to stick to the default logger. Are there any other options?...
Solution:
… Hmm. Alright then. Seems like an unnecessary amount of work just to change the format of how log messages are written. But guess I’ll have to do that.

Paginated Message Bug

```js DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (D:\bots\scully\node_modules@discordjs\rest\dist\index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async BurstHandler.runRequest (D:\bots\scully\node_modules@discordjs\rest\dist\index.js:826:23)...
Solution:
could they have any interaction handlers that ended up having the same name as something in a paginated message component?

Optimal way of developing with typescript

Hello! I've been using sapphire for some days now, and one thing that I'm trying to achieve is to not change anything in the source code of my bot when being done with my developing and deploying to production, or going back to developing after deploying. I may be completely wrong, but in the documentation, it says that sapphire needs the "main" property of the package.json to point to the main file of my bot. But the issue I'm personally having is that when developing in typescript, I point the "main" property to something like "src/index.ts", but before deploying to production, I manually change that to "dist/index.js". ...
Solution:
Tsc-watch config is included in sapphire's template bot. So You can use that instead...

/test command doesn't work but /ping does?

code: https://paste.ee/p/k2cXx please ping me when you respond! Thanks in advance...