@open-discord-bots/framework 0.0.1 → 0.0.2
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.
- package/LICENSE.md +713 -0
- package/README.md +104 -0
- package/dist/api/api.d.ts +26 -0
- package/dist/api/api.js +44 -0
- package/dist/api/main.d.ts +133 -0
- package/dist/api/main.js +87 -0
- package/dist/api/modules/action.d.ts +34 -0
- package/dist/api/modules/action.js +58 -0
- package/dist/api/modules/base.d.ts +329 -0
- package/dist/api/modules/base.js +804 -0
- package/dist/api/modules/builder.d.ts +647 -0
- package/dist/api/modules/builder.js +1441 -0
- package/dist/api/modules/checker.d.ts +648 -0
- package/dist/api/modules/checker.js +1324 -0
- package/dist/api/modules/client.d.ts +768 -0
- package/dist/api/modules/client.js +1859 -0
- package/dist/api/modules/code.d.ts +33 -0
- package/dist/api/modules/code.js +57 -0
- package/dist/api/modules/config.d.ts +70 -0
- package/dist/api/modules/config.js +206 -0
- package/dist/api/modules/console.d.ts +305 -0
- package/dist/api/modules/console.js +598 -0
- package/dist/api/modules/cooldown.d.ts +138 -0
- package/dist/api/modules/cooldown.js +359 -0
- package/dist/api/modules/database.d.ts +135 -0
- package/dist/api/modules/database.js +271 -0
- package/dist/api/modules/event.d.ts +43 -0
- package/dist/api/modules/event.js +100 -0
- package/dist/api/modules/flag.d.ts +40 -0
- package/dist/api/modules/flag.js +72 -0
- package/dist/api/modules/fuse.d.ts +218 -0
- package/dist/api/modules/fuse.js +123 -0
- package/dist/api/modules/helpmenu.d.ts +106 -0
- package/dist/api/modules/helpmenu.js +167 -0
- package/dist/api/modules/language.d.ts +85 -0
- package/dist/api/modules/language.js +195 -0
- package/dist/api/modules/permission.d.ts +121 -0
- package/dist/api/modules/permission.js +314 -0
- package/dist/api/modules/plugin.d.ts +128 -0
- package/dist/api/modules/plugin.js +168 -0
- package/dist/api/modules/post.d.ts +44 -0
- package/dist/api/modules/post.js +92 -0
- package/dist/api/modules/progressbar.d.ts +108 -0
- package/dist/api/modules/progressbar.js +233 -0
- package/dist/api/modules/responder.d.ts +506 -0
- package/dist/api/modules/responder.js +1468 -0
- package/dist/api/modules/session.d.ts +58 -0
- package/dist/api/modules/session.js +171 -0
- package/dist/api/modules/startscreen.d.ts +165 -0
- package/dist/api/modules/startscreen.js +293 -0
- package/dist/api/modules/stat.d.ts +142 -0
- package/dist/api/modules/stat.js +293 -0
- package/dist/api/modules/verifybar.d.ts +54 -0
- package/dist/api/modules/verifybar.js +60 -0
- package/dist/api/modules/worker.d.ts +41 -0
- package/dist/api/modules/worker.js +93 -0
- package/dist/api/utils.d.ts +61 -0
- package/dist/api/utils.js +254 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +40 -0
- package/dist/startup/dump.d.ts +14 -0
- package/dist/startup/dump.js +79 -0
- package/dist/startup/errorHandling.d.ts +2 -0
- package/dist/startup/errorHandling.js +43 -0
- package/dist/startup/pluginLauncher.d.ts +2 -0
- package/dist/startup/pluginLauncher.js +202 -0
- package/package.json +9 -3
- package/src/api/api.ts +29 -0
- package/src/api/main.ts +189 -0
- package/src/api/modules/action.ts +58 -0
- package/src/api/modules/base.ts +811 -0
- package/src/api/modules/builder.ts +1554 -0
- package/src/api/modules/checker.ts +1549 -0
- package/src/api/modules/client.ts +2247 -0
- package/src/api/modules/code.ts +58 -0
- package/src/api/modules/config.ts +159 -0
- package/src/api/modules/console.ts +665 -0
- package/src/api/modules/cooldown.ts +348 -0
- package/src/api/modules/database.ts +278 -0
- package/src/api/modules/event.ts +99 -0
- package/src/api/modules/flag.ts +73 -0
- package/src/api/modules/fuse.ts +348 -0
- package/src/api/modules/helpmenu.ts +216 -0
- package/src/api/modules/language.ts +201 -0
- package/src/api/modules/permission.ts +340 -0
- package/src/api/modules/plugin.ts +242 -0
- package/src/api/modules/post.ts +90 -0
- package/src/api/modules/progressbar.ts +232 -0
- package/src/api/modules/responder.ts +1420 -0
- package/src/api/modules/session.ts +155 -0
- package/src/api/modules/startscreen.ts +320 -0
- package/src/api/modules/stat.ts +313 -0
- package/src/api/modules/verifybar.ts +61 -0
- package/src/api/modules/worker.ts +93 -0
- package/src/api/utils.ts +206 -0
- package/src/cli/cli.ts +151 -0
- package/src/cli/editConfig.ts +943 -0
- package/src/index.ts +6 -1
- package/src/startup/compilation.ts +186 -0
- package/src/startup/dump.ts +45 -0
- package/src/startup/errorHandling.ts +38 -0
- package/src/startup/pluginLauncher.ts +261 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
import { ODManager, ODManagerData, ODValidId } from "./base";
|
|
2
|
+
import * as discord from "discord.js";
|
|
3
|
+
import { ODDebugger } from "./console";
|
|
4
|
+
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder";
|
|
5
|
+
import { ODManualProgressBar } from "./progressbar";
|
|
6
|
+
/**## ODClientIntents `type`
|
|
7
|
+
* A list of intents required when inviting the bot.
|
|
8
|
+
*/
|
|
9
|
+
export type ODClientIntents = ("Guilds" | "GuildMembers" | "GuildModeration" | "GuildEmojisAndStickers" | "GuildIntegrations" | "GuildWebhooks" | "GuildInvites" | "GuildVoiceStates" | "GuildPresences" | "GuildMessages" | "GuildMessageReactions" | "GuildMessageTyping" | "DirectMessages" | "DirectMessageReactions" | "DirectMessageTyping" | "MessageContent" | "GuildScheduledEvents" | "AutoModerationConfiguration" | "AutoModerationExecution");
|
|
10
|
+
/**## ODClientPriviligedIntents `type`
|
|
11
|
+
* A list of priviliged intents required to be enabled in the developer portal.
|
|
12
|
+
*/
|
|
13
|
+
export type ODClientPriviligedIntents = ("GuildMembers" | "MessageContent" | "Presence");
|
|
14
|
+
/**## ODClientPartials `type`
|
|
15
|
+
* A list of partials required for the bot to work. (`Message` & `Channel` are for receiving DM messages from uncached channels)
|
|
16
|
+
*/
|
|
17
|
+
export type ODClientPartials = ("User" | "Channel" | "GuildMember" | "Message" | "Reaction" | "GuildScheduledEvent" | "ThreadMember");
|
|
18
|
+
/**## ODClientPermissions `type`
|
|
19
|
+
* A list of permissions required in the server that the bot is active in.
|
|
20
|
+
*/
|
|
21
|
+
export type ODClientPermissions = ("CreateInstantInvite" | "KickMembers" | "BanMembers" | "Administrator" | "ManageChannels" | "ManageGuild" | "AddReactions" | "ViewAuditLog" | "PrioritySpeaker" | "Stream" | "ViewChannel" | "SendMessages" | "SendTTSMessages" | "ManageMessages" | "EmbedLinks" | "AttachFiles" | "ReadMessageHistory" | "MentionEveryone" | "UseExternalEmojis" | "ViewGuildInsights" | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers" | "MoveMembers" | "UseVAD" | "ChangeNickname" | "ManageNicknames" | "ManageRoles" | "ManageWebhooks" | "ManageGuildExpressions" | "UseApplicationCommands" | "RequestToSpeak" | "ManageEvents" | "ManageThreads" | "CreatePublicThreads" | "CreatePrivateThreads" | "UseExternalStickers" | "SendMessagesInThreads" | "UseEmbeddedActivities" | "ModerateMembers" | "ViewCreatorMonetizationAnalytics" | "UseSoundboard" | "UseExternalSounds" | "SendVoiceMessages");
|
|
22
|
+
/**## ODClientManager `class`
|
|
23
|
+
* This is an Open Discord client manager.
|
|
24
|
+
*
|
|
25
|
+
* It is responsible for managing the discord.js client. Here, you can set the status, register slash commands and much more!
|
|
26
|
+
*
|
|
27
|
+
* If you want, you can also listen for custom events on the `ODClientManager.client` variable (`discord.Client`)
|
|
28
|
+
*/
|
|
29
|
+
export declare class ODClientManager {
|
|
30
|
+
#private;
|
|
31
|
+
/**List of required bot intents. Add intents to this list using the `onClientLoad` event. */
|
|
32
|
+
intents: ODClientIntents[];
|
|
33
|
+
/**List of required bot privileged intents. Add intents to this list using the `onClientLoad` event. */
|
|
34
|
+
privileges: ODClientPriviligedIntents[];
|
|
35
|
+
/**List of required bot partials. Add intents to this list using the `onClientLoad` event. **❌ Only use when neccessery!** */
|
|
36
|
+
partials: ODClientPartials[];
|
|
37
|
+
/**List of required bot permissions. Add permissions to this list using the `onClientLoad` event. */
|
|
38
|
+
permissions: ODClientPermissions[];
|
|
39
|
+
/**The discord bot token, empty by default. */
|
|
40
|
+
set token(value: string);
|
|
41
|
+
get token(): string;
|
|
42
|
+
/**The discord.js `discord.Client`. Only use it when initiated! */
|
|
43
|
+
client: discord.Client<true>;
|
|
44
|
+
/**The discord.js REST client. Used for stuff that discord.js can't handle :) */
|
|
45
|
+
rest: discord.REST;
|
|
46
|
+
/**Is the bot initiated? */
|
|
47
|
+
initiated: boolean;
|
|
48
|
+
/**Is the bot logged in? */
|
|
49
|
+
loggedIn: boolean;
|
|
50
|
+
/**Is the bot ready? */
|
|
51
|
+
ready: boolean;
|
|
52
|
+
/**The main server of the bot. Provided by serverId in the config */
|
|
53
|
+
mainServer: discord.Guild | null;
|
|
54
|
+
/**(❌ DO NOT OVERWRITE ❌) Internal Open Discord function to continue the startup when the client is ready! */
|
|
55
|
+
readyListener: (() => Promise<void>) | null;
|
|
56
|
+
/**The status manager is responsible for setting the bot status. */
|
|
57
|
+
activity: ODClientActivityManager;
|
|
58
|
+
/**The slash command manager is responsible for all slash commands & their events inside the bot. */
|
|
59
|
+
slashCommands: ODSlashCommandManager;
|
|
60
|
+
/**The text command manager is responsible for all text commands & their events inside the bot. */
|
|
61
|
+
textCommands: ODTextCommandManager;
|
|
62
|
+
/**The context menu manager is responsible for all context menus & their events inside the bot. */
|
|
63
|
+
contextMenus: ODContextMenuManager;
|
|
64
|
+
/**The autocomplete manager is responsible for all autocomplete events inside the bot. */
|
|
65
|
+
autocompletes: ODAutocompleteManager;
|
|
66
|
+
constructor(debug: ODDebugger);
|
|
67
|
+
/**Initiate the `client` variable & add the intents & partials to the bot. */
|
|
68
|
+
initClient(): void;
|
|
69
|
+
/**Get all servers the bot is part of. */
|
|
70
|
+
getGuilds(): Promise<discord.Guild[]>;
|
|
71
|
+
/**Check if the bot is in a specific guild */
|
|
72
|
+
checkBotInGuild(guild: discord.Guild): boolean;
|
|
73
|
+
/**Check if a specific guild has all required permissions (or `Administrator`) */
|
|
74
|
+
checkGuildPerms(guild: discord.Guild): boolean;
|
|
75
|
+
/**Log-in with a discord auth token. Rejects returns `false` using 'softErrors' on failure. */
|
|
76
|
+
login(softErrors?: boolean): Promise<boolean>;
|
|
77
|
+
/**A simplified shortcut to get a `discord.User` :) */
|
|
78
|
+
fetchUser(id: string): Promise<discord.User | null>;
|
|
79
|
+
/**A simplified shortcut to get a `discord.Guild` :) */
|
|
80
|
+
fetchGuild(id: string): Promise<discord.Guild | null>;
|
|
81
|
+
/**A simplified shortcut to get a `discord.Channel` :) */
|
|
82
|
+
fetchChannel(id: string): Promise<discord.Channel | null>;
|
|
83
|
+
/**A simplified shortcut to get a `discord.GuildBasedChannel` :) */
|
|
84
|
+
fetchGuildChannel(guildId: string | discord.Guild, id: string): Promise<discord.GuildBasedChannel | null>;
|
|
85
|
+
/**A simplified shortcut to get a `discord.TextChannel` :) */
|
|
86
|
+
fetchGuildTextChannel(guildId: string | discord.Guild, id: string): Promise<discord.TextChannel | null>;
|
|
87
|
+
/**A simplified shortcut to get a `discord.CategoryChannel` :) */
|
|
88
|
+
fetchGuildCategoryChannel(guildId: string | discord.Guild, id: string): Promise<discord.CategoryChannel | null>;
|
|
89
|
+
/**A simplified shortcut to get a `discord.GuildMember` :) */
|
|
90
|
+
fetchGuildMember(guildId: string | discord.Guild, id: string): Promise<discord.GuildMember | null>;
|
|
91
|
+
/**A simplified shortcut to get a `discord.Role` :) */
|
|
92
|
+
fetchGuildRole(guildId: string | discord.Guild, id: string): Promise<discord.Role | null>;
|
|
93
|
+
/**A simplified shortcut to get a `discord.Message` :) */
|
|
94
|
+
fetchGuildChannelMessage(guildId: string | discord.Guild, channelId: string | discord.TextChannel, id: string): Promise<discord.Message<true> | null>;
|
|
95
|
+
fetchGuildChannelMessage(channelId: discord.TextChannel, id: string): Promise<discord.Message<true> | null>;
|
|
96
|
+
/**A simplified shortcut to send a DM to a user :) */
|
|
97
|
+
sendUserDm(user: string | discord.User, message: ODMessageBuildResult): Promise<ODMessageBuildSentResult<false>>;
|
|
98
|
+
}
|
|
99
|
+
/**## ODClientActivityType `type`
|
|
100
|
+
* Possible activity types for the bot.
|
|
101
|
+
*/
|
|
102
|
+
export type ODClientActivityType = ("playing" | "listening" | "watching" | "custom" | false);
|
|
103
|
+
/**## ODClientActivityMode `type`
|
|
104
|
+
* Possible activity statuses for the bot.
|
|
105
|
+
*/
|
|
106
|
+
export type ODClientActivityMode = ("online" | "invisible" | "idle" | "dnd");
|
|
107
|
+
/**## ODClientActivityManager `class`
|
|
108
|
+
* This is an Open Discord client activity manager.
|
|
109
|
+
*
|
|
110
|
+
* It's responsible for managing the client status. Here, you can set the activity & status of the bot.
|
|
111
|
+
*
|
|
112
|
+
* It also has a built-in refresh function, so the status will refresh every 10 minutes to keep it visible.
|
|
113
|
+
*/
|
|
114
|
+
export declare class ODClientActivityManager {
|
|
115
|
+
#private;
|
|
116
|
+
/**Copy of discord.js client */
|
|
117
|
+
manager: ODClientManager;
|
|
118
|
+
/**The current status type */
|
|
119
|
+
type: ODClientActivityType;
|
|
120
|
+
/**The current status text */
|
|
121
|
+
text: string;
|
|
122
|
+
/**The current status mode */
|
|
123
|
+
mode: ODClientActivityMode;
|
|
124
|
+
/**Additional state text */
|
|
125
|
+
state: string;
|
|
126
|
+
/**The timer responsible for refreshing the status. Stop it using `clearInterval(interval)` */
|
|
127
|
+
interval?: NodeJS.Timeout;
|
|
128
|
+
/**status refresh interval in seconds (5 minutes by default)*/
|
|
129
|
+
refreshInterval: number;
|
|
130
|
+
/**Is the status already initiated? */
|
|
131
|
+
initiated: boolean;
|
|
132
|
+
constructor(debug: ODDebugger, manager: ODClientManager);
|
|
133
|
+
/**Update the status. When already initiated, it can take up to 10min to see the updated status in discord. */
|
|
134
|
+
setStatus(type: ODClientActivityType, text: string, mode: ODClientActivityMode, state: string, forceUpdate?: boolean): void;
|
|
135
|
+
/**When initiating the status, the bot starts updating the status using `discord.js`. Returns `true` when successfull. */
|
|
136
|
+
initStatus(): boolean;
|
|
137
|
+
/**Get the status type (for displaying the status) */
|
|
138
|
+
getStatusType(): "listening " | "playing " | "watching " | "";
|
|
139
|
+
}
|
|
140
|
+
/**## ODSlashCommandUniversalTranslation `interface`
|
|
141
|
+
* A universal template for a slash command translation. (used in names & descriptions)
|
|
142
|
+
*
|
|
143
|
+
* Why universal? Both **existing slash commands** & **unregistered templates** can be converted to this type.
|
|
144
|
+
*/
|
|
145
|
+
export interface ODSlashCommandUniversalTranslation {
|
|
146
|
+
/**The language code or locale of this language. */
|
|
147
|
+
language: `${discord.Locale}`;
|
|
148
|
+
/**The translation of the name in this language. */
|
|
149
|
+
value: string;
|
|
150
|
+
}
|
|
151
|
+
/**## ODSlashCommandUniversalOptionChoice `interface`
|
|
152
|
+
* A universal template for a slash command option choice. (used in `string` options)
|
|
153
|
+
*
|
|
154
|
+
* Why universal? Both **existing slash commands** & **unregistered templates** can be converted to this type.
|
|
155
|
+
*/
|
|
156
|
+
export interface ODSlashCommandUniversalOptionChoice {
|
|
157
|
+
/**The name of this choice. */
|
|
158
|
+
name: string;
|
|
159
|
+
/**All localized names of this choice. */
|
|
160
|
+
nameLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
161
|
+
/**The value of this choice. */
|
|
162
|
+
value: string;
|
|
163
|
+
}
|
|
164
|
+
/**## ODSlashCommandUniversalOption `interface`
|
|
165
|
+
* A universal template for a slash command option.
|
|
166
|
+
*
|
|
167
|
+
* Why universal? Both **existing slash commands** & **unregistered templates** can be converted to this type.
|
|
168
|
+
*/
|
|
169
|
+
export interface ODSlashCommandUniversalOption {
|
|
170
|
+
/**The type of this option. */
|
|
171
|
+
type: discord.ApplicationCommandOptionType;
|
|
172
|
+
/**The name of this option. */
|
|
173
|
+
name: string;
|
|
174
|
+
/**All localized names of this option. */
|
|
175
|
+
nameLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
176
|
+
/**The description of this option. */
|
|
177
|
+
description: string;
|
|
178
|
+
/**All localized descriptions of this option. */
|
|
179
|
+
descriptionLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
180
|
+
/**Is this option required? */
|
|
181
|
+
required: boolean;
|
|
182
|
+
/**Is autocomplete enabled in this option? */
|
|
183
|
+
autocomplete: boolean | null;
|
|
184
|
+
/**Choices for this option (only when type is `string`) */
|
|
185
|
+
choices: ODSlashCommandUniversalOptionChoice[];
|
|
186
|
+
/**A list of sub-options for this option (only when type is `subCommand` or `subCommandGroup`) */
|
|
187
|
+
options: readonly ODSlashCommandUniversalOption[];
|
|
188
|
+
/**A list of allowed channel types for this option (only when type is `channel`) */
|
|
189
|
+
channelTypes: readonly discord.ChannelType[];
|
|
190
|
+
/**The minimum amount required for this option (only when type is `number` or `integer`) */
|
|
191
|
+
minValue: number | null;
|
|
192
|
+
/**The maximum amount required for this option (only when type is `number` or `integer`) */
|
|
193
|
+
maxValue: number | null;
|
|
194
|
+
/**The minimum length required for this option (only when type is `string`) */
|
|
195
|
+
minLength: number | null;
|
|
196
|
+
/**The maximum length required for this option (only when type is `string`) */
|
|
197
|
+
maxLength: number | null;
|
|
198
|
+
}
|
|
199
|
+
/**## ODSlashCommandUniversalCommand `interface`
|
|
200
|
+
* A universal template for a slash command.
|
|
201
|
+
*
|
|
202
|
+
* Why universal? Both **existing slash commands** & **unregistered templates** can be converted to this type.
|
|
203
|
+
*/
|
|
204
|
+
export interface ODSlashCommandUniversalCommand {
|
|
205
|
+
/**The type of this command. (required => `ChatInput`) */
|
|
206
|
+
type: discord.ApplicationCommandType.ChatInput;
|
|
207
|
+
/**The name of this command. */
|
|
208
|
+
name: string;
|
|
209
|
+
/**All localized names of this command. */
|
|
210
|
+
nameLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
211
|
+
/**The description of this command. */
|
|
212
|
+
description: string;
|
|
213
|
+
/**All localized descriptions of this command. */
|
|
214
|
+
descriptionLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
215
|
+
/**The id of the guild this command is registered in. */
|
|
216
|
+
guildId: string | null;
|
|
217
|
+
/**Is this command for 18+ users only? */
|
|
218
|
+
nsfw: boolean;
|
|
219
|
+
/**A list of options for this command. */
|
|
220
|
+
options: readonly ODSlashCommandUniversalOption[];
|
|
221
|
+
/**A bitfield of the user permissions required to use this command. */
|
|
222
|
+
defaultMemberPermissions: bigint;
|
|
223
|
+
/**Is this command available in DM? */
|
|
224
|
+
dmPermission: boolean;
|
|
225
|
+
/**A list of contexts where you can install this command. */
|
|
226
|
+
integrationTypes: readonly discord.ApplicationIntegrationType[];
|
|
227
|
+
/**A list of contexts where you can use this command. */
|
|
228
|
+
contexts: readonly discord.InteractionContextType[];
|
|
229
|
+
}
|
|
230
|
+
/**## ODSlashCommandBuilder `interface`
|
|
231
|
+
* The builder for slash commands. Here you can add options to the command.
|
|
232
|
+
*/
|
|
233
|
+
export interface ODSlashCommandBuilder extends discord.ChatInputApplicationCommandData {
|
|
234
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
235
|
+
integrationTypes: discord.ApplicationIntegrationType[];
|
|
236
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
237
|
+
contexts: discord.InteractionContextType[];
|
|
238
|
+
}
|
|
239
|
+
/**## ODSlashCommandComparator `class`
|
|
240
|
+
* A utility class to compare existing slash commands with newly registered ones.
|
|
241
|
+
*/
|
|
242
|
+
export declare class ODSlashCommandComparator {
|
|
243
|
+
#private;
|
|
244
|
+
/**Convert a `ODSlashCommandBuilder` to a universal Open Discord slash command object for comparison. */
|
|
245
|
+
convertBuilder(builder: ODSlashCommandBuilder, guildId: string | null): ODSlashCommandUniversalCommand | null;
|
|
246
|
+
/**Convert a `discord.ApplicationCommand` to a universal Open Discord slash command object for comparison. */
|
|
247
|
+
convertCommand(cmd: discord.ApplicationCommand): ODSlashCommandUniversalCommand | null;
|
|
248
|
+
/**Returns `true` when the 2 slash command options are the same. */
|
|
249
|
+
compareOption(optA: ODSlashCommandUniversalOption, optB: ODSlashCommandUniversalOption): boolean;
|
|
250
|
+
/**Returns `true` when the 2 slash commands are the same. */
|
|
251
|
+
compare(cmdA: ODSlashCommandUniversalCommand, cmdB: ODSlashCommandUniversalCommand): boolean;
|
|
252
|
+
}
|
|
253
|
+
/**## ODSlashCommandInteractionCallback `type`
|
|
254
|
+
* Callback for the slash command interaction listener.
|
|
255
|
+
*/
|
|
256
|
+
export type ODSlashCommandInteractionCallback = (interaction: discord.ChatInputCommandInteraction, cmd: ODSlashCommand) => void;
|
|
257
|
+
/**## ODSlashCommandRegisteredResult `type`
|
|
258
|
+
* The result which will be returned when getting all (un)registered slash commands from the manager.
|
|
259
|
+
*/
|
|
260
|
+
export type ODSlashCommandRegisteredResult = {
|
|
261
|
+
/**A list of all registered commands. */
|
|
262
|
+
registered: {
|
|
263
|
+
/**The instance (`ODSlashCommand`) from this command. */
|
|
264
|
+
instance: ODSlashCommand;
|
|
265
|
+
/**The (universal) slash command object/template of this command. */
|
|
266
|
+
cmd: ODSlashCommandUniversalCommand;
|
|
267
|
+
/**Does this command require an update? */
|
|
268
|
+
requiresUpdate: boolean;
|
|
269
|
+
}[];
|
|
270
|
+
/**A list of all unregistered commands. */
|
|
271
|
+
unregistered: {
|
|
272
|
+
/**The instance (`ODSlashCommand`) from this command. */
|
|
273
|
+
instance: ODSlashCommand;
|
|
274
|
+
/**The (universal) slash command object/template of this command. */
|
|
275
|
+
cmd: null;
|
|
276
|
+
/**Does this command require an update? */
|
|
277
|
+
requiresUpdate: true;
|
|
278
|
+
}[];
|
|
279
|
+
/**A list of all unused commands (not found in `ODSlashCommandManager`). */
|
|
280
|
+
unused: {
|
|
281
|
+
/**The instance (`ODSlashCommand`) from this command. */
|
|
282
|
+
instance: null;
|
|
283
|
+
/**The (universal) slash command object/template of this command. */
|
|
284
|
+
cmd: ODSlashCommandUniversalCommand;
|
|
285
|
+
/**Does this command require an update? */
|
|
286
|
+
requiresUpdate: false;
|
|
287
|
+
}[];
|
|
288
|
+
};
|
|
289
|
+
/**## ODSlashCommandManager `class`
|
|
290
|
+
* This is an Open Discord client slash manager.
|
|
291
|
+
*
|
|
292
|
+
* It's responsible for managing all the slash commands from the client.
|
|
293
|
+
*
|
|
294
|
+
* Here, you can add & remove slash commands & the bot will do the (de)registering.
|
|
295
|
+
*/
|
|
296
|
+
export declare class ODSlashCommandManager extends ODManager<ODSlashCommand> {
|
|
297
|
+
#private;
|
|
298
|
+
/**Refrerence to discord.js client. */
|
|
299
|
+
manager: ODClientManager;
|
|
300
|
+
/**Discord.js application commands manager. */
|
|
301
|
+
commandManager: discord.ApplicationCommandManager | null;
|
|
302
|
+
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
303
|
+
listenerLimit: number;
|
|
304
|
+
/**A utility class used to compare 2 slash commands with each other. */
|
|
305
|
+
comparator: ODSlashCommandComparator;
|
|
306
|
+
constructor(debug: ODDebugger, manager: ODClientManager);
|
|
307
|
+
/**Get all registered & unregistered slash commands. */
|
|
308
|
+
getAllRegisteredCommands(guildId?: string): Promise<ODSlashCommandRegisteredResult>;
|
|
309
|
+
/**Create all commands that are not registered yet.*/
|
|
310
|
+
createNewCommands(instances: ODSlashCommand[], progress?: ODManualProgressBar): Promise<void>;
|
|
311
|
+
/**Update all commands that are already registered. */
|
|
312
|
+
updateExistingCommands(instances: ODSlashCommand[], progress?: ODManualProgressBar): Promise<void>;
|
|
313
|
+
/**Remove all commands that are registered but unused by Open Discord. */
|
|
314
|
+
removeUnusedCommands(instances: ODSlashCommandUniversalCommand[], guildId?: string, progress?: ODManualProgressBar): Promise<void>;
|
|
315
|
+
/**Create a slash command. **(SYSTEM ONLY)** => Use `ODSlashCommandManager` for registering commands the default way! */
|
|
316
|
+
createCmd(cmd: ODSlashCommand): Promise<void>;
|
|
317
|
+
/**Start listening to the discord.js client `interactionCreate` event. */
|
|
318
|
+
startListeningToInteractions(): void;
|
|
319
|
+
/**Callback on interaction from one or multiple slash commands. */
|
|
320
|
+
onInteraction(commandName: string | RegExp, callback: ODSlashCommandInteractionCallback): void;
|
|
321
|
+
}
|
|
322
|
+
/**## ODSlashCommandUpdateFunction `type`
|
|
323
|
+
* The function responsible for updating slash commands when they already exist.
|
|
324
|
+
*/
|
|
325
|
+
export type ODSlashCommandUpdateFunction = (command: ODSlashCommandUniversalCommand) => boolean;
|
|
326
|
+
/**## ODSlashCommand `class`
|
|
327
|
+
* This is an Open Discord slash command.
|
|
328
|
+
*
|
|
329
|
+
* When registered, you can listen for this command using the `ODCommandResponder`. The advantages of using this class for creating a slash command are:
|
|
330
|
+
* - automatic option parsing (even for channels, users, roles & mentions)!
|
|
331
|
+
* - automatic registration in discord.js
|
|
332
|
+
* - error reporting to the user when the bot fails to respond
|
|
333
|
+
* - plugins can extend this command
|
|
334
|
+
* - the bot won't re-register the command when it already exists (except when requested)!
|
|
335
|
+
*
|
|
336
|
+
* And more!
|
|
337
|
+
*/
|
|
338
|
+
export declare class ODSlashCommand extends ODManagerData {
|
|
339
|
+
/**The discord.js builder for this slash command. */
|
|
340
|
+
builder: ODSlashCommandBuilder;
|
|
341
|
+
/**The id of the guild this command is for. Null when not set. */
|
|
342
|
+
guildId: string | null;
|
|
343
|
+
/**Function to check if the slash command requires to be updated (when it already exists). */
|
|
344
|
+
requiresUpdate: ODSlashCommandUpdateFunction | null;
|
|
345
|
+
constructor(id: ODValidId, builder: ODSlashCommandBuilder, requiresUpdate?: ODSlashCommandUpdateFunction, guildId?: string);
|
|
346
|
+
/**The name of this slash command. */
|
|
347
|
+
get name(): string;
|
|
348
|
+
set name(name: string);
|
|
349
|
+
}
|
|
350
|
+
/**## ODTextCommandBuilderBaseOptionType `type`
|
|
351
|
+
* The types available in the text command option builder.
|
|
352
|
+
*/
|
|
353
|
+
export type ODTextCommandBuilderBaseOptionType = "string" | "number" | "boolean" | "user" | "guildmember" | "role" | "mentionable" | "channel";
|
|
354
|
+
/**## ODTextCommandBuilderBaseOption `interface`
|
|
355
|
+
* The default option builder for text commands.
|
|
356
|
+
*/
|
|
357
|
+
export interface ODTextCommandBuilderBaseOption {
|
|
358
|
+
/**The name of this option */
|
|
359
|
+
name: string;
|
|
360
|
+
/**The type of this option */
|
|
361
|
+
type: ODTextCommandBuilderBaseOptionType;
|
|
362
|
+
/**Is this option required? (optional options can only exist at the end of the command!) */
|
|
363
|
+
required?: boolean;
|
|
364
|
+
}
|
|
365
|
+
/**## ODTextCommandBuilderStringOption `interface`
|
|
366
|
+
* The string option builder for text commands.
|
|
367
|
+
*/
|
|
368
|
+
export interface ODTextCommandBuilderStringOption extends ODTextCommandBuilderBaseOption {
|
|
369
|
+
type: "string";
|
|
370
|
+
/**Set the maximum length of this string */
|
|
371
|
+
maxLength?: number;
|
|
372
|
+
/**Set the minimum length of this string */
|
|
373
|
+
minLength?: number;
|
|
374
|
+
/**The string needs to match this regex or it will be invalid */
|
|
375
|
+
regex?: RegExp;
|
|
376
|
+
/**The string needs to match one of these choices or it will be invalid */
|
|
377
|
+
choices?: string[];
|
|
378
|
+
/**When this is the last option, allow this string to contain spaces */
|
|
379
|
+
allowSpaces?: boolean;
|
|
380
|
+
}
|
|
381
|
+
/**## ODTextCommandBuilderNumberOption `interface`
|
|
382
|
+
* The number option builder for text commands.
|
|
383
|
+
*/
|
|
384
|
+
export interface ODTextCommandBuilderNumberOption extends ODTextCommandBuilderBaseOption {
|
|
385
|
+
type: "number";
|
|
386
|
+
/**The number can't be higher than this value */
|
|
387
|
+
max?: number;
|
|
388
|
+
/**The number can't be lower than this value */
|
|
389
|
+
min?: number;
|
|
390
|
+
/**Allow the number to be negative */
|
|
391
|
+
allowNegative?: boolean;
|
|
392
|
+
/**Allow the number to be positive */
|
|
393
|
+
allowPositive?: boolean;
|
|
394
|
+
/**Allow the number to be zero */
|
|
395
|
+
allowZero?: boolean;
|
|
396
|
+
/**Allow a number with decimal */
|
|
397
|
+
allowDecimal?: boolean;
|
|
398
|
+
}
|
|
399
|
+
/**## ODTextCommandBuilderBooleanOption `interface`
|
|
400
|
+
* The boolean option builder for text commands.
|
|
401
|
+
*/
|
|
402
|
+
export interface ODTextCommandBuilderBooleanOption extends ODTextCommandBuilderBaseOption {
|
|
403
|
+
type: "boolean";
|
|
404
|
+
/**The value when `true` */
|
|
405
|
+
trueValue?: string;
|
|
406
|
+
/**The value when `false` */
|
|
407
|
+
falseValue?: string;
|
|
408
|
+
}
|
|
409
|
+
/**## ODTextCommandBuilderChannelOption `interface`
|
|
410
|
+
* The channel option builder for text commands.
|
|
411
|
+
*/
|
|
412
|
+
export interface ODTextCommandBuilderChannelOption extends ODTextCommandBuilderBaseOption {
|
|
413
|
+
type: "channel";
|
|
414
|
+
/**When specified, only allow the following channel types */
|
|
415
|
+
channelTypes?: discord.GuildChannelType[];
|
|
416
|
+
}
|
|
417
|
+
/**## ODTextCommandBuilderRoleOption `interface`
|
|
418
|
+
* The role option builder for text commands.
|
|
419
|
+
*/
|
|
420
|
+
export interface ODTextCommandBuilderRoleOption extends ODTextCommandBuilderBaseOption {
|
|
421
|
+
type: "role";
|
|
422
|
+
}
|
|
423
|
+
/**## ODTextCommandBuilderUserOption `interface`
|
|
424
|
+
* The user option builder for text commands.
|
|
425
|
+
*/
|
|
426
|
+
export interface ODTextCommandBuilderUserOption extends ODTextCommandBuilderBaseOption {
|
|
427
|
+
type: "user";
|
|
428
|
+
}
|
|
429
|
+
/**## ODTextCommandBuilderGuildMemberOption `interface`
|
|
430
|
+
* The guild member option builder for text commands.
|
|
431
|
+
*/
|
|
432
|
+
export interface ODTextCommandBuilderGuildMemberOption extends ODTextCommandBuilderBaseOption {
|
|
433
|
+
type: "guildmember";
|
|
434
|
+
}
|
|
435
|
+
/**## ODTextCommandBuilderMentionableOption `interface`
|
|
436
|
+
* The mentionable option builder for text commands.
|
|
437
|
+
*/
|
|
438
|
+
export interface ODTextCommandBuilderMentionableOption extends ODTextCommandBuilderBaseOption {
|
|
439
|
+
type: "mentionable";
|
|
440
|
+
}
|
|
441
|
+
/**## ODTextCommandBuilderOption `type`
|
|
442
|
+
* The option builder for text commands.
|
|
443
|
+
*/
|
|
444
|
+
export type ODTextCommandBuilderOption = (ODTextCommandBuilderStringOption | ODTextCommandBuilderBooleanOption | ODTextCommandBuilderNumberOption | ODTextCommandBuilderChannelOption | ODTextCommandBuilderRoleOption | ODTextCommandBuilderUserOption | ODTextCommandBuilderGuildMemberOption | ODTextCommandBuilderMentionableOption);
|
|
445
|
+
/**## ODTextCommandBuilder `interface`
|
|
446
|
+
* The builder for text commands. Here you can add options to the command.
|
|
447
|
+
*/
|
|
448
|
+
export interface ODTextCommandBuilder {
|
|
449
|
+
/**The prefix of this command */
|
|
450
|
+
prefix: string;
|
|
451
|
+
/**The name of this command (can include spaces for subcommands) */
|
|
452
|
+
name: string;
|
|
453
|
+
/**Is this command allowed in dm? */
|
|
454
|
+
dmPermission?: boolean;
|
|
455
|
+
/**Is this command allowed in guilds? */
|
|
456
|
+
guildPermission?: boolean;
|
|
457
|
+
/**When specified, only allow this command to be executed in the following guilds */
|
|
458
|
+
allowedGuildIds?: string[];
|
|
459
|
+
/**Are bots allowed to execute this command? */
|
|
460
|
+
allowBots?: boolean;
|
|
461
|
+
/**The options for this text command (like slash commands) */
|
|
462
|
+
options?: ODTextCommandBuilderOption[];
|
|
463
|
+
}
|
|
464
|
+
/**## ODTextCommand `class`
|
|
465
|
+
* This is an Open Discord text command.
|
|
466
|
+
*
|
|
467
|
+
* When registered, you can listen for this command using the `ODCommandResponder`. The advantages of using this class for creating a text command are:
|
|
468
|
+
* - automatic option parsing (even for channels, users, roles & mentions)!
|
|
469
|
+
* - automatic errors on invalid parameters
|
|
470
|
+
* - error reporting to the user when the bot fails to respond
|
|
471
|
+
* - plugins can extend this command
|
|
472
|
+
*
|
|
473
|
+
* And more!
|
|
474
|
+
*/
|
|
475
|
+
export declare class ODTextCommand extends ODManagerData {
|
|
476
|
+
/**The builder for this slash command. */
|
|
477
|
+
builder: ODTextCommandBuilder;
|
|
478
|
+
/**The name of this slash command. */
|
|
479
|
+
name: string;
|
|
480
|
+
constructor(id: ODValidId, builder: ODTextCommandBuilder);
|
|
481
|
+
}
|
|
482
|
+
/**## ODTextCommandInteractionOptionBase `interface`
|
|
483
|
+
* The object returned for options from a text command interaction.
|
|
484
|
+
*/
|
|
485
|
+
export interface ODTextCommandInteractionOptionBase<Name, Type> {
|
|
486
|
+
/**The name of this option */
|
|
487
|
+
name: string;
|
|
488
|
+
/**The type of this option */
|
|
489
|
+
type: Name;
|
|
490
|
+
/**The value of this option */
|
|
491
|
+
value: Type;
|
|
492
|
+
}
|
|
493
|
+
/**## ODTextCommandInteractionOption `type`
|
|
494
|
+
* A list of types returned for options from a text command interaction.
|
|
495
|
+
*/
|
|
496
|
+
export type ODTextCommandInteractionOption = (ODTextCommandInteractionOptionBase<"string", string> | ODTextCommandInteractionOptionBase<"number", number> | ODTextCommandInteractionOptionBase<"boolean", boolean> | ODTextCommandInteractionOptionBase<"channel", discord.GuildBasedChannel> | ODTextCommandInteractionOptionBase<"role", discord.Role> | ODTextCommandInteractionOptionBase<"user", discord.User> | ODTextCommandInteractionOptionBase<"guildmember", discord.GuildMember> | ODTextCommandInteractionOptionBase<"mentionable", discord.Role | discord.User>);
|
|
497
|
+
/**## ODTextCommandInteractionCallback `type`
|
|
498
|
+
* Callback for the text command interaction listener.
|
|
499
|
+
*/
|
|
500
|
+
export type ODTextCommandInteractionCallback = (msg: discord.Message, cmd: ODTextCommand, options: ODTextCommandInteractionOption[]) => void;
|
|
501
|
+
/**## ODTextCommandErrorBase `interface`
|
|
502
|
+
* The object returned from a text command error callback.
|
|
503
|
+
*/
|
|
504
|
+
export interface ODTextCommandErrorBase {
|
|
505
|
+
/**The type of text command error */
|
|
506
|
+
type: "unknown_prefix" | "unknown_command" | "invalid_option" | "missing_option";
|
|
507
|
+
/**The message this error originates from */
|
|
508
|
+
msg: discord.Message;
|
|
509
|
+
}
|
|
510
|
+
/**## ODTextCommandErrorUnknownPrefix `interface`
|
|
511
|
+
* The object returned from a text command unknown prefix error callback.
|
|
512
|
+
*/
|
|
513
|
+
export interface ODTextCommandErrorUnknownPrefix extends ODTextCommandErrorBase {
|
|
514
|
+
type: "unknown_prefix";
|
|
515
|
+
}
|
|
516
|
+
/**## ODTextCommandErrorUnknownCommand `interface`
|
|
517
|
+
* The object returned from a text command unknown command error callback.
|
|
518
|
+
*/
|
|
519
|
+
export interface ODTextCommandErrorUnknownCommand extends ODTextCommandErrorBase {
|
|
520
|
+
type: "unknown_command";
|
|
521
|
+
}
|
|
522
|
+
/**## ODTextCommandErrorInvalidOptionReason `type`
|
|
523
|
+
* A list of reasons for the invalid_option error to be thrown.
|
|
524
|
+
*/
|
|
525
|
+
export type ODTextCommandErrorInvalidOptionReason = ("boolean" | "number_max" | "number_min" | "number_decimal" | "number_negative" | "number_positive" | "number_zero" | "number_invalid" | "string_max_length" | "string_min_length" | "string_regex" | "string_choice" | "not_in_guild" | "channel_not_found" | "channel_type" | "user_not_found" | "member_not_found" | "role_not_found" | "mentionable_not_found");
|
|
526
|
+
/**## ODTextCommandErrorInvalidOption `interface`
|
|
527
|
+
* The object returned from a text command invalid option error callback.
|
|
528
|
+
*/
|
|
529
|
+
export interface ODTextCommandErrorInvalidOption extends ODTextCommandErrorBase {
|
|
530
|
+
type: "invalid_option";
|
|
531
|
+
/**The command this error originates from */
|
|
532
|
+
command: ODTextCommand;
|
|
533
|
+
/**The command prefix this error originates from */
|
|
534
|
+
prefix: string;
|
|
535
|
+
/**The command name this error originates from (can include spaces for subcommands) */
|
|
536
|
+
name: string;
|
|
537
|
+
/**The option that this error originates from */
|
|
538
|
+
option: ODTextCommandBuilderOption;
|
|
539
|
+
/**The location that this option was found */
|
|
540
|
+
location: number;
|
|
541
|
+
/**The current value of this invalid option */
|
|
542
|
+
value: string;
|
|
543
|
+
/**The reason for this invalid option */
|
|
544
|
+
reason: ODTextCommandErrorInvalidOptionReason;
|
|
545
|
+
}
|
|
546
|
+
/**## ODTextCommandErrorMissingOption `interface`
|
|
547
|
+
* The object returned from a text command missing option error callback.
|
|
548
|
+
*/
|
|
549
|
+
export interface ODTextCommandErrorMissingOption extends ODTextCommandErrorBase {
|
|
550
|
+
type: "missing_option";
|
|
551
|
+
/**The command this error originates from */
|
|
552
|
+
command: ODTextCommand;
|
|
553
|
+
/**The command prefix this error originates from */
|
|
554
|
+
prefix: string;
|
|
555
|
+
/**The command name this error originates from (can include spaces for subcommands) */
|
|
556
|
+
name: string;
|
|
557
|
+
/**The option that this error originates from */
|
|
558
|
+
option: ODTextCommandBuilderOption;
|
|
559
|
+
/**The location that this option was found */
|
|
560
|
+
location: number;
|
|
561
|
+
}
|
|
562
|
+
/**## ODTextCommandError `type`
|
|
563
|
+
* A list of types returned for errors from a text command interaction.
|
|
564
|
+
*/
|
|
565
|
+
export type ODTextCommandError = (ODTextCommandErrorUnknownPrefix | ODTextCommandErrorUnknownCommand | ODTextCommandErrorInvalidOption | ODTextCommandErrorMissingOption);
|
|
566
|
+
/**## ODTextCommandErrorCallback `type`
|
|
567
|
+
* Callback for the text command error listener.
|
|
568
|
+
*/
|
|
569
|
+
export type ODTextCommandErrorCallback = (error: ODTextCommandError) => void;
|
|
570
|
+
/**## ODTextCommandManager `class`
|
|
571
|
+
* This is an Open Discord client text manager.
|
|
572
|
+
*
|
|
573
|
+
* It's responsible for managing all the text commands from the client.
|
|
574
|
+
*
|
|
575
|
+
* Here, you can add & remove text commands & the bot will do the (de)registering.
|
|
576
|
+
*/
|
|
577
|
+
export declare class ODTextCommandManager extends ODManager<ODTextCommand> {
|
|
578
|
+
#private;
|
|
579
|
+
/**Copy of discord.js client. */
|
|
580
|
+
manager: ODClientManager;
|
|
581
|
+
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
582
|
+
listenerLimit: number;
|
|
583
|
+
constructor(debug: ODDebugger, manager: ODClientManager);
|
|
584
|
+
/**Start listening to the discord.js client `messageCreate` event. */
|
|
585
|
+
startListeningToInteractions(): void;
|
|
586
|
+
/**Callback on interaction from one of the registered text commands */
|
|
587
|
+
onInteraction(commandPrefix: string, commandName: string | RegExp, callback: ODTextCommandInteractionCallback): void;
|
|
588
|
+
/**Callback on error from all the registered text commands */
|
|
589
|
+
onError(callback: ODTextCommandErrorCallback): void;
|
|
590
|
+
add(data: ODTextCommand, overwrite?: boolean): boolean;
|
|
591
|
+
}
|
|
592
|
+
/**## ODContextMenuUniversalMenu `interface`
|
|
593
|
+
* A universal template for a context menu.
|
|
594
|
+
*
|
|
595
|
+
* Why universal? Both **existing context menus** & **unregistered templates** can be converted to this type.
|
|
596
|
+
*/
|
|
597
|
+
export interface ODContextMenuUniversalMenu {
|
|
598
|
+
/**The type of this context menu. (required => `Message`|`User`) */
|
|
599
|
+
type: discord.ApplicationCommandType.Message | discord.ApplicationCommandType.User;
|
|
600
|
+
/**The name of this context menu. */
|
|
601
|
+
name: string;
|
|
602
|
+
/**All localized names of this context menu. */
|
|
603
|
+
nameLocalizations: readonly ODSlashCommandUniversalTranslation[];
|
|
604
|
+
/**The id of the guild this context menu is registered in. */
|
|
605
|
+
guildId: string | null;
|
|
606
|
+
/**Is this context menu for 18+ users only? */
|
|
607
|
+
nsfw: boolean;
|
|
608
|
+
/**A bitfield of the user permissions required to use this context menu. */
|
|
609
|
+
defaultMemberPermissions: bigint;
|
|
610
|
+
/**Is this context menu available in DM? */
|
|
611
|
+
dmPermission: boolean;
|
|
612
|
+
/**A list of contexts where you can install this context menu. */
|
|
613
|
+
integrationTypes: readonly discord.ApplicationIntegrationType[];
|
|
614
|
+
/**A list of contexts where you can use this context menu. */
|
|
615
|
+
contexts: readonly discord.InteractionContextType[];
|
|
616
|
+
}
|
|
617
|
+
/**## ODContextMenuBuilderMessage `interface`
|
|
618
|
+
* The builder for message context menus.
|
|
619
|
+
*/
|
|
620
|
+
export interface ODContextMenuBuilderMessage extends discord.MessageApplicationCommandData {
|
|
621
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
622
|
+
integrationTypes: discord.ApplicationIntegrationType[];
|
|
623
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
624
|
+
contexts: discord.InteractionContextType[];
|
|
625
|
+
}
|
|
626
|
+
/**## ODContextMenuBuilderUser `interface`
|
|
627
|
+
* The builder for user context menus.
|
|
628
|
+
*/
|
|
629
|
+
export interface ODContextMenuBuilderUser extends discord.UserApplicationCommandData {
|
|
630
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
631
|
+
integrationTypes: discord.ApplicationIntegrationType[];
|
|
632
|
+
/**This field is required in Open Discord for future compatibility. */
|
|
633
|
+
contexts: discord.InteractionContextType[];
|
|
634
|
+
}
|
|
635
|
+
/**## ODContextMenuBuilderUser `interface`
|
|
636
|
+
* The builder for context menus.
|
|
637
|
+
*/
|
|
638
|
+
export type ODContextMenuBuilder = (ODContextMenuBuilderMessage | ODContextMenuBuilderUser);
|
|
639
|
+
/**## ODContextMenuComparator `class`
|
|
640
|
+
* A utility class to compare existing context menu's with newly registered ones.
|
|
641
|
+
*/
|
|
642
|
+
export declare class ODContextMenuComparator {
|
|
643
|
+
/**Convert a `ODContextMenuBuilder` to a universal Open Discord context menu object for comparison. */
|
|
644
|
+
convertBuilder(builder: ODContextMenuBuilder, guildId: string | null): ODContextMenuUniversalMenu | null;
|
|
645
|
+
/**Convert a `discord.ApplicationCommand` to a universal Open Discord context menu object for comparison. */
|
|
646
|
+
convertMenu(cmd: discord.ApplicationCommand): ODContextMenuUniversalMenu | null;
|
|
647
|
+
/**Returns `true` when the 2 context menus are the same. */
|
|
648
|
+
compare(ctxA: ODContextMenuUniversalMenu, ctxB: ODContextMenuUniversalMenu): boolean;
|
|
649
|
+
}
|
|
650
|
+
/**## ODContextMenuInteractionCallback `type`
|
|
651
|
+
* Callback for the context menu interaction listener.
|
|
652
|
+
*/
|
|
653
|
+
export type ODContextMenuInteractionCallback = (interaction: discord.ContextMenuCommandInteraction, cmd: ODContextMenu) => void;
|
|
654
|
+
/**## ODContextMenuRegisteredResult `type`
|
|
655
|
+
* The result which will be returned when getting all (un)registered user context menu's from the manager.
|
|
656
|
+
*/
|
|
657
|
+
export type ODContextMenuRegisteredResult = {
|
|
658
|
+
/**A list of all registered context menus. */
|
|
659
|
+
registered: {
|
|
660
|
+
/**The instance (`ODContextMenu`) from this context menu. */
|
|
661
|
+
instance: ODContextMenu;
|
|
662
|
+
/**The universal object/template/builder of this context menu. */
|
|
663
|
+
menu: ODContextMenuUniversalMenu;
|
|
664
|
+
/**Does this context menu require an update? */
|
|
665
|
+
requiresUpdate: boolean;
|
|
666
|
+
}[];
|
|
667
|
+
/**A list of all unregistered context menus. */
|
|
668
|
+
unregistered: {
|
|
669
|
+
/**The instance (`ODContextMenu`) from this context menu. */
|
|
670
|
+
instance: ODContextMenu;
|
|
671
|
+
/**The universal object/template/builder of this context menu. */
|
|
672
|
+
menu: null;
|
|
673
|
+
/**Does this context menu require an update? */
|
|
674
|
+
requiresUpdate: true;
|
|
675
|
+
}[];
|
|
676
|
+
/**A list of all unused context menus (not found in `ODContextMenuManager`). */
|
|
677
|
+
unused: {
|
|
678
|
+
/**The instance (`ODContextMenu`) from this context menu. */
|
|
679
|
+
instance: null;
|
|
680
|
+
/**The universal object/template/builder of this context menu. */
|
|
681
|
+
menu: ODContextMenuUniversalMenu;
|
|
682
|
+
/**Does this context menu require an update? */
|
|
683
|
+
requiresUpdate: false;
|
|
684
|
+
}[];
|
|
685
|
+
};
|
|
686
|
+
/**## ODContextMenuManager `class`
|
|
687
|
+
* This is an Open Discord client context menu manager.
|
|
688
|
+
*
|
|
689
|
+
* It's responsible for managing all the context interactions from the client.
|
|
690
|
+
*
|
|
691
|
+
* Here, you can add & remove context interactions & the bot will do the (de)registering.
|
|
692
|
+
*/
|
|
693
|
+
export declare class ODContextMenuManager extends ODManager<ODContextMenu> {
|
|
694
|
+
#private;
|
|
695
|
+
/**Refrerence to discord.js client. */
|
|
696
|
+
manager: ODClientManager;
|
|
697
|
+
/**Discord.js application commands manager. */
|
|
698
|
+
commandManager: discord.ApplicationCommandManager | null;
|
|
699
|
+
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
700
|
+
listenerLimit: number;
|
|
701
|
+
/**A utility class used to compare 2 context menus with each other. */
|
|
702
|
+
comparator: ODContextMenuComparator;
|
|
703
|
+
constructor(debug: ODDebugger, manager: ODClientManager);
|
|
704
|
+
/**Get all registered & unregistered message context menu commands. */
|
|
705
|
+
getAllRegisteredMenus(guildId?: string): Promise<ODContextMenuRegisteredResult>;
|
|
706
|
+
/**Create all context menus that are not registered yet.*/
|
|
707
|
+
createNewMenus(instances: ODContextMenu[], progress?: ODManualProgressBar): Promise<void>;
|
|
708
|
+
/**Update all context menus that are already registered. */
|
|
709
|
+
updateExistingMenus(instances: ODContextMenu[], progress?: ODManualProgressBar): Promise<void>;
|
|
710
|
+
/**Remove all context menus that are registered but unused by Open Discord. */
|
|
711
|
+
removeUnusedMenus(instances: ODContextMenuUniversalMenu[], guildId?: string, progress?: ODManualProgressBar): Promise<void>;
|
|
712
|
+
/**Create a context menu. **(SYSTEM ONLY)** => Use `ODContextMenuManager` for registering context menu's the default way! */
|
|
713
|
+
createMenu(menu: ODContextMenu): Promise<void>;
|
|
714
|
+
/**Start listening to the discord.js client `interactionCreate` event. */
|
|
715
|
+
startListeningToInteractions(): void;
|
|
716
|
+
/**Callback on interaction from one or multiple context menu's. */
|
|
717
|
+
onInteraction(menuName: string | RegExp, callback: ODContextMenuInteractionCallback): void;
|
|
718
|
+
}
|
|
719
|
+
/**## ODContextMenuUpdateFunction `type`
|
|
720
|
+
* The function responsible for updating context menu's when they already exist.
|
|
721
|
+
*/
|
|
722
|
+
export type ODContextMenuUpdateFunction = (menu: ODContextMenuUniversalMenu) => boolean;
|
|
723
|
+
/**## ODContextMenu `class`
|
|
724
|
+
* This is an Open Discord context menu.
|
|
725
|
+
*
|
|
726
|
+
* When registered, you can listen for this context menu using the `ODContextResponder`. The advantages of using this class for creating a context menu are:
|
|
727
|
+
* - automatic registration in discord.js
|
|
728
|
+
* - error reporting to the user when the bot fails to respond
|
|
729
|
+
* - plugins can extend this context menu
|
|
730
|
+
* - the bot won't re-register the context menu when it already exists (except when requested)!
|
|
731
|
+
*
|
|
732
|
+
* And more!
|
|
733
|
+
*/
|
|
734
|
+
export declare class ODContextMenu extends ODManagerData {
|
|
735
|
+
/**The discord.js builder for this context menu. */
|
|
736
|
+
builder: ODContextMenuBuilder;
|
|
737
|
+
/**The id of the guild this context menu is for. `null` when not set. */
|
|
738
|
+
guildId: string | null;
|
|
739
|
+
/**Function to check if the context menu requires to be updated (when it already exists). */
|
|
740
|
+
requiresUpdate: ODContextMenuUpdateFunction | null;
|
|
741
|
+
constructor(id: ODValidId, builder: ODContextMenuBuilder, requiresUpdate?: ODContextMenuUpdateFunction, guildId?: string);
|
|
742
|
+
/**The name of this context menu. */
|
|
743
|
+
get name(): string;
|
|
744
|
+
set name(name: string);
|
|
745
|
+
}
|
|
746
|
+
/**## ODAutocompleteInteractionCallback `type`
|
|
747
|
+
* Callback for the autocomplete interaction listener.
|
|
748
|
+
*/
|
|
749
|
+
export type ODAutocompleteInteractionCallback = (interaction: discord.AutocompleteInteraction) => void;
|
|
750
|
+
/**## ODAutocompleteManager `class`
|
|
751
|
+
* This is an Open Discord client autocomplete interaction manager.
|
|
752
|
+
*
|
|
753
|
+
* It's responsible for managing all the autocomplete interactions from the client.
|
|
754
|
+
*/
|
|
755
|
+
export declare class ODAutocompleteManager {
|
|
756
|
+
#private;
|
|
757
|
+
/**Refrerence to discord.js client. */
|
|
758
|
+
manager: ODClientManager;
|
|
759
|
+
/**Discord.js application commands manager. */
|
|
760
|
+
commandManager: discord.ApplicationCommandManager | null;
|
|
761
|
+
/**Set the soft limit for maximum amount of listeners. A warning will be shown when there are more listeners than this limit. */
|
|
762
|
+
listenerLimit: number;
|
|
763
|
+
constructor(debug: ODDebugger, manager: ODClientManager);
|
|
764
|
+
/**Start listening to the discord.js client `interactionCreate` event. */
|
|
765
|
+
startListeningToInteractions(): void;
|
|
766
|
+
/**Callback on interaction from one or multiple autocompletes. */
|
|
767
|
+
onInteraction(cmdName: string | RegExp, optName: string | RegExp, callback: ODAutocompleteInteractionCallback): void;
|
|
768
|
+
}
|