Fozzie
Fozzie
SIASapphire - Imagine a framework
Created by Fozzie on 8/9/2024 in #sapphire-support
Issue with application commands after logging in after client#destroy()
If I login after doing client.destroy(), the bot logs in fine, but the application commands aren't registered again. Am I doing something wrong? Some example code:
client = new SapphireClient({
intents: Constants.INTENTS,
partials: Constants.PARTIALS,
presence: Constants.PRESENCE,
});
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(
RegisterBehavior.Overwrite,
);

await client.login(process.env.TOKEN);
await client.destroy();

client = new SapphireClient({
intents: Constants.INTENTS,
partials: Constants.PARTIALS,
presence: Constants.PRESENCE,
});
await client.login(process.env.TOKEN);
client = new SapphireClient({
intents: Constants.INTENTS,
partials: Constants.PARTIALS,
presence: Constants.PRESENCE,
});
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(
RegisterBehavior.Overwrite,
);

await client.login(process.env.TOKEN);
await client.destroy();

client = new SapphireClient({
intents: Constants.INTENTS,
partials: Constants.PARTIALS,
presence: Constants.PRESENCE,
});
await client.login(process.env.TOKEN);
The first login I get (I am logging Bot has connected on the ready event):
ApplicationCommandRegistries: Initializing...
Bot has connected.
ApplicationCommandRegistries: Took 6ms to initialize.
ApplicationCommandRegistries: Initializing...
Bot has connected.
ApplicationCommandRegistries: Took 6ms to initialize.
But on the second login I only get:
Bot has connected.
Bot has connected.
So it seems like ApplicationCommandRegistries isn't being initialised again. Should I be recreating the SapphireClient, or is there another way I should be doing this? Thanks!
26 replies
SIASapphire - Imagine a framework
Created by Fozzie on 5/15/2024 in #sapphire-support
Sapphire "no such file or directory" error
I know I like to only have weird bugs, but this is a new level even for me. Updating @sentry/node from ^7.114.0 to ^8.0.0 causes the following error in Sapphire on startup (not just for messageUpdate, for loads of other files as well):
Error when loading '/app/dist/listeners/messageUpdate.js': [Error: ENOENT: no such file or directory, open '/app/node_modules/@sapphire/framework/dist/esm/@sapphire/result'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/app/node_modules/@sapphire/framework/dist/esm/@sapphire/result'
}
Error when loading '/app/dist/listeners/messageUpdate.js': [Error: ENOENT: no such file or directory, open '/app/node_modules/@sapphire/framework/dist/esm/@sapphire/result'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/app/node_modules/@sapphire/framework/dist/esm/@sapphire/result'
}
Any ideas? Is this likely an upstream issue?
11 replies
SIASapphire - Imagine a framework
Created by Fozzie on 6/18/2023 in #sapphire-support
Event before interaction handlers are ran
There are ChatInputCommandRun and ContextMenuCommandRun events, which are emitted before the run method. Is there anything similar for interaction handlers which is emitted after parse but before run?
12 replies
SIASapphire - Imagine a framework
Created by Fozzie on 2/24/2023 in #sapphire-support
autoModerationActionExecution Event
Does Sapphire not emit the Discord.js autoModerationActionExecution event? The following code doesn't seem to trigger: autoModerationActionExecution.ts
import { Listener } from "@sapphire/framework";
import { AutoModerationActionExecution } from "discord.js";

export class AutoModerationActionExecutionListener extends Listener {

public async run(action: AutoModerationActionExecution) {
console.log("hi!");
}
}
import { Listener } from "@sapphire/framework";
import { AutoModerationActionExecution } from "discord.js";

export class AutoModerationActionExecutionListener extends Listener {

public async run(action: AutoModerationActionExecution) {
console.log("hi!");
}
}
I could be doing something completely wrong though!
9 replies
SIASapphire - Imagine a framework
Created by Fozzie on 1/10/2023 in #sapphire-support
Context menu commands not being registered
Hi, on updating to v4 I experienced the following error:
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
I imagined this might be caused by the migration, so I deleted the application command and removed the idHints, but now the context menu won't even register at all. I'm not getting any error or output in the console using the following code:
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: Constants.GUILD_IDS,
}
);
registry.registerContextMenuCommand(
{
name: "Banish",
type: ApplicationCommandType.Message,
},
{
guildIds: Constants.GUILD_IDS,
}
);
Has there been a change I'm missing here?
41 replies
SIASapphire - Imagine a framework
Created by Fozzie on 12/19/2022 in #sapphire-support
API error event handler
Hi, when I get a DiscordAPIError through the logger that starts like this:
Encountered error while handling an interaction handler run method for interaction-handler
Encountered error while handling an interaction handler run method for interaction-handler
Is there a singular event to capture these without listening to multiple events such as chatInputCommandError, commandAutocompleteInteractionError and contextMenuCommandError etc?
4 replies