MCPcopy Create free account
hub / github.com/ArrowM/Queue-Bot / registerCommands

Function registerCommands

src/utils/client.utils.ts:27–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25 let LIVE_COMMANDS: Collection<Snowflake, ApplicationCommand<{ guild: GuildResolvable }>>;
26
27 export async function registerCommands() {
28 try {
29 console.time(`Registered ${COMMANDS.size} commands with server`);
30 const commandsPutRoute = Routes.applicationCommands(process.env.CLIENT_ID);
31 const commandsJSON = COMMANDS.map(c => c.data.toJSON());
32 await new REST()
33 .setToken(process.env.TOKEN)
34 .put(commandsPutRoute, { body: commandsJSON });
35
36 LIVE_COMMANDS = await CLIENT.application.commands.fetch();
37 console.timeEnd(`Registered ${COMMANDS.size} commands with server`);
38 }
39 catch (e) {
40 console.error(e);
41 }
42 }
43
44 export function getLiveCommand(commandName: string) {
45 return LIVE_COMMANDS.find(cmd => cmd.name === commandName);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected