Sapphire - Imagine a framework

Welcome to the Sapphire Discord server! The next-gen object-oriented Discord.js bot framework can be found here.

Join Server

Community questions


How to get infos about the current task?

I want to log things like taskid etc. what infos are there to work with and how do I get them inside of my task?

How can i start using bulkOverwrite

I was just curious on how I could start using BulkOverwrite to override slash commands?

Adding preconditions to a slash command?

Is there a way to add a precondition to an application command? I'm not sure if it works the same as the old chat commands or if I would have to hardcode them into each command.

mongoose listener not working

im trying to setup a mongoose listener for the 'open' event however saphire doesnt seem to catch it my best guess is i didnt specify the right emitter as my other listeners work here is a screenshot

TypeError: channel.isTextBased is not a function

I have a problem with Interactions:
Since yesterday evening every button interaction results in an error as follows
        if (channel && !channel.isTextBased()) return;

TypeError: channel.isTextBased is not a function
    at InteractionCreateAction.handle (/home/developer/Wishbot/node_modules/discord.js/src/client/actions/InteractionCreate.js:50:33)
    at module.exports [as INTERACTION_CREATE] (/home/developer/Wishbot/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (/home/developer/Wishbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (/home/developer/Wishbot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:489:22)
    at WebSocketShard.onMessage (/home/developer/Wishbot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:328:10)
    at callListener (/home/developer/Wishbot/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onMessage (/home/developer/Wishbot/node_modules/ws/lib/event-target.js:209:9)
    at WebSocket.emit (node:events:512:28)
    at Receiver.receiverOnMessage (/home/developer/Wishbot/node_modules/ws/lib/websocket.js:1180:20)
    at Receiver.emit (node:events:512:28)

Can not resolve dependency sapphire

Hello, after todays NODE JS update, im having an issue with sapphire dependency, would you be able to advise me? thank you.

UserError listener not catching all errors

I am running an imported function in my command, and calling UserError in this file and when I do, it is not caught by the listener, and my bot crashes.

Error Source: https://github.com/cosigyn/Clanware-V3/blob/master/src/mods.mjs#L229
Command: https://github.com/cosigyn/Clanware-V3/blob/master/src/commands/general/affiliate.mjs

How to get message args ?

Like i have command +mark 123, how i can get the 123

API Placeholder in Route

I didn't found it in the docs. Is there any way to get a placeholder into a route like in express with /routename/:id so I can use it to get the resource with the respective id?

TypeError piace.aliases is not iterable

Good afternoon, I mixed such a strange code as best I could. My task was to add a button to the message with a built-in embed, but it's not clear why I get an error in the console, please give me an answer what I did wrong :). Code and error below.

const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, } = require("@discordjs/builders")
const { Command, Piece, InteractionHandlerTypes } = require('@sapphire/framework');
const { ButtonStyle, InteractionType } = require("discord.js");

class Embed extends Command {
constructor(ctx, context, options) {
super(ctx, context, { ...options,
InteractionHandlerType: InteractionHandlerTypes.Button

registerApplicationCommands(registry) {
registry.registerChatInputCommand((builder) =>
async chatInputRun(interaction,client) {
const button = new ButtonBuilder()

const embed = new EmbedBuilder()
const embed2 = new EmbedBuilder()
const embed3 = new EmbedBuilder()

interaction.channel.send({ embeds: [embed,embed2,embed3]}, {components: [ActionRowBuilder(),addComponents(button)]})
module.exports = {
Embed, ActionRowBuilder, ButtonBuilder
D:Файлы\Project 1\node_modules@sapphire\pieces\dist\lib\structures\AliasStore.js:58
for (const key of piece.aliases) {

API Client with SSL?

Hey guys,

currently I am trying to make the switch from an custom express API to the API plugin. Is there a way to let the plugin consume an ssl cert and open a https server?


Context Menu Command and Subcommand cannot be in same extended class?

I have a slash command which is an extended Subcommand called give-role with two subcommands - one & multi.

The file name is give-role.ts

Now I also want a Context Menu command named Give Role within same give-role.ts

I can register both slash command & context menu command, but cannot provide contextMenuRun() within same give-role class.

Any solution(s)?

UserErrors not being caught by listener - bot is crashing

import { Events, Listener } from "@sapphire/framework";
import { send } from "@sapphire/plugin-editable-commands";
import { EmbedBuilder } from "discord.js";

export class UserEvent extends Listener {
  constructor(context, options) {
    super(context, {
      once: false,
      event: Events.MessageCommandError,
      name: "messageCommandError",

  async run({ context, message: content }, { message: msg }) {
    // `context: { silent: true }` should make UserError silent:
    // Use cases for this are for example permissions error when running the `eval` command.
    if (Reflect.get(Object(context), "silent")) return;

    const embed = new EmbedBuilder()
      .setTitle("Command Failed")

    return send(msg, {
      embeds: [embed],
      allowedMentions: { users: [msg.author.id], roles: [] },

Subcommand isn't running

When the subcommand is run in Discord, it times out. I've added a log to the beginning of the method but it isn't triggered. Normal commands work fine.

  name: 'blacklist',
  description: 'Blacklist users or guilds from using the bot.',
  preconditions: ['OwnerOnly'],
  subcommands: [
      name: 'user',
      chatInputRun: 'chatInputUser'
export class BlacklistCommand extends Subcommand {
  public override registerApplicationCommands(
    registry: ChatInputCommand.Registry
  ) {
      (builder) =>
          .addSubcommand((command) =>
              .setDescription('Blacklist a user from using the bot.')
              .addUserOption((option) =>
                  .setDescription('The user to blacklist.')
        guildIds: config.testGuilds

  public async chatInputUser(
    interaction: Subcommand.ChatInputCommandInteraction
  ) {

How to properly handle UserErrors?

I'm using the official sapphire template and want to throw a UserError inside a context menu command.
How do I correctly handle the error and send a message to the user?
I saw contextMenuCommandDenied.ts and thought that would handle it but I don't get a response and the error is shown in the logs.

Can I set different requiredUserPermissions for each subcommand?

Just wondering if this is possible, and how. Thanks

Handling BulkOverwrite Registry Errors

When I encounter this error
[ERROR] ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite guild application commands for guild 1********* DiscordAPIError[50001]: Missing Access

I want to be able to capture this error and take an action. In this case update my record of guilds to remove the inaccessible guild.

I've tried to capture the errors using the error event listener as well as one on commandApplicationCommandRegistryError however neither seems to be called when this error occurs. What is the recommended way to listen for these BulkOverwrite error events?

Example listeners which are never called:
import { ApplyOptions } from '@sapphire/decorators';
import { Listener, Events, Command } from '@sapphire/framework';

  event: Events.CommandApplicationCommandRegistryError,
export class ApplicationRegistryError extends Listener<
  typeof Events.CommandApplicationCommandRegistryError
> {
  public run(error: unknown, command: Command) {
    console.error('caught registry error');

import { Events, Listener } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';

  event: Events.Error,
export class ErrorListener extends Listener {
  public run(error: Error) {
    console.error('captured error');

Events for Voice

How can I do something like the following but for voice?

import { Listener } from '@sapphire/framework';

export class VoiceStateUpdateListener extends Listener {
  constructor(context, options) {
    super(context, {
      once: false,
      event: 'voiceStateUpdate'

  async run(oldState, newState) {

How do I use autocompleteRun on subcommands?

^ As the title says. I can't seem to figure out how subcommands can have autocompleteRun implemented. I'm not too worried about duplicates, since there is only one subcommand that uses autocomplete.