MCPcopy Create free account
hub / github.com/esmBot/esmBot / update

Function update

src/utils/handler.ts:215–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213}
214
215export function update() {
216 const commandArray: CreateApplicationCommandOptions[] = [];
217 const privateCommandArray: CreateApplicationCommandOptions[] = [];
218 const merged = new Map([...commands, ...messageCommands, ...userCommands]);
219 for (const [name, cmd] of merged) {
220 // skip slash commands with spaces in the title
221 if (cmd.type === Constants.ApplicationCommandTypes.CHAT_INPUT && name.includes(" ")) continue;
222 if (cmd.type === Constants.ApplicationCommandTypes.MESSAGE || cmd.type === Constants.ApplicationCommandTypes.USER) {
223 (cmd.adminOnly ? privateCommandArray : commandArray).push({
224 name: name,
225 nameLocalizations: getAllLocalizations(`commands.names.${name}`),
226 type: cmd.type,
227 integrationTypes: [0, cmd.userAllowed ? 1 : null].filter((v) => v !== null),
228 contexts: [0, cmd.directAllowed ? 1 : null, 2].filter((v) => v !== null),
229 });
230 } else if (cmd.slashAllowed) {
231 (cmd.adminOnly ? privateCommandArray : commandArray).push({
232 name,
233 nameLocalizations: getAllLocalizations(`commands.names.${name}`),
234 type: cmd.type.valueOf(),
235 description: cmd.description,
236 descriptionLocalizations: getAllLocalizations(`commands.descriptions.${name}`),
237 options: cmd.flags as ApplicationCommandOptions[],
238 integrationTypes: [0, cmd.userAllowed ? 1 : null].filter((v) => v !== null),
239 contexts: [0, cmd.directAllowed ? 1 : null, 2].filter((v) => v !== null),
240 });
241 }
242 }
243 return {
244 main: commandArray,
245 private: privateCommandArray,
246 };
247}
248
249export async function send(bot: Client) {
250 const commandArray = update();

Callers 1

sendFunction · 0.85

Calls 1

getAllLocalizationsFunction · 0.90

Tested by

no test coverage detected