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
[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';

@ApplyOptions<Listener.Options>({
event: Events.CommandApplicationCommandRegistryError,
})
export class ApplicationRegistryError extends Listener<
typeof Events.CommandApplicationCommandRegistryError
> {
public run(error: unknown, command: Command) {
console.error('caught registry error');
console.error(error);
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Listener, Events, Command } from '@sapphire/framework';

@ApplyOptions<Listener.Options>({
event: Events.CommandApplicationCommandRegistryError,
})
export class ApplicationRegistryError extends Listener<
typeof Events.CommandApplicationCommandRegistryError
> {
public run(error: unknown, command: Command) {
console.error('caught registry error');
console.error(error);
}
}
import { Events, Listener } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';


@ApplyOptions<Listener.Options>({
event: Events.Error,
})
export class ErrorListener extends Listener {
public run(error: Error) {
console.error('captured error');
console.error(error);
}
}
import { Events, Listener } from '@sapphire/framework';
import { ApplyOptions } from '@sapphire/decorators';


@ApplyOptions<Listener.Options>({
event: Events.Error,
})
export class ErrorListener extends Listener {
public run(error: Error) {
console.error('captured error');
console.error(error);
}
}
16 Replies
Favna
Favna•2y ago
@A Vladdy
vladdy
vladdy•2y ago
Did I do a dumb and forgot to handle this? Yes, yes i did I made it just log Thx for the report, I'll have a pr to add this to an event hopefully this week
kyle13
kyle13OP•2y ago
Thanks @Vladdy appreciate the response and fast turnaround!
vladdy
vladdy•2y ago
@kyle13 I've opened https://github.com/sapphiredev/framework/pull/622, should work, you can install the packed version and test it out sometime Prayge
kyle13
kyle13OP•2y ago
@A Vladdy the code fix looks like it will solve the issue. I'm just not sure how to "install the packed version" to test it out. I tried checking out the branch, building it and using npm link, but it seems like it can't resolve the types for my project when used that way. Any advice on how to install and test out your fix? Also is there a timeline on when this would be added to a release? Thanks so much for your help!
vladdy
vladdy•2y ago
we packed the release for you oh shit @Favna this is badd Im gonna try a rerun
Favna
Favna•2y ago
sup? what happened?
vladdy
vladdy•2y ago
sapphire pack never finished wait it did it never responded tho
Favna
Favna•2y ago
you have to run npm run prepack when you want to link otherwise it doesnt build a proper bundle
vladdy
vladdy•2y ago
Favna
Favna•2y ago
npm i @sapphire/framework@pr-622
npm i @sapphire/framework@pr-622
anyway yeah I noticed that before as well I need to look into it I guess @A Vladdy can you create a GH issue on the repo and assign me so I dont forget? sapphiredev/sapphiredev
vladdy
vladdy•2y ago
on it
Favna
Favna•2y ago
tyvm
vladdy
vladdy•2y ago
mf disabled issues 🤡
Favna
Favna•2y ago
what 🤡
kyle13
kyle13OP•2y ago
Thank you @Vladdy and @Favna for your outstanding support! I was able to download the test version and verify adding a listener lets me capture the bulk overwrite errors perfectly. I'll go ahead and mark this request as solved.
@ApplyOptions<Listener.Options>({
event: Events.ApplicationCommandRegistriesBulkOverwriteError,
})
export class ApplicationRegistryError extends Listener<
typeof Events.ApplicationCommandRegistriesBulkOverwriteError
> {
public run(error: unknown, guildId: string) {
logger.error('caught bulk registry error', { guildId, error });
}
}
@ApplyOptions<Listener.Options>({
event: Events.ApplicationCommandRegistriesBulkOverwriteError,
})
export class ApplicationRegistryError extends Listener<
typeof Events.ApplicationCommandRegistriesBulkOverwriteError
> {
public run(error: unknown, guildId: string) {
logger.error('caught bulk registry error', { guildId, error });
}
}
Want results from more Discord servers?
Add your server