Reduce loading time of ApplicationCommandRegistries

Hello all, I am experiencing a non-issue where the application command registries are taking over a minute to load. This is consistent, so I'm curious if there is any way to reduce this loading time. The bot has around 16 commands, most with minimal to no options.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 61,304ms to initialize.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 61,304ms to initialize.
22 Replies
Seren_Modz 21
Seren_Modz 213mo ago
you could change your default registry behaviour to bulk overwrite instead of having it compare each command for differences (i think that is the default, i can't remember).
import { ApplicationCommandRegistries, RegisterBehavior } from "@sapphire/framework";

// execute this before starting your bot
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);
import { ApplicationCommandRegistries, RegisterBehavior } from "@sapphire/framework";

// execute this before starting your bot
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);
https://www.sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/advanced/setting-global-behavior-when-not-identical
Sapphire Framework
Configuring the global behavior when commands are not identical | S...
Configuring the global behavior is easy! You just need to import the
alaninnovates, the sequel
when i do development, i often start and restart the bot. if i ewre to use that, would there be negative impacts (i.e. ratelimits) if i were to do it too often?
Seren_Modz 21
Seren_Modz 213mo ago
i've never had any problems with it myself but i don't think i really restart my bot that much during dev
Favna
Favna3mo ago
Sounds like a network issue tbh...
Favna
Favna3mo ago
could still be ping to the discord server but still weird. short of using bluk overwrite I think the only thing we can realistically do for you here is if you share each and every command registration code bit, or preferebly the whole code base so @vladdy (who wrote all the diffing loging) can analyze it
vladdy
vladdy3mo ago
if you use bulkoverwrite, the time comes from discord unfortunately, not us. for non-overwrite... use VerboseOverwrite to see whats taking longer but I doubt we can do much
alaninnovates, the sequel
aha. i have found the issue. for every load, sapphire attempts to update every command because:
[DEBUG] ApplicationCommandRegistry[memory-match] Found differences for command "memory-match" (1395414702594723983) versus provided api data.
└── At path: integrationTypes
├── Received: integration types present
└── Expected: no integration types present
[DEBUG] ApplicationCommandRegistry[memory-match] Found differences for command "memory-match" (1395414702594723983) versus provided api data.
└── At path: integrationTypes
├── Received: integration types present
└── Expected: no integration types present
so i went through and added integration types to all of my commands. it now takes 3-4ms.
Favna
Favna3mo ago
huh I thought you fixed integration types long ago @vladdy
vladdy
vladdy3mo ago
i thought so too :dead:
alaninnovates, the sequel
packages:
"@sapphire/decorators": "^6.2.0",
"@sapphire/discord.js-utilities": "^7.3.3",
"@sapphire/framework": "^5.3.6",
"@sapphire/plugin-scheduled-tasks": "^10.0.3",
"@sapphire/utilities": "^3.18.2",
"common-tags": "^1.8.2",
"discord.js": "^14.21.0",
"dotenv": "^17.2.0",
"mongodb": "^6.17.0"
"@sapphire/decorators": "^6.2.0",
"@sapphire/discord.js-utilities": "^7.3.3",
"@sapphire/framework": "^5.3.6",
"@sapphire/plugin-scheduled-tasks": "^10.0.3",
"@sapphire/utilities": "^3.18.2",
"common-tags": "^1.8.2",
"discord.js": "^14.21.0",
"dotenv": "^17.2.0",
"mongodb": "^6.17.0"
i think im on latest lmk if im not 🙃
vladdy
vladdy3mo ago
No you definitely have it right and yeah there's code for it so I dont understand why Can you share the command pls
alaninnovates, the sequel
all of them
vladdy
vladdy3mo ago
Nah just one thats throwing this error, and I only need the registerApplicationCommands method
alaninnovates, the sequel
all of them are throwing this error
vladdy
vladdy3mo ago
then the simplest one that throws this error pls :Prayge:
alaninnovates, the sequel
but i guess uh the help command ‼️
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import {
ActionRowBuilder,
ApplicationIntegrationType,
ButtonBuilder,
ButtonStyle,
StringSelectMenuBuilder,
} from 'discord.js';
import { menuData, pages } from '../lib/help/pages';

@ApplyOptions<Command.Options>({
name: 'help',
description: 'Get help with the bot',
})
export class HelpCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName(this.name)
.setDescription(this.description)
{
idHints: ['1393749717485355051'],
},
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction,
) {
await interaction.reply({
/* snip */
});
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import {
ActionRowBuilder,
ApplicationIntegrationType,
ButtonBuilder,
ButtonStyle,
StringSelectMenuBuilder,
} from 'discord.js';
import { menuData, pages } from '../lib/help/pages';

@ApplyOptions<Command.Options>({
name: 'help',
description: 'Get help with the bot',
})
export class HelpCommand extends Command {
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
(builder) =>
builder
.setName(this.name)
.setDescription(this.description)
{
idHints: ['1393749717485355051'],
},
);
}

public override async chatInputRun(
interaction: Command.ChatInputCommandInteraction,
) {
await interaction.reply({
/* snip */
});
}
}
vladdy
vladdy3mo ago
fun, ty
alaninnovates, the sequel
to fix i simply added
.setIntegrationTypes(
ApplicationIntegrationType.GuildInstall,
),
.setIntegrationTypes(
ApplicationIntegrationType.GuildInstall,
),
vladdy
vladdy3mo ago
i'll investigate tomorrow

Did you find this page helpful?