@constatic/base 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApplicationCommandOptionType, ApplicationCommandType, AutocompleteInteraction, ChatInputCommandInteraction, InteractionContextType, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, type ApplicationCommandOptionAllowedChannelTypes, type ApplicationCommandOptionChoiceData, type BaseApplicationCommandData, type CacheType, type LocalizationMap } from "discord.js";
|
|
2
2
|
import type { NotEmptyArray, UniqueArray } from "../../utils/types.js";
|
|
3
|
-
export type CommandType =
|
|
3
|
+
export type CommandType = ApplicationCommandType.ChatInput | ApplicationCommandType.Message | ApplicationCommandType.User;
|
|
4
4
|
type AutocompleData<Type> = Promise<readonly ApplicationCommandOptionChoiceData<Type extends (number | string) ? Type : (number | string)>[] | undefined | void>;
|
|
5
5
|
export type AutocompleteRun<Type, Contexts> = (this: void, interaction: AutocompleteInteraction<CacheMode<Contexts>>) => AutocompleData<Type>;
|
|
6
6
|
interface AutocompleteOptionData<Type, Contexts> {
|
|
@@ -196,26 +196,30 @@ class CommandManager extends BaseManager {
|
|
|
196
196
|
const promises = [];
|
|
197
197
|
const manager = client.application.commands;
|
|
198
198
|
const logs = [];
|
|
199
|
-
const setGlobal = (commands2) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`${client.user.username} application`
|
|
203
|
-
])));
|
|
199
|
+
const setGlobal = async (commands2) => {
|
|
200
|
+
const data = await manager.set(commands2);
|
|
201
|
+
logs.push([data.size, `${client.user.username} application`]);
|
|
204
202
|
};
|
|
205
|
-
if (guildList.size
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
if (guildList.size) {
|
|
204
|
+
const guildScopedCommands = [];
|
|
205
|
+
const globalCommands = [];
|
|
206
|
+
for (const command of commands) {
|
|
207
|
+
if (command.global) {
|
|
208
|
+
globalCommands.push(command);
|
|
209
|
+
} else {
|
|
210
|
+
guildScopedCommands.push(command);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const id of guildList) {
|
|
214
|
+
promises.push(manager.set(guildScopedCommands, id).then((registerdCommands) => logs.push([
|
|
215
|
+
registerdCommands.size,
|
|
210
216
|
`${id} guild`
|
|
211
217
|
])));
|
|
212
218
|
}
|
|
213
|
-
|
|
214
|
-
if (globalCommands.length >= 1) {
|
|
215
|
-
setGlobal(globalCommands);
|
|
216
|
-
}
|
|
219
|
+
promises.push(setGlobal(globalCommands));
|
|
217
220
|
} else {
|
|
218
|
-
setGlobal(commands);
|
|
221
|
+
promises.push(setGlobal(commands));
|
|
222
|
+
client.guilds.cache.forEach((guild) => guild.commands.set([]).catch(() => null));
|
|
219
223
|
}
|
|
220
224
|
await Promise.all(promises);
|
|
221
225
|
console.log(logs.map(([size, location]) => format(styleText("green", "└ %s command%s registered in %s"), size, size === 1 ? "" : "s", styleText("greenBright", location))).join(`
|
package/dist/version.js
CHANGED