vimcord 1.0.36 → 1.0.38
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/README.md +395 -47
- package/dist/index.cjs +1238 -1016
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +742 -411
- package/dist/index.d.ts +742 -411
- package/dist/index.js +1213 -1001
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { SlashCommandBuilder as SlashCommandBuilder$1, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandSubcommandGroupBuilder, PermissionResolvable,
|
|
3
|
-
import
|
|
4
|
-
import * as mongoose from 'mongoose';
|
|
5
|
-
import mongoose__default, { ClientSessionOptions, Connection, Schema, Model, SchemaDefinition, mongo, ClientSession, Require_id, RootFilterQuery, MongooseBaseQueryOptions, CreateOptions, Document, QueryOptions, ProjectionType, HydratedDocument, UpdateQuery, MongooseUpdateQueryOptions, PipelineStage, AggregateOptions, AnyBulkWriteOperation, MongooseBulkWriteOptions } from 'mongoose';
|
|
2
|
+
import { SlashCommandBuilder as SlashCommandBuilder$1, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandSubcommandGroupBuilder, PermissionResolvable, ChatInputCommandInteraction, Message, ContextMenuCommandInteraction, ContextMenuCommandBuilder, ClientEvents, ActivityType, Guild, CommandInteraction, ColorResolvable, ButtonComponentData, APIThumbnailComponent, ActionRowBuilder, MessageActionRowComponentBuilder, ContainerBuilder, BaseMessageOptions, StickerResolvable, PollData, InteractionReplyOptions, MessageMentionOptions, ReplyOptions, ForwardOptions, Client, TextBasedChannel, GuildMember, User, APIEmbedField, APIEmbed, EmbedBuilder, RepliableInteraction, DMChannel, TextChannel, NewsChannel, ThreadChannel, ClientOptions, MessageComponentType, InteractionCollector, MappedInteractionTypes, UserResolvable as UserResolvable$1, AwaitModalSubmitOptions, ModalSubmitInteraction, APIChannelSelectComponent, APIFileUploadComponent, APIMentionableSelectComponent, APITextInputComponent, APIStringSelectComponent, APIUserSelectComponent, APIRoleSelectComponent, APIModalInteractionResponseCallbackData, ModalBuilder, Interaction, InteractionDeferUpdateOptions, InteractionResponse, MessagePayload, AttachmentBuilder, SelectMenuComponentOptionData, StringSelectMenuOptionBuilder, StringSelectMenuInteraction, ButtonInteraction, MessageReaction, ButtonBuilder, StringSelectMenuBuilder, ReactionCollector, APIButtonComponent, ChannelType, PartialGroupDMChannel, PartialDMChannel, GuildBasedChannel, AnyThreadChannel, VoiceBasedChannel, CategoryChannel, Channel, Role, GuildTextBasedChannel } from 'discord.js';
|
|
3
|
+
import * as type_fest from 'type-fest';
|
|
6
4
|
import { PartialDeep } from 'type-fest';
|
|
7
5
|
import EventEmitter from 'node:events';
|
|
8
6
|
import { Loop } from 'qznt';
|
|
7
|
+
import * as mongoose from 'mongoose';
|
|
8
|
+
import mongoose__default, { ClientSessionOptions, Connection, QueryOptions, HydratedDocument, Require_id, Schema, Model, SchemaDefinition, mongo, ClientSession, RootFilterQuery, MongooseBaseQueryOptions, CreateOptions, Document, ProjectionType, UpdateQuery, MongooseUpdateQueryOptions, PipelineStage, AggregateOptions, AnyBulkWriteOperation, MongooseBulkWriteOptions } from 'mongoose';
|
|
9
|
+
import { DotenvConfigOptions } from 'dotenv';
|
|
9
10
|
import { Interface } from 'node:readline';
|
|
10
11
|
|
|
11
12
|
type AnySlashCommandBuilder = SlashCommandBuilder$1 | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandBuilder | SlashCommandSubcommandsOnlyBuilder | SlashCommandSubcommandGroupBuilder;
|
|
@@ -77,234 +78,68 @@ interface CommandPermissionResults {
|
|
|
77
78
|
blacklistedRole?: string;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
declare class MongoDatabase {
|
|
85
|
-
private static instances;
|
|
86
|
-
private static emitter;
|
|
87
|
-
readonly moduleName = "MongoDatabase";
|
|
88
|
-
readonly clientId: number;
|
|
89
|
-
readonly client: Vimcord;
|
|
90
|
-
readonly mongoose: mongoose__default.Mongoose;
|
|
91
|
-
private isConnecting;
|
|
92
|
-
/**
|
|
93
|
-
* Returns an instance of MongoDatabase.
|
|
94
|
-
* @param clientId [default: 0]
|
|
95
|
-
*/
|
|
96
|
-
static getInstance(clientId?: number | Vimcord): MongoDatabase | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Waits for a MongoDatabase instance to be ready. First waiting for the instance to initialize if it doesn't exist.
|
|
99
|
-
* @param clientId [default: 0]
|
|
100
|
-
* @param timeoutMs [default: 60000]
|
|
101
|
-
*/
|
|
102
|
-
static getReadyInstance(clientId?: number | Vimcord, timeoutMs?: number): Promise<MongoDatabase>;
|
|
103
|
-
/**
|
|
104
|
-
* Starts a new Mongo client session.
|
|
105
|
-
* @param options Options for the new session
|
|
106
|
-
* @param clientId [default: 0]
|
|
107
|
-
*/
|
|
108
|
-
static startSession(options?: ClientSessionOptions, clientId?: number | Vimcord): Promise<mongoose__default.mongo.ClientSession>;
|
|
109
|
-
constructor(client: Vimcord, options?: mongoose__default.MongooseOptions);
|
|
110
|
-
get connection(): Connection;
|
|
111
|
-
get isReady(): boolean;
|
|
112
|
-
waitForReady(): Promise<this>;
|
|
113
|
-
connect(uri?: string, connectionOptions?: mongoose__default.ConnectOptions, options?: MongoConnectionOptions): Promise<boolean>;
|
|
114
|
-
disconnect(): Promise<void>;
|
|
115
|
-
startSession(options?: ClientSessionOptions): Promise<mongoose__default.mongo.ClientSession>;
|
|
116
|
-
useTransaction(fn: (session: mongoose__default.ClientSession) => Promise<void>): Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
type DatabaseManager = MongoDatabase;
|
|
120
|
-
|
|
121
|
-
interface AppConfig {
|
|
122
|
-
devMode: boolean;
|
|
123
|
-
name: string;
|
|
124
|
-
appVersion: string;
|
|
125
|
-
/** Enable verbose console logs?
|
|
126
|
-
* @defaultValue false */
|
|
127
|
-
verbose: boolean;
|
|
128
|
-
/** Disable the vimcord client banner on startup
|
|
129
|
-
* @defaultValue false */
|
|
130
|
-
disableBanner: boolean;
|
|
131
|
-
/** Only auto import modules that end with these suffixes */
|
|
132
|
-
moduleSuffixes: {
|
|
133
|
-
/** @defaultValue slash */
|
|
134
|
-
slashCommand: "slash";
|
|
135
|
-
/** @defaultValue ctx */
|
|
136
|
-
contextCommand: "ctx";
|
|
137
|
-
/** @defaultValue prefix */
|
|
138
|
-
prefixCommand: "prefix";
|
|
139
|
-
/** @defaultValue event */
|
|
140
|
-
event: "event";
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
declare function createAppConfig(options?: PartialDeep<AppConfig>): AppConfig;
|
|
144
|
-
|
|
145
|
-
interface StaffConfig {
|
|
146
|
-
ownerId: string | null;
|
|
147
|
-
superUsers: string[];
|
|
148
|
-
superUserRoles: string[];
|
|
149
|
-
bypassers: {
|
|
150
|
-
commandName: string;
|
|
151
|
-
userIds: string[];
|
|
152
|
-
}[];
|
|
153
|
-
bypassesGuildAdmin: {
|
|
154
|
-
allBotStaff: boolean;
|
|
155
|
-
botOwner: boolean;
|
|
156
|
-
superUsers: boolean;
|
|
157
|
-
bypassers: boolean;
|
|
158
|
-
};
|
|
159
|
-
guild: {
|
|
160
|
-
id: string | null;
|
|
161
|
-
inviteUrl: string | null;
|
|
162
|
-
channels: Record<string, string>;
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
declare function createStaffConfig(options?: PartialDeep<StaffConfig>): StaffConfig;
|
|
166
|
-
|
|
167
|
-
interface SlashCommandConfig extends BaseCommandConfig<CommandType.Slash> {
|
|
168
|
-
}
|
|
169
|
-
declare function createSlashCommandConfig(options?: PartialDeep<SlashCommandConfig>): SlashCommandConfig;
|
|
170
|
-
|
|
171
|
-
interface PrefixCommandConfig extends BaseCommandConfig<CommandType.Prefix> {
|
|
172
|
-
/** @defaultValue ! */
|
|
173
|
-
defaultPrefix: string;
|
|
174
|
-
/** @defaultValue true */
|
|
175
|
-
allowMentionAsPrefix: boolean;
|
|
176
|
-
/** @defaultValue true */
|
|
177
|
-
allowCaseInsensitiveCommandNames: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* A custom resolver to fetch a guild-specific prefix.
|
|
180
|
-
* Returns a string (the prefix) or null/undefined to fallback to default.
|
|
181
|
-
*/
|
|
182
|
-
guildPrefixResolver?: (client: Vimcord, guildId: string) => Promise<string | null | undefined> | string | null | undefined;
|
|
183
|
-
}
|
|
184
|
-
declare function createPrefixCommandConfig(options?: PartialDeep<PrefixCommandConfig>): PrefixCommandConfig;
|
|
185
|
-
|
|
186
|
-
interface ContextCommandConfig extends BaseCommandConfig<CommandType.Context> {
|
|
187
|
-
}
|
|
188
|
-
declare function createContextCommandConfig(options?: PartialDeep<ContextCommandConfig>): ContextCommandConfig;
|
|
189
|
-
|
|
190
|
-
interface LoggerOptions {
|
|
191
|
-
colors?: Partial<typeof LOGGER_COLORS>;
|
|
192
|
-
prefix?: string | null;
|
|
193
|
-
prefixEmoji?: string | null;
|
|
194
|
-
minLevel?: LogLevel;
|
|
195
|
-
/** @defaultValue `true` */
|
|
196
|
-
showTimestamp?: boolean;
|
|
197
|
-
}
|
|
198
|
-
declare enum LogLevel {
|
|
199
|
-
DEBUG = 0,
|
|
200
|
-
INFO = 1,
|
|
201
|
-
SUCCESS = 2,
|
|
202
|
-
WARN = 3,
|
|
203
|
-
ERROR = 4
|
|
204
|
-
}
|
|
205
|
-
declare const LOGGER_COLORS: {
|
|
206
|
-
primary: string;
|
|
207
|
-
success: string;
|
|
208
|
-
warn: string;
|
|
209
|
-
danger: string;
|
|
210
|
-
muted: string;
|
|
211
|
-
text: string;
|
|
212
|
-
};
|
|
213
|
-
/** Reusable functions for using `console.log()`, but in 4k ultra HD retrocolor */
|
|
214
|
-
declare class Logger {
|
|
215
|
-
private logPrefixEmoji;
|
|
216
|
-
private logPrefix;
|
|
217
|
-
private minLevel;
|
|
218
|
-
private showTimestamp;
|
|
219
|
-
private colorScheme;
|
|
220
|
-
constructor(options?: LoggerOptions);
|
|
221
|
-
protected formatTimestamp(): string;
|
|
222
|
-
protected formatPrefix(): string;
|
|
223
|
-
protected shouldLog(level: LogLevel): boolean;
|
|
224
|
-
get prefixEmoji(): string | null;
|
|
225
|
-
get prefix(): string | null;
|
|
226
|
-
get colors(): {
|
|
227
|
-
primary: string;
|
|
228
|
-
success: string;
|
|
229
|
-
warn: string;
|
|
230
|
-
danger: string;
|
|
231
|
-
muted: string;
|
|
232
|
-
text: string;
|
|
233
|
-
};
|
|
234
|
-
extend<Extra extends Record<string, (...args: any) => void>>(extras: Extra & ThisType<Logger>): Logger & Extra;
|
|
235
|
-
setPrefix(prefix: string | null): this;
|
|
236
|
-
setPrefixEmoji(prefixEmoji: string | null): this;
|
|
237
|
-
setMinLevel(minLevel: LogLevel): this;
|
|
238
|
-
setShowTimestamp(show: boolean): this;
|
|
239
|
-
setColors(colors: Partial<typeof LOGGER_COLORS>): this;
|
|
240
|
-
log(message: string, ...args: any[]): void;
|
|
241
|
-
debug(message: string, ...args: any[]): void;
|
|
242
|
-
info(message: string, ...args: any[]): void;
|
|
243
|
-
success(message: string, ...args: any[]): void;
|
|
244
|
-
warn(message: string, ...args: any[]): void;
|
|
245
|
-
error(message: string, error?: Error, ...args: any[]): void;
|
|
246
|
-
loader(message: string): (newMessage?: string) => void;
|
|
247
|
-
table(title: string, data: Record<string, any>): void;
|
|
248
|
-
section(title: string): void;
|
|
81
|
+
declare enum CommandType {
|
|
82
|
+
Slash = 0,
|
|
83
|
+
Prefix = 1,
|
|
84
|
+
Context = 2
|
|
249
85
|
}
|
|
250
|
-
declare
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
86
|
+
declare enum MissingPermissionReason {
|
|
87
|
+
User = 0,
|
|
88
|
+
Bot = 1,
|
|
89
|
+
Role = 2,
|
|
90
|
+
UserBlacklisted = 3,
|
|
91
|
+
RoleBlacklisted = 4,
|
|
92
|
+
NotInGuild = 5,
|
|
93
|
+
NotGuildOwner = 6,
|
|
94
|
+
NotBotOwner = 7,
|
|
95
|
+
NotBotStaff = 8
|
|
257
96
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*/
|
|
264
|
-
name: string;
|
|
265
|
-
type: ActivityType;
|
|
266
|
-
status: StatusType;
|
|
267
|
-
streamUrl?: string;
|
|
97
|
+
declare enum RateLimitScope {
|
|
98
|
+
User = 0,
|
|
99
|
+
Guild = 1,
|
|
100
|
+
Channel = 2,
|
|
101
|
+
Global = 3
|
|
268
102
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
103
|
+
type BaseCommandParameters<T extends CommandType> = T extends CommandType.Slash ? [client: Vimcord<true>, interaction: ChatInputCommandInteraction] : T extends CommandType.Prefix ? [client: Vimcord<true>, message: Message] : T extends CommandType.Context ? [client: Vimcord<true>, interaction: ContextMenuCommandInteraction] : never;
|
|
104
|
+
interface BaseCommandConfig<T extends CommandType> {
|
|
105
|
+
/** Is this command enabled? @defaultValue true */
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
/** Custom conditions that must be met for this command to execute */
|
|
108
|
+
conditions?: Array<(...args: BaseCommandParameters<T>) => boolean | Promise<boolean>>;
|
|
109
|
+
/** Command permission requirements */
|
|
110
|
+
permissions?: CommandPermissions;
|
|
111
|
+
/** Command metadata configuration */
|
|
112
|
+
metadata?: CommandMetadata;
|
|
113
|
+
/** Rate limiting options */
|
|
114
|
+
rateLimit?: CommandRateLimitOptions<(...args: BaseCommandParameters<T>) => any>;
|
|
115
|
+
/** Log whenever a command is executed? @defaultValue true */
|
|
116
|
+
logExecution?: boolean;
|
|
117
|
+
/** Executed before the main command logic */
|
|
118
|
+
beforeExecute?: (...args: BaseCommandParameters<T>) => any;
|
|
119
|
+
/** The main command function that will be executed */
|
|
120
|
+
execute?: (...args: BaseCommandParameters<T>) => any;
|
|
121
|
+
/** Executed after successful execution */
|
|
122
|
+
afterExecute?: (result: any, ...args: BaseCommandParameters<T>) => any;
|
|
123
|
+
/** Executed when the required permissions are not met */
|
|
124
|
+
onMissingPermissions?: (results: CommandPermissionResults, ...args: BaseCommandParameters<T>) => any;
|
|
125
|
+
/** Executed when the required conditions are not met */
|
|
126
|
+
onConditionsNotMet?: (...args: BaseCommandParameters<T>) => any;
|
|
127
|
+
/** Executed when this command is used when its disabled */
|
|
128
|
+
onUsedWhenDisabled?: (...args: BaseCommandParameters<T>) => any;
|
|
129
|
+
/** Executed when the rate limit is hit */
|
|
130
|
+
onRateLimit?: (...args: BaseCommandParameters<T>) => any;
|
|
131
|
+
/** Custom error handler */
|
|
132
|
+
onError?: (error: Error, ...args: BaseCommandParameters<T>) => any;
|
|
274
133
|
}
|
|
275
|
-
interface
|
|
276
|
-
|
|
277
|
-
|
|
134
|
+
interface BaseAppCommandConfig {
|
|
135
|
+
/** Command deployment configuration */
|
|
136
|
+
deployment?: AppCommandDeployment;
|
|
278
137
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
rotation: [ClientActivity];
|
|
285
|
-
paused: [Loop];
|
|
286
|
-
started: [Loop];
|
|
287
|
-
destroyed: [];
|
|
288
|
-
};
|
|
289
|
-
declare class StatusManager {
|
|
290
|
-
client: Vimcord;
|
|
291
|
-
logger: Logger;
|
|
292
|
-
emitter: EventEmitter<StatusManagerEvents>;
|
|
293
|
-
lastActivity: ClientActivity | null;
|
|
294
|
-
lastActivityIndex: number;
|
|
295
|
-
private task;
|
|
296
|
-
constructor(client: Vimcord);
|
|
297
|
-
private clearData;
|
|
298
|
-
private getReadyClient;
|
|
299
|
-
private formatActivityName;
|
|
300
|
-
private setActivity;
|
|
301
|
-
private statusRotationTask;
|
|
302
|
-
private scheduleStatusRotation;
|
|
303
|
-
start(): this;
|
|
304
|
-
pause(): this;
|
|
305
|
-
set(status: PartialDeep<VimcordClientStatus>): Promise<this>;
|
|
306
|
-
destroy(): Promise<this>;
|
|
307
|
-
clear(): Promise<this>;
|
|
138
|
+
interface CommandInternalRateLimitData {
|
|
139
|
+
/** Number of times executed */
|
|
140
|
+
executions: number;
|
|
141
|
+
/** Timestamp of latest execution */
|
|
142
|
+
timestamp: number;
|
|
308
143
|
}
|
|
309
144
|
|
|
310
145
|
interface _ContextCommandConfig extends BaseCommandConfig<CommandType.Context>, BaseAppCommandConfig {
|
|
@@ -400,6 +235,16 @@ declare class SlashCommandBuilder extends BaseCommandBuilder<CommandType.Slash,
|
|
|
400
235
|
|
|
401
236
|
type VimcordCommandBuilderByType<T extends CommandType> = T extends CommandType.Slash ? SlashCommandBuilder : T extends CommandType.Context ? ContextCommandBuilder : T extends CommandType.Prefix ? PrefixCommandBuilder : never;
|
|
402
237
|
|
|
238
|
+
declare abstract class ModuleImporter<T> {
|
|
239
|
+
readonly client: Vimcord;
|
|
240
|
+
abstract readonly items: Map<string, T>;
|
|
241
|
+
abstract readonly itemSuffix: string | undefined;
|
|
242
|
+
abstract readonly itemName: string;
|
|
243
|
+
constructor(client: Vimcord);
|
|
244
|
+
importFrom(dir: string | string[], set?: boolean, suffix?: string | string[] | null): Promise<Map<string, T>>;
|
|
245
|
+
protected abstract getName(module: T): string;
|
|
246
|
+
}
|
|
247
|
+
|
|
403
248
|
interface CommandFilter {
|
|
404
249
|
names?: string[];
|
|
405
250
|
fuzzyNames?: string[];
|
|
@@ -411,12 +256,14 @@ interface CommandByCategory<T extends CommandType> {
|
|
|
411
256
|
emoji: string | undefined;
|
|
412
257
|
commands: VimcordCommandBuilderByType<T>[];
|
|
413
258
|
}
|
|
414
|
-
declare class BaseCommandManager<T extends CommandType> {
|
|
259
|
+
declare class BaseCommandManager<T extends CommandType> extends ModuleImporter<VimcordCommandBuilderByType<T>> {
|
|
415
260
|
readonly type: T;
|
|
416
|
-
readonly
|
|
417
|
-
readonly
|
|
418
|
-
|
|
419
|
-
|
|
261
|
+
readonly items: Map<string, VimcordCommandBuilderByType<T>>;
|
|
262
|
+
readonly itemSuffix: string | undefined;
|
|
263
|
+
constructor(client: Vimcord, type: T, itemSuffix?: string);
|
|
264
|
+
get commands(): Map<string, VimcordCommandBuilderByType<T>>;
|
|
265
|
+
get itemName(): string;
|
|
266
|
+
protected getName(module: VimcordCommandBuilderByType<T>): string;
|
|
420
267
|
/**
|
|
421
268
|
* Gets a command by name.
|
|
422
269
|
*/
|
|
@@ -429,12 +276,6 @@ declare class BaseCommandManager<T extends CommandType> {
|
|
|
429
276
|
* Groups commands by category alphabetically.
|
|
430
277
|
*/
|
|
431
278
|
sortByCategory(): CommandByCategory<T>[];
|
|
432
|
-
/**
|
|
433
|
-
* Imports command modules from a directory.
|
|
434
|
-
* @param dir Path of one or more folders.
|
|
435
|
-
* @param set Replaces imported command modules with the ones found.
|
|
436
|
-
*/
|
|
437
|
-
importFrom(dir: string | string[], set?: boolean): Promise<Map<string, VimcordCommandBuilderByType<T>>>;
|
|
438
279
|
}
|
|
439
280
|
declare class SlashCommandManager extends BaseCommandManager<CommandType.Slash> {
|
|
440
281
|
constructor(client: Vimcord);
|
|
@@ -451,7 +292,7 @@ declare class CommandManager {
|
|
|
451
292
|
readonly prefix: PrefixCommandManager;
|
|
452
293
|
readonly context: ContextCommandManager;
|
|
453
294
|
constructor(client: Vimcord);
|
|
454
|
-
getAllAppCommands(options?: CommandFilter): (
|
|
295
|
+
getAllAppCommands(options?: CommandFilter): (ContextCommandBuilder | SlashCommandBuilder)[];
|
|
455
296
|
registerGlobal(options?: CommandFilter): Promise<void>;
|
|
456
297
|
unregisterGlobal(): Promise<void>;
|
|
457
298
|
registerGuild(options?: CommandFilter & {
|
|
@@ -462,6 +303,68 @@ declare class CommandManager {
|
|
|
462
303
|
}): Promise<void>;
|
|
463
304
|
}
|
|
464
305
|
|
|
306
|
+
interface LoggerOptions {
|
|
307
|
+
colors?: Partial<typeof LOGGER_COLORS>;
|
|
308
|
+
prefix?: string | null;
|
|
309
|
+
prefixEmoji?: string | null;
|
|
310
|
+
minLevel?: LogLevel;
|
|
311
|
+
/** @defaultValue `true` */
|
|
312
|
+
showTimestamp?: boolean;
|
|
313
|
+
}
|
|
314
|
+
declare enum LogLevel {
|
|
315
|
+
DEBUG = 0,
|
|
316
|
+
INFO = 1,
|
|
317
|
+
SUCCESS = 2,
|
|
318
|
+
WARN = 3,
|
|
319
|
+
ERROR = 4
|
|
320
|
+
}
|
|
321
|
+
declare const LOGGER_COLORS: {
|
|
322
|
+
primary: string;
|
|
323
|
+
success: string;
|
|
324
|
+
warn: string;
|
|
325
|
+
danger: string;
|
|
326
|
+
muted: string;
|
|
327
|
+
text: string;
|
|
328
|
+
};
|
|
329
|
+
/** Reusable functions for using `console.log()`, but in 4k ultra HD retrocolor */
|
|
330
|
+
declare class Logger {
|
|
331
|
+
private logPrefixEmoji;
|
|
332
|
+
private logPrefix;
|
|
333
|
+
private minLevel;
|
|
334
|
+
private showTimestamp;
|
|
335
|
+
private colorScheme;
|
|
336
|
+
constructor(options?: LoggerOptions);
|
|
337
|
+
protected formatTimestamp(): string;
|
|
338
|
+
protected formatPrefix(): string;
|
|
339
|
+
protected shouldLog(level: LogLevel): boolean;
|
|
340
|
+
get prefixEmoji(): string | null;
|
|
341
|
+
get prefix(): string | null;
|
|
342
|
+
get colors(): {
|
|
343
|
+
primary: string;
|
|
344
|
+
success: string;
|
|
345
|
+
warn: string;
|
|
346
|
+
danger: string;
|
|
347
|
+
muted: string;
|
|
348
|
+
text: string;
|
|
349
|
+
};
|
|
350
|
+
extend<Extra extends Record<string, (...args: any) => void>>(extras: Extra & ThisType<Logger>): Logger & Extra;
|
|
351
|
+
setPrefix(prefix: string | null): this;
|
|
352
|
+
setPrefixEmoji(prefixEmoji: string | null): this;
|
|
353
|
+
setMinLevel(minLevel: LogLevel): this;
|
|
354
|
+
setShowTimestamp(show: boolean): this;
|
|
355
|
+
setColors(colors: Partial<typeof LOGGER_COLORS>): this;
|
|
356
|
+
log(message: string, ...args: any[]): void;
|
|
357
|
+
debug(message: string, ...args: any[]): void;
|
|
358
|
+
info(message: string, ...args: any[]): void;
|
|
359
|
+
success(message: string, ...args: any[]): void;
|
|
360
|
+
warn(message: string, ...args: any[]): void;
|
|
361
|
+
error(message: string, error?: Error, ...args: any[]): void;
|
|
362
|
+
loader(message: string): (newMessage?: string) => void;
|
|
363
|
+
table(title: string, data: Record<string, any>): void;
|
|
364
|
+
section(title: string): void;
|
|
365
|
+
}
|
|
366
|
+
declare const logger: Logger;
|
|
367
|
+
|
|
465
368
|
type EventParameters<T extends keyof ClientEvents> = [client: Vimcord<true>, ...args: ClientEvents[T]];
|
|
466
369
|
|
|
467
370
|
interface EventMetadata {
|
|
@@ -560,11 +463,13 @@ declare class EventBuilder<T extends keyof ClientEvents = keyof ClientEvents> im
|
|
|
560
463
|
executeEvent(...args: EventParameters<T>): Promise<any>;
|
|
561
464
|
}
|
|
562
465
|
|
|
563
|
-
declare class EventManager {
|
|
564
|
-
|
|
565
|
-
|
|
466
|
+
declare class EventManager extends ModuleImporter<EventBuilder<any>> {
|
|
467
|
+
readonly items: Map<string, EventBuilder<any>>;
|
|
468
|
+
readonly itemSuffix = "event";
|
|
469
|
+
readonly itemName = "Event Handlers";
|
|
566
470
|
logger: Logger;
|
|
567
471
|
constructor(client: Vimcord);
|
|
472
|
+
protected getName(module: EventBuilder<any>): string;
|
|
568
473
|
register<T extends keyof ClientEvents>(...events: EventBuilder<T>[]): void;
|
|
569
474
|
unregister(...names: string[]): void;
|
|
570
475
|
clear(): void;
|
|
@@ -573,25 +478,360 @@ declare class EventManager {
|
|
|
573
478
|
getByCategory(category: string): EventBuilder[];
|
|
574
479
|
getByEvent<T extends keyof ClientEvents>(eventType: T): EventBuilder<T>[];
|
|
575
480
|
executeEvents<T extends keyof ClientEvents>(eventType: T, ...args: ClientEvents[T]): Promise<void>;
|
|
576
|
-
/** Import event modules that end with `.event` */
|
|
577
|
-
importFrom(dir: string | string[], replaceAll?: boolean): Promise<Map<string, EventBuilder<any>>>;
|
|
578
481
|
}
|
|
579
482
|
|
|
580
|
-
declare enum
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
483
|
+
declare enum StatusType {
|
|
484
|
+
DND = "dnd",
|
|
485
|
+
Idle = "idle",
|
|
486
|
+
Online = "online",
|
|
487
|
+
Invisible = "invisible"
|
|
488
|
+
}
|
|
489
|
+
interface ClientActivity {
|
|
490
|
+
/** Mappings:
|
|
491
|
+
* - `$USER_COUNT` - this.client.users.cache.size
|
|
492
|
+
* - `$GUILD_COUNT` - this.client.guilds.cache.size
|
|
493
|
+
* - `$STAFF_GUILD_MEMBER_COUNT` - self explanatory
|
|
494
|
+
*/
|
|
495
|
+
name: string;
|
|
496
|
+
type: ActivityType;
|
|
497
|
+
status: StatusType;
|
|
498
|
+
streamUrl?: string;
|
|
499
|
+
}
|
|
500
|
+
interface ClientStatus {
|
|
501
|
+
/** In seconds */
|
|
502
|
+
interval?: number;
|
|
503
|
+
randomize?: boolean;
|
|
504
|
+
activity: ClientActivity | ClientActivity[];
|
|
505
|
+
}
|
|
506
|
+
interface VimcordClientStatus {
|
|
507
|
+
production: ClientStatus;
|
|
508
|
+
development: ClientStatus;
|
|
509
|
+
}
|
|
510
|
+
declare function createVimcordStatusConfig(options?: PartialDeep<VimcordClientStatus>): VimcordClientStatus;
|
|
511
|
+
|
|
512
|
+
type StatusManagerEvents = {
|
|
513
|
+
changed: [ClientActivity];
|
|
514
|
+
cleared: [];
|
|
515
|
+
rotation: [ClientActivity];
|
|
516
|
+
paused: [Loop];
|
|
517
|
+
started: [Loop];
|
|
518
|
+
destroyed: [];
|
|
519
|
+
};
|
|
520
|
+
declare class StatusManager {
|
|
521
|
+
client: Vimcord;
|
|
522
|
+
logger: Logger;
|
|
523
|
+
emitter: EventEmitter<StatusManagerEvents>;
|
|
524
|
+
lastActivity: ClientActivity | null;
|
|
525
|
+
lastActivityIndex: number;
|
|
526
|
+
private task;
|
|
527
|
+
constructor(client: Vimcord);
|
|
528
|
+
private clearData;
|
|
529
|
+
private getReadyClient;
|
|
530
|
+
private formatActivityName;
|
|
531
|
+
private setActivity;
|
|
532
|
+
private statusRotationTask;
|
|
533
|
+
private scheduleStatusRotation;
|
|
534
|
+
start(): this;
|
|
535
|
+
pause(): this;
|
|
536
|
+
set(status: PartialDeep<VimcordClientStatus>): Promise<this>;
|
|
537
|
+
destroy(): Promise<this>;
|
|
538
|
+
clear(): Promise<this>;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
interface MongoConnectionOptions {
|
|
542
|
+
/** The maximum number of attempts to connect to MongoDB @defaultValue `3` */
|
|
543
|
+
maxRetries?: number;
|
|
544
|
+
}
|
|
545
|
+
declare class MongoDatabase {
|
|
546
|
+
private static instances;
|
|
547
|
+
private static emitter;
|
|
548
|
+
readonly moduleName = "MongoDatabase";
|
|
549
|
+
readonly clientId: number;
|
|
550
|
+
readonly client: Vimcord;
|
|
551
|
+
readonly mongoose: mongoose__default.Mongoose;
|
|
552
|
+
private isConnecting;
|
|
553
|
+
/**
|
|
554
|
+
* Returns an instance of MongoDatabase.
|
|
555
|
+
* @param clientId [default: 0]
|
|
556
|
+
*/
|
|
557
|
+
static getInstance(clientId?: number | Vimcord): MongoDatabase | undefined;
|
|
558
|
+
/**
|
|
559
|
+
* Waits for a MongoDatabase instance to be ready. First waiting for the instance to initialize if it doesn't exist.
|
|
560
|
+
* @param clientId [default: 0]
|
|
561
|
+
* @param timeoutMs [default: 60000]
|
|
562
|
+
*/
|
|
563
|
+
static getReadyInstance(clientId?: number | Vimcord, timeoutMs?: number): Promise<MongoDatabase>;
|
|
564
|
+
/**
|
|
565
|
+
* Starts a new Mongo client session.
|
|
566
|
+
* @param options Options for the new session
|
|
567
|
+
* @param clientId [default: 0]
|
|
568
|
+
*/
|
|
569
|
+
static startSession(options?: ClientSessionOptions, clientId?: number | Vimcord): Promise<mongoose__default.mongo.ClientSession>;
|
|
570
|
+
constructor(client: Vimcord, options?: mongoose__default.MongooseOptions);
|
|
571
|
+
get connection(): Connection;
|
|
572
|
+
get isReady(): boolean;
|
|
573
|
+
waitForReady(): Promise<this>;
|
|
574
|
+
connect(uri?: string, connectionOptions?: mongoose__default.ConnectOptions, options?: MongoConnectionOptions): Promise<boolean>;
|
|
575
|
+
disconnect(): Promise<void>;
|
|
576
|
+
startSession(options?: ClientSessionOptions): Promise<mongoose__default.mongo.ClientSession>;
|
|
577
|
+
useTransaction(fn: (session: mongoose__default.ClientSession) => Promise<void>): Promise<void>;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
type DatabaseManager = MongoDatabase;
|
|
581
|
+
|
|
582
|
+
declare class ErrorHandler {
|
|
583
|
+
readonly client: Vimcord;
|
|
584
|
+
constructor(client: Vimcord);
|
|
585
|
+
/** Handles command errors - sends error embed to user, then rethrows. */
|
|
586
|
+
handleCommandError(error: Error, guild: Guild | null, messageOrInteraction: Message | CommandInteraction): Promise<void>;
|
|
587
|
+
/** Handles internal Vimcord errors - logs with [Vimcord] prefix. */
|
|
588
|
+
handleVimcordError(error: Error, context: string): void;
|
|
589
|
+
/** Sets up global process error handlers. */
|
|
590
|
+
setupGlobalHandlers(): void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
interface AppConfig {
|
|
594
|
+
/** The name of the bot displayed in logs and startup banner.
|
|
595
|
+
* @accessible via `client.$name` for use in embeds, error messages, etc.
|
|
596
|
+
*/
|
|
597
|
+
name: string;
|
|
598
|
+
/** The current version of the bot displayed in logs and startup banner.
|
|
599
|
+
* @accessible via `client.$version` for version commands or update notifications.
|
|
600
|
+
* @defaultValue Extracted from your `package.json` version field. If not found, defaults to `1.0.0`.
|
|
601
|
+
*/
|
|
602
|
+
version: string;
|
|
603
|
+
/** Enables development mode for testing and debugging.
|
|
604
|
+
*
|
|
605
|
+
* **The way it works:**
|
|
606
|
+
* - If the bot is ran with the `--dev` flag it will automatically be enabled
|
|
607
|
+
* - Can be changed during runtime using the `client.$devMode` setter
|
|
608
|
+
*
|
|
609
|
+
* **What this does by default:**
|
|
610
|
+
* - Automatically switches to `TOKEN_DEV` and `MONGO_URI_DEV` environment variables
|
|
611
|
+
*
|
|
612
|
+
* **Common use cases:**
|
|
613
|
+
* - Use a separate Discord server, bot account, or database for testing
|
|
614
|
+
* - Skip production-only behaviors like analytics tracking or email notifications
|
|
615
|
+
* - Enable additional debug commands or verbose logging
|
|
616
|
+
* - Switch between development and production API endpoints for your other services
|
|
617
|
+
*
|
|
618
|
+
* @accessible via `client.$devMode` to conditionally enable/disable your own features.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* // Use different API endpoints for your own services
|
|
623
|
+
* const baseAPIUrl = client.$devMode
|
|
624
|
+
* ? 'http://localhost:3000'
|
|
625
|
+
* : 'https://api.production.com';
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
devMode: boolean;
|
|
629
|
+
/** Enables verbose console logging with additional debug information.
|
|
630
|
+
* @accessible via `client.$verboseMode`
|
|
631
|
+
* @defaultValue false
|
|
632
|
+
*/
|
|
633
|
+
verbose: boolean;
|
|
634
|
+
/** Enables the Vimcord CLI.
|
|
635
|
+
* @defaultValue false
|
|
636
|
+
*/
|
|
637
|
+
enableCLI: boolean;
|
|
638
|
+
/** Disables the Vimcord ASCII art banner on startup.
|
|
639
|
+
* @defaultValue false
|
|
640
|
+
*/
|
|
641
|
+
disableBanner: boolean;
|
|
642
|
+
}
|
|
643
|
+
declare const createAppConfig: (options?: {
|
|
644
|
+
name?: string | undefined;
|
|
645
|
+
version?: string | undefined;
|
|
646
|
+
devMode?: boolean | undefined;
|
|
647
|
+
verbose?: boolean | undefined;
|
|
648
|
+
enableCLI?: boolean | undefined;
|
|
649
|
+
disableBanner?: boolean | undefined;
|
|
650
|
+
}, existing?: AppConfig | undefined) => AppConfig;
|
|
651
|
+
|
|
652
|
+
interface ContextCommandConfig extends BaseCommandConfig<CommandType.Context> {
|
|
653
|
+
}
|
|
654
|
+
declare const createContextCommandConfig: (options?: {
|
|
655
|
+
enabled?: boolean | undefined;
|
|
656
|
+
conditions?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => boolean | Promise<boolean>)[] | undefined;
|
|
657
|
+
permissions?: {
|
|
658
|
+
user?: discord_js.PermissionResolvable[] | undefined;
|
|
659
|
+
bot?: discord_js.PermissionResolvable[] | undefined;
|
|
660
|
+
roles?: string[] | undefined;
|
|
661
|
+
userWhitelist?: string[] | undefined;
|
|
662
|
+
userBlacklist?: string[] | undefined;
|
|
663
|
+
roleBlacklist?: string[] | undefined;
|
|
664
|
+
guildOnly?: boolean | undefined;
|
|
665
|
+
guildOwnerOnly?: boolean | undefined;
|
|
666
|
+
botOwnerOnly?: boolean | undefined;
|
|
667
|
+
botStaffOnly?: boolean | undefined;
|
|
668
|
+
} | undefined;
|
|
669
|
+
metadata?: {
|
|
670
|
+
category?: string | undefined;
|
|
671
|
+
categoryEmoji?: string | undefined;
|
|
672
|
+
tags?: string[] | undefined;
|
|
673
|
+
examples?: string[] | undefined;
|
|
674
|
+
emoji?: string | undefined;
|
|
675
|
+
hidden?: boolean | undefined;
|
|
676
|
+
} | undefined;
|
|
677
|
+
rateLimit?: {
|
|
678
|
+
max?: number | undefined;
|
|
679
|
+
interval?: number | undefined;
|
|
680
|
+
scope?: RateLimitScope | undefined;
|
|
681
|
+
onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
682
|
+
} | undefined;
|
|
683
|
+
logExecution?: boolean | undefined;
|
|
684
|
+
beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
685
|
+
execute?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
686
|
+
afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
687
|
+
onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
688
|
+
onConditionsNotMet?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
689
|
+
onUsedWhenDisabled?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
690
|
+
onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
691
|
+
onError?: ((error: Error, client: Vimcord<true>, interaction: discord_js.ContextMenuCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
692
|
+
}, existing?: ContextCommandConfig | undefined) => ContextCommandConfig;
|
|
693
|
+
|
|
694
|
+
interface PrefixCommandConfig extends BaseCommandConfig<CommandType.Prefix> {
|
|
695
|
+
/** @defaultValue ! */
|
|
696
|
+
defaultPrefix: string;
|
|
697
|
+
/** @defaultValue true */
|
|
698
|
+
allowMentionAsPrefix: boolean;
|
|
699
|
+
/** @defaultValue true */
|
|
700
|
+
allowCaseInsensitiveCommandNames: boolean;
|
|
701
|
+
/**
|
|
702
|
+
* A custom resolver to fetch a guild-specific prefix.
|
|
703
|
+
* Returns a string (the prefix) or null/undefined to fallback to default.
|
|
704
|
+
*/
|
|
705
|
+
guildPrefixResolver?: (client: Vimcord, guildId: string) => Promise<string | null | undefined> | string | null | undefined;
|
|
706
|
+
}
|
|
707
|
+
declare const createPrefixCommandConfig: (options?: {
|
|
708
|
+
defaultPrefix?: string | undefined;
|
|
709
|
+
allowMentionAsPrefix?: boolean | undefined;
|
|
710
|
+
allowCaseInsensitiveCommandNames?: boolean | undefined;
|
|
711
|
+
guildPrefixResolver?: ((client: Vimcord, guildId: string) => Promise<string | null | undefined> | string | null | undefined) | undefined;
|
|
712
|
+
enabled?: boolean | undefined;
|
|
713
|
+
conditions?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => boolean | Promise<boolean>)[] | undefined;
|
|
714
|
+
permissions?: {
|
|
715
|
+
user?: discord_js.PermissionResolvable[] | undefined;
|
|
716
|
+
bot?: discord_js.PermissionResolvable[] | undefined;
|
|
717
|
+
roles?: string[] | undefined;
|
|
718
|
+
userWhitelist?: string[] | undefined;
|
|
719
|
+
userBlacklist?: string[] | undefined;
|
|
720
|
+
roleBlacklist?: string[] | undefined;
|
|
721
|
+
guildOnly?: boolean | undefined;
|
|
722
|
+
guildOwnerOnly?: boolean | undefined;
|
|
723
|
+
botOwnerOnly?: boolean | undefined;
|
|
724
|
+
botStaffOnly?: boolean | undefined;
|
|
725
|
+
} | undefined;
|
|
726
|
+
metadata?: {
|
|
727
|
+
category?: string | undefined;
|
|
728
|
+
categoryEmoji?: string | undefined;
|
|
729
|
+
tags?: string[] | undefined;
|
|
730
|
+
examples?: string[] | undefined;
|
|
731
|
+
emoji?: string | undefined;
|
|
732
|
+
hidden?: boolean | undefined;
|
|
733
|
+
} | undefined;
|
|
734
|
+
rateLimit?: {
|
|
735
|
+
max?: number | undefined;
|
|
736
|
+
interval?: number | undefined;
|
|
737
|
+
scope?: RateLimitScope | undefined;
|
|
738
|
+
onRateLimit?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
739
|
+
} | undefined;
|
|
740
|
+
logExecution?: boolean | undefined;
|
|
741
|
+
beforeExecute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
742
|
+
execute?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
743
|
+
afterExecute?: ((result: any, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
744
|
+
onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
745
|
+
onConditionsNotMet?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
746
|
+
onUsedWhenDisabled?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
747
|
+
onRateLimit?: ((client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
748
|
+
onError?: ((error: Error, client: Vimcord<true>, message: discord_js.Message<boolean>) => any) | undefined;
|
|
749
|
+
}, existing?: PrefixCommandConfig | undefined) => PrefixCommandConfig;
|
|
750
|
+
|
|
751
|
+
interface SlashCommandConfig extends BaseCommandConfig<CommandType.Slash> {
|
|
588
752
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
753
|
+
declare const createSlashCommandConfig: (options?: {
|
|
754
|
+
enabled?: boolean | undefined;
|
|
755
|
+
conditions?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => boolean | Promise<boolean>)[] | undefined;
|
|
756
|
+
permissions?: {
|
|
757
|
+
user?: discord_js.PermissionResolvable[] | undefined;
|
|
758
|
+
bot?: discord_js.PermissionResolvable[] | undefined;
|
|
759
|
+
roles?: string[] | undefined;
|
|
760
|
+
userWhitelist?: string[] | undefined;
|
|
761
|
+
userBlacklist?: string[] | undefined;
|
|
762
|
+
roleBlacklist?: string[] | undefined;
|
|
763
|
+
guildOnly?: boolean | undefined;
|
|
764
|
+
guildOwnerOnly?: boolean | undefined;
|
|
765
|
+
botOwnerOnly?: boolean | undefined;
|
|
766
|
+
botStaffOnly?: boolean | undefined;
|
|
767
|
+
} | undefined;
|
|
768
|
+
metadata?: {
|
|
769
|
+
category?: string | undefined;
|
|
770
|
+
categoryEmoji?: string | undefined;
|
|
771
|
+
tags?: string[] | undefined;
|
|
772
|
+
examples?: string[] | undefined;
|
|
773
|
+
emoji?: string | undefined;
|
|
774
|
+
hidden?: boolean | undefined;
|
|
775
|
+
} | undefined;
|
|
776
|
+
rateLimit?: {
|
|
777
|
+
max?: number | undefined;
|
|
778
|
+
interval?: number | undefined;
|
|
779
|
+
scope?: RateLimitScope | undefined;
|
|
780
|
+
onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
781
|
+
} | undefined;
|
|
782
|
+
logExecution?: boolean | undefined;
|
|
783
|
+
beforeExecute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
784
|
+
execute?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
785
|
+
afterExecute?: ((result: any, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
786
|
+
onMissingPermissions?: ((results: CommandPermissionResults, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
787
|
+
onConditionsNotMet?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
788
|
+
onUsedWhenDisabled?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
789
|
+
onRateLimit?: ((client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
790
|
+
onError?: ((error: Error, client: Vimcord<true>, interaction: discord_js.ChatInputCommandInteraction<discord_js.CacheType>) => any) | undefined;
|
|
791
|
+
}, existing?: SlashCommandConfig | undefined) => SlashCommandConfig;
|
|
792
|
+
|
|
793
|
+
interface StaffConfig {
|
|
794
|
+
ownerId: string | null;
|
|
795
|
+
superUsers: string[];
|
|
796
|
+
superUserRoles: string[];
|
|
797
|
+
bypassers: {
|
|
798
|
+
commandName: string;
|
|
799
|
+
userIds: string[];
|
|
800
|
+
}[];
|
|
801
|
+
bypassesGuildAdmin: {
|
|
802
|
+
allBotStaff: boolean;
|
|
803
|
+
botOwner: boolean;
|
|
804
|
+
superUsers: boolean;
|
|
805
|
+
bypassers: boolean;
|
|
806
|
+
};
|
|
807
|
+
guild: {
|
|
808
|
+
id: string | null;
|
|
809
|
+
inviteUrl: string | null;
|
|
810
|
+
channels: Record<string, string>;
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
declare const createStaffConfig: (options?: {
|
|
814
|
+
ownerId?: string | null | undefined;
|
|
815
|
+
superUsers?: string[] | undefined;
|
|
816
|
+
superUserRoles?: string[] | undefined;
|
|
817
|
+
bypassers?: {
|
|
818
|
+
commandName: string;
|
|
819
|
+
userIds: string[];
|
|
820
|
+
}[] | undefined;
|
|
821
|
+
bypassesGuildAdmin?: {
|
|
822
|
+
allBotStaff?: boolean | undefined;
|
|
823
|
+
botOwner?: boolean | undefined;
|
|
824
|
+
superUsers?: boolean | undefined;
|
|
825
|
+
bypassers?: boolean | undefined;
|
|
826
|
+
} | undefined;
|
|
827
|
+
guild?: {
|
|
828
|
+
id?: string | null | undefined;
|
|
829
|
+
inviteUrl?: string | null | undefined;
|
|
830
|
+
channels?: {
|
|
831
|
+
[x: string]: string | undefined;
|
|
832
|
+
} | undefined;
|
|
833
|
+
} | undefined;
|
|
834
|
+
}, existing?: StaffConfig | undefined) => StaffConfig;
|
|
595
835
|
|
|
596
836
|
interface ToolsConfig {
|
|
597
837
|
devMode: boolean;
|
|
@@ -630,8 +870,7 @@ interface ToolsConfig {
|
|
|
630
870
|
};
|
|
631
871
|
}
|
|
632
872
|
declare const globalToolsConfig: ToolsConfig;
|
|
633
|
-
declare
|
|
634
|
-
declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsConfig & {
|
|
873
|
+
declare const createToolsConfig: (options?: {
|
|
635
874
|
devMode?: boolean | undefined;
|
|
636
875
|
embedColor?: ColorResolvable[] | undefined;
|
|
637
876
|
embedColorDev?: ColorResolvable[] | undefined;
|
|
@@ -660,7 +899,7 @@ declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsCon
|
|
|
660
899
|
id?: string | undefined;
|
|
661
900
|
} | undefined;
|
|
662
901
|
} | undefined;
|
|
663
|
-
|
|
902
|
+
last?: {
|
|
664
903
|
label?: string | undefined;
|
|
665
904
|
emoji?: {
|
|
666
905
|
animated?: boolean | undefined;
|
|
@@ -668,7 +907,7 @@ declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsCon
|
|
|
668
907
|
id?: string | undefined;
|
|
669
908
|
} | undefined;
|
|
670
909
|
} | undefined;
|
|
671
|
-
|
|
910
|
+
back?: {
|
|
672
911
|
label?: string | undefined;
|
|
673
912
|
emoji?: {
|
|
674
913
|
animated?: boolean | undefined;
|
|
@@ -676,7 +915,7 @@ declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsCon
|
|
|
676
915
|
id?: string | undefined;
|
|
677
916
|
} | undefined;
|
|
678
917
|
} | undefined;
|
|
679
|
-
|
|
918
|
+
jump?: {
|
|
680
919
|
label?: string | undefined;
|
|
681
920
|
emoji?: {
|
|
682
921
|
animated?: boolean | undefined;
|
|
@@ -684,7 +923,7 @@ declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsCon
|
|
|
684
923
|
id?: string | undefined;
|
|
685
924
|
} | undefined;
|
|
686
925
|
} | undefined;
|
|
687
|
-
|
|
926
|
+
next?: {
|
|
688
927
|
label?: string | undefined;
|
|
689
928
|
emoji?: {
|
|
690
929
|
animated?: boolean | undefined;
|
|
@@ -700,7 +939,8 @@ declare function createToolsConfig(options?: PartialDeep<ToolsConfig>): ToolsCon
|
|
|
700
939
|
confirmLabel?: string | undefined;
|
|
701
940
|
rejectLabel?: string | undefined;
|
|
702
941
|
} | undefined;
|
|
703
|
-
};
|
|
942
|
+
}, existing?: ToolsConfig | undefined) => ToolsConfig;
|
|
943
|
+
declare const defineGlobalToolsConfig: (options: PartialDeep<ToolsConfig>) => void;
|
|
704
944
|
|
|
705
945
|
interface BetterContainerData {
|
|
706
946
|
color?: ColorResolvable | ColorResolvable[] | null;
|
|
@@ -883,30 +1123,82 @@ declare class BetterEmbed {
|
|
|
883
1123
|
send(handler: SendHandler, options?: DynaSendOptions, overrides?: Partial<BetterEmbedData>): Promise<Message | null>;
|
|
884
1124
|
}
|
|
885
1125
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1126
|
+
declare enum SendMethod {
|
|
1127
|
+
Reply = 0,
|
|
1128
|
+
EditReply = 1,
|
|
1129
|
+
FollowUp = 2,
|
|
1130
|
+
Channel = 3,
|
|
1131
|
+
MessageReply = 4,
|
|
1132
|
+
MessageEdit = 5,
|
|
1133
|
+
User = 6
|
|
1134
|
+
}
|
|
1135
|
+
type SendHandler = CommandInteraction | RepliableInteraction | TextBasedChannel | Message | GuildMember | User;
|
|
1136
|
+
type InteractionBasedSendHandler = CommandInteraction | RepliableInteraction;
|
|
1137
|
+
type EmbedResolvable = EmbedBuilder | BetterEmbed;
|
|
1138
|
+
type InteractionResolveable = CommandInteraction | RepliableInteraction;
|
|
1139
|
+
type UserResolvable = GuildMember | User | string;
|
|
1140
|
+
type SendableTextChannel = DMChannel | TextChannel | NewsChannel | ThreadChannel;
|
|
1141
|
+
|
|
1142
|
+
interface ModuleImportOptions {
|
|
1143
|
+
/** The directories to import from. */
|
|
1144
|
+
dir: string | string[];
|
|
1145
|
+
/** Recursively imports modules from subdirectories.
|
|
1146
|
+
* @defaultValue true
|
|
1147
|
+
**/
|
|
1148
|
+
recursive?: boolean;
|
|
1149
|
+
/** Only import modules that end with these suffixes.
|
|
1150
|
+
*
|
|
1151
|
+
* If set to `null` all files in the directory will be imported, which may lead to import errors if you have modules not related to commands in the same directory.
|
|
1152
|
+
*
|
|
1153
|
+
* Respectively, the default suffixes are `.slash`, `.ctx`, `.prefix`, and `.event`.
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* // Example module filenames using the default suffixes
|
|
1157
|
+
* "ping.slash.ts"
|
|
1158
|
+
* "avatar.ctx.ts"
|
|
1159
|
+
* "help.prefix.ts"
|
|
1160
|
+
* "ready.event.ts"
|
|
1161
|
+
*/
|
|
1162
|
+
suffix?: string | string[] | null;
|
|
1163
|
+
}
|
|
1164
|
+
interface AppModuleImports {
|
|
1165
|
+
/** Default suffix: slash
|
|
1166
|
+
* @example
|
|
1167
|
+
* // Example module filename
|
|
1168
|
+
* "ping.slash.ts"
|
|
1169
|
+
*/
|
|
1170
|
+
slashCommands?: string | string[] | ModuleImportOptions;
|
|
1171
|
+
/** Default suffix: ctx
|
|
1172
|
+
* @example
|
|
1173
|
+
* // Example module filename
|
|
1174
|
+
* "avatar.ctx.ts"
|
|
1175
|
+
*/
|
|
1176
|
+
contextCommands?: string | string[] | ModuleImportOptions;
|
|
1177
|
+
/** Default suffix: prefix
|
|
1178
|
+
* @example
|
|
1179
|
+
* // Example module filename
|
|
1180
|
+
* "help.prefix.ts"
|
|
1181
|
+
*/
|
|
1182
|
+
prefixCommands?: string | string[] | ModuleImportOptions;
|
|
1183
|
+
/** Default suffix: event
|
|
1184
|
+
* @example
|
|
1185
|
+
* // Example module filename
|
|
1186
|
+
* "ready.event.ts"
|
|
1187
|
+
*/
|
|
1188
|
+
events?: string | string[] | ModuleImportOptions;
|
|
901
1189
|
}
|
|
902
1190
|
interface VimcordFeatures {
|
|
903
|
-
/** Use global process error handlers
|
|
1191
|
+
/** Use global process error handlers.
|
|
1192
|
+
* @defaultValue true */
|
|
904
1193
|
useGlobalErrorHandlers?: boolean;
|
|
905
|
-
/** Use our default prefix command handler
|
|
1194
|
+
/** Use our default prefix command handler.
|
|
1195
|
+
* @defaultValue true */
|
|
906
1196
|
useDefaultPrefixCommandHandler?: boolean;
|
|
907
|
-
/** Use our default slash command handler
|
|
1197
|
+
/** Use our default slash command handler.
|
|
1198
|
+
* @defaultValue true */
|
|
908
1199
|
useDefaultSlashCommandHandler?: boolean;
|
|
909
|
-
/** Use our default context command handler
|
|
1200
|
+
/** Use our default context command handler.
|
|
1201
|
+
* @defaultValue true */
|
|
910
1202
|
useDefaultContextCommandHandler?: boolean;
|
|
911
1203
|
/** Reply to the user with an Uh-oh! embed when a command fails. If not using our default command handlers, you will have to implement this yourself using {@link sendCommandErrorEmbed}
|
|
912
1204
|
* @example
|
|
@@ -922,19 +1214,10 @@ interface VimcordFeatures {
|
|
|
922
1214
|
* }
|
|
923
1215
|
* ``` */
|
|
924
1216
|
enableCommandErrorMessage?: boolean | CommandErrorMessageConfig;
|
|
925
|
-
/** Update the state of {@link globalToolsConfig.devMode} whenever {@link AppConfig.devMode} is updated in the client. This is mainly useful for {@link BetterEmbed} to switch between devMode and production colors during runtime without having to update the global config manually @defaultValue `false` */
|
|
926
|
-
hookToolsDevMode?: boolean;
|
|
927
|
-
/** Setup and configure `dotenv` @defaultValue `false` */
|
|
928
|
-
useEnv?: boolean | DotenvConfigOptions;
|
|
929
1217
|
/** The maximum number of attempts to log into Discord @defaultValue `3` */
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
importModules?:
|
|
933
|
-
events?: string | string[];
|
|
934
|
-
slashCommands?: string | string[];
|
|
935
|
-
prefixCommands?: string | string[];
|
|
936
|
-
contextCommands?: string | string[];
|
|
937
|
-
};
|
|
1218
|
+
maxLoginAttempts?: number;
|
|
1219
|
+
/** Automatically imports modules from these directories. */
|
|
1220
|
+
importModules?: AppModuleImports;
|
|
938
1221
|
}
|
|
939
1222
|
interface VimcordConfig {
|
|
940
1223
|
app: AppConfig;
|
|
@@ -943,8 +1226,45 @@ interface VimcordConfig {
|
|
|
943
1226
|
prefixCommands: PrefixCommandConfig;
|
|
944
1227
|
contextCommands: ContextCommandConfig;
|
|
945
1228
|
}
|
|
1229
|
+
interface VimcordCreateConfig {
|
|
1230
|
+
options: ClientOptions;
|
|
1231
|
+
features?: VimcordFeatures;
|
|
1232
|
+
config?: PartialDeep<VimcordConfig>;
|
|
1233
|
+
}
|
|
1234
|
+
interface CommandErrorMessageConfig {
|
|
1235
|
+
/** Use a custom embed */
|
|
1236
|
+
embed?: (embed: EmbedResolvable, error: Error, guild: Guild | null | undefined) => EmbedResolvable;
|
|
1237
|
+
/** @defaultValue config.staff.mainServer.inviteUrl */
|
|
1238
|
+
inviteUrl?: string;
|
|
1239
|
+
/** The support server invite button label @defaultValue "Support Server" */
|
|
1240
|
+
inviteButtonLabel?: string;
|
|
1241
|
+
/** The error details button label @defaultValue "Details" */
|
|
1242
|
+
detailButtonLabel?: string;
|
|
1243
|
+
/** @defaultValue 30_000 // 30 seconds */
|
|
1244
|
+
detailButtonIdleTimeout?: number;
|
|
1245
|
+
/** Should the message be ephemeral? */
|
|
1246
|
+
ephemeral?: boolean;
|
|
1247
|
+
/** Should the message be deleted after a certain amount of time? */
|
|
1248
|
+
deleteAfter?: number;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
946
1251
|
declare class Vimcord<Ready extends boolean = boolean> extends Client<Ready> {
|
|
947
1252
|
static instances: Map<number, Vimcord<boolean>>;
|
|
1253
|
+
private static emitter;
|
|
1254
|
+
private clientStartingPromise;
|
|
1255
|
+
static create(options: ClientOptions, features?: VimcordFeatures, config?: PartialDeep<VimcordConfig>): Vimcord;
|
|
1256
|
+
static create(config: VimcordCreateConfig): Vimcord;
|
|
1257
|
+
/**
|
|
1258
|
+
* Returns an instance of Vimcord.
|
|
1259
|
+
* @param clientId [default: 0]
|
|
1260
|
+
*/
|
|
1261
|
+
static getInstance(clientId?: number): Vimcord | undefined;
|
|
1262
|
+
/**
|
|
1263
|
+
* Waits for a Vimcord instance to be ready.
|
|
1264
|
+
* @param clientId [default: 0]
|
|
1265
|
+
* @param timeoutMs [default: 60000]
|
|
1266
|
+
*/
|
|
1267
|
+
static getReadyInstance(clientId?: number, timeoutMs?: number): Promise<Vimcord<true>>;
|
|
948
1268
|
readonly uuid: string;
|
|
949
1269
|
readonly clientId: number;
|
|
950
1270
|
readonly clientOptions: ClientOptions;
|
|
@@ -954,15 +1274,27 @@ declare class Vimcord<Ready extends boolean = boolean> extends Client<Ready> {
|
|
|
954
1274
|
readonly events: EventManager;
|
|
955
1275
|
readonly commands: CommandManager;
|
|
956
1276
|
db?: DatabaseManager;
|
|
957
|
-
logger: Logger & {
|
|
1277
|
+
readonly logger: Logger & {
|
|
958
1278
|
clientBanner(client: Vimcord): void;
|
|
959
1279
|
clientReady(clientTag: string, guildCount: number): void;
|
|
960
1280
|
moduleLoaded(moduleName: string, count?: number, ignoredCount?: number): void;
|
|
961
1281
|
commandExecuted(commandName: string, username: string, guildName?: string): void;
|
|
962
1282
|
database(action: string, details?: string): void;
|
|
963
1283
|
};
|
|
964
|
-
|
|
1284
|
+
readonly error: ErrorHandler;
|
|
965
1285
|
constructor(options: ClientOptions, features?: VimcordFeatures, config?: PartialDeep<VimcordConfig>);
|
|
1286
|
+
/** Current app name */
|
|
1287
|
+
get $name(): string;
|
|
1288
|
+
set $name(name: string);
|
|
1289
|
+
/** Current app version */
|
|
1290
|
+
get $version(): string;
|
|
1291
|
+
set $version(version: string);
|
|
1292
|
+
/** Current dev mode state */
|
|
1293
|
+
get $devMode(): boolean;
|
|
1294
|
+
set $devMode(mode: boolean);
|
|
1295
|
+
/** Current verbose mode state */
|
|
1296
|
+
get $verboseMode(): boolean;
|
|
1297
|
+
set $verboseMode(mode: boolean);
|
|
966
1298
|
/** Returns the options, features, and config of this client. */
|
|
967
1299
|
toJSON(): {
|
|
968
1300
|
options: ClientOptions;
|
|
@@ -970,93 +1302,90 @@ declare class Vimcord<Ready extends boolean = boolean> extends Client<Ready> {
|
|
|
970
1302
|
config: VimcordConfig;
|
|
971
1303
|
};
|
|
972
1304
|
/** Makes a clone of this client. */
|
|
973
|
-
clone(): Vimcord
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
importPrefixCommandModules(dir: string | string[], replaceAll?: boolean): Promise<this>;
|
|
982
|
-
importContextCommandModules(dir: string | string[], replaceAll?: boolean): Promise<this>;
|
|
983
|
-
useDatabase(db: DatabaseManager): Promise<boolean>;
|
|
984
|
-
waitForReady(): Promise<Vimcord<true>>;
|
|
1305
|
+
clone(): Vimcord;
|
|
1306
|
+
/**
|
|
1307
|
+
* Modifies a client config.
|
|
1308
|
+
* @param type The type of config to modify.
|
|
1309
|
+
* @param options The options to set for the config.
|
|
1310
|
+
*/
|
|
1311
|
+
configure<T extends keyof VimcordConfig>(type: T, options?: PartialDeep<VimcordConfig[T]>): this;
|
|
1312
|
+
/** Builds the client by importing modules and registering builtin handlers. */
|
|
985
1313
|
build(): Promise<this>;
|
|
986
|
-
/**
|
|
1314
|
+
/**
|
|
1315
|
+
* Imports modules into the client.
|
|
1316
|
+
* @param type The type of modules to import.
|
|
1317
|
+
* @param options The options to import the module with.
|
|
1318
|
+
* @param set Replaces already imported modules with the ones found.
|
|
1319
|
+
*/
|
|
1320
|
+
importModules<T extends keyof AppModuleImports>(type: T, options: AppModuleImports[T], set?: boolean): Promise<this>;
|
|
1321
|
+
/**
|
|
1322
|
+
* Allows Vimcord to handle environment variables using [dotenv](https://www.npmjs.com/package/dotenv).
|
|
1323
|
+
* @param options Options for dotenv
|
|
1324
|
+
* @see https://www.npmjs.com/package/dotenv
|
|
1325
|
+
*/
|
|
1326
|
+
useEnv(options?: DotenvConfigOptions): this;
|
|
1327
|
+
/**
|
|
1328
|
+
* Connects to a database.
|
|
1329
|
+
* @param db The database manager to use.
|
|
1330
|
+
*/
|
|
1331
|
+
useDatabase(db: DatabaseManager): Promise<boolean>;
|
|
1332
|
+
/**
|
|
1333
|
+
* Fetches a user from the client, checking the cache first.
|
|
1334
|
+
* @param userId The ID of the user to fetch.
|
|
1335
|
+
*/
|
|
1336
|
+
fetchUser(userId: string | undefined | null): Promise<discord_js.User | null>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Fetches a guild from the client, checking the cache first.
|
|
1339
|
+
* @param guildId The ID of the guild to fetch.
|
|
1340
|
+
*/
|
|
1341
|
+
fetchGuild(guildId: string | undefined | null): Promise<discord_js.Guild | null>;
|
|
1342
|
+
/**
|
|
1343
|
+
* Starts the client and connects to Discord.
|
|
1344
|
+
* Automatically uses `process.env.TOKEN` or `process.env.TOKEN_DEV` if token isn't provided.
|
|
1345
|
+
* @param token The Discord bot token.
|
|
1346
|
+
* @param callback Runs after logging in.
|
|
1347
|
+
*/
|
|
987
1348
|
start(token?: string): Promise<string | null>;
|
|
988
|
-
start(
|
|
989
|
-
start(token?: string,
|
|
1349
|
+
start(callback?: (client: Vimcord) => unknown): Promise<string | null>;
|
|
1350
|
+
start(token?: string, callback?: (client: Vimcord) => unknown): Promise<string | null>;
|
|
1351
|
+
/** Destroys the client and disconnects from Discord. */
|
|
990
1352
|
kill(): Promise<void>;
|
|
991
|
-
/** Shortcut for {@link fetchUser tools.fetchUser} */
|
|
992
|
-
fetchUser(id: string | undefined | null): Promise<User | null>;
|
|
993
|
-
/** Shortcut for {@link fetchGuild tools.fetchGuild} */
|
|
994
|
-
fetchGuild(id: string | undefined | null): Promise<Guild | null>;
|
|
995
1353
|
}
|
|
996
1354
|
|
|
997
|
-
declare
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
declare
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
/** Log whenever a command is executed? @defaultValue true */
|
|
1032
|
-
logExecution?: boolean;
|
|
1033
|
-
/** Executed before the main command logic */
|
|
1034
|
-
beforeExecute?: (...args: BaseCommandParameters<T>) => any;
|
|
1035
|
-
/** The main command function that will be executed */
|
|
1036
|
-
execute?: (...args: BaseCommandParameters<T>) => any;
|
|
1037
|
-
/** Executed after successful execution */
|
|
1038
|
-
afterExecute?: (result: any, ...args: BaseCommandParameters<T>) => any;
|
|
1039
|
-
/** Executed when the required permissions are not met */
|
|
1040
|
-
onMissingPermissions?: (results: CommandPermissionResults, ...args: BaseCommandParameters<T>) => any;
|
|
1041
|
-
/** Executed when the required conditions are not met */
|
|
1042
|
-
onConditionsNotMet?: (...args: BaseCommandParameters<T>) => any;
|
|
1043
|
-
/** Executed when this command is used when its disabled */
|
|
1044
|
-
onUsedWhenDisabled?: (...args: BaseCommandParameters<T>) => any;
|
|
1045
|
-
/** Executed when the rate limit is hit */
|
|
1046
|
-
onRateLimit?: (...args: BaseCommandParameters<T>) => any;
|
|
1047
|
-
/** Custom error handler */
|
|
1048
|
-
onError?: (error: Error, ...args: BaseCommandParameters<T>) => any;
|
|
1049
|
-
}
|
|
1050
|
-
interface BaseAppCommandConfig {
|
|
1051
|
-
/** Command deployment configuration */
|
|
1052
|
-
deployment?: AppCommandDeployment;
|
|
1053
|
-
}
|
|
1054
|
-
interface CommandInternalRateLimitData {
|
|
1055
|
-
/** Number of times executed */
|
|
1056
|
-
executions: number;
|
|
1057
|
-
/** Timestamp of latest execution */
|
|
1058
|
-
timestamp: number;
|
|
1059
|
-
}
|
|
1355
|
+
declare const clientLoggerFactory: (client: Vimcord) => Logger & {
|
|
1356
|
+
clientBanner(client: Vimcord): void;
|
|
1357
|
+
clientReady(clientTag: string, guildCount: number): void;
|
|
1358
|
+
moduleLoaded(moduleName: string, count?: number, ignoredCount?: number): void;
|
|
1359
|
+
commandExecuted(commandName: string, username: string, guildName?: string): void;
|
|
1360
|
+
database(action: string, details?: string): void;
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1363
|
+
declare const DEFAULT_MODULE_SUFFIXES: {
|
|
1364
|
+
readonly slashCommands: ".slash";
|
|
1365
|
+
readonly contextCommands: ".ctx";
|
|
1366
|
+
readonly prefixCommands: ".prefix";
|
|
1367
|
+
readonly events: ".event";
|
|
1368
|
+
};
|
|
1369
|
+
declare const configSetters: Record<keyof VimcordConfig, (options: PartialDeep<VimcordConfig[keyof VimcordConfig]>, existing?: VimcordConfig[keyof VimcordConfig]) => VimcordConfig[keyof VimcordConfig]>;
|
|
1370
|
+
declare const moduleImporters: Record<keyof AppModuleImports, (client: Vimcord, options: AppModuleImports[keyof AppModuleImports], set?: boolean) => any>;
|
|
1371
|
+
declare function defineClientOptions(options: ClientOptions): ClientOptions;
|
|
1372
|
+
declare function defineVimcordFeatures(features: VimcordFeatures): VimcordFeatures;
|
|
1373
|
+
declare function defineVimcordConfig(config: PartialDeep<VimcordConfig>): VimcordConfig;
|
|
1374
|
+
/**
|
|
1375
|
+
* Returns an instance of Vimcord.
|
|
1376
|
+
* @param clientId [default: 0]
|
|
1377
|
+
*/
|
|
1378
|
+
declare function useClient(clientId?: number): Vimcord<boolean> | undefined;
|
|
1379
|
+
/**
|
|
1380
|
+
* Waits for a Vimcord instance to be ready.
|
|
1381
|
+
* @param clientId [default: 0]
|
|
1382
|
+
* @param timeoutMs [default: 60000]
|
|
1383
|
+
*/
|
|
1384
|
+
declare function useReadyClient(clientId?: number, timeoutMs?: number): Promise<Vimcord<true>>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Creates a new instance of Vimcord.
|
|
1387
|
+
*/
|
|
1388
|
+
declare function createClient(options: discord_js.ClientOptions, features?: VimcordFeatures, config?: type_fest.PartialDeep<VimcordConfig>): Vimcord<boolean>;
|
|
1060
1389
|
|
|
1061
1390
|
declare abstract class BaseCommandBuilder<T extends CommandType, O extends BaseCommandConfig<T> = BaseCommandConfig<T>> {
|
|
1062
1391
|
readonly uuid: string;
|
|
@@ -1150,12 +1479,6 @@ declare abstract class BaseCommandBuilder<T extends CommandType, O extends BaseC
|
|
|
1150
1479
|
setOnError(callback: (error: Error, ...args: BaseCommandParameters<T>) => any): this;
|
|
1151
1480
|
}
|
|
1152
1481
|
|
|
1153
|
-
declare const BUILTIN_ContextCommandHandler: EventBuilder<"interactionCreate">;
|
|
1154
|
-
|
|
1155
|
-
declare const BUILTIN_PrefixCommandHandler: EventBuilder<"messageCreate">;
|
|
1156
|
-
|
|
1157
|
-
declare const BUILTIN_SlashCommandHandler: EventBuilder<"interactionCreate">;
|
|
1158
|
-
|
|
1159
1482
|
type MongoPlugin<Definition extends object> = (builder: MongoSchemaBuilder<Definition>) => void;
|
|
1160
1483
|
type ExtractReturn<T> = T extends (this: any, ...args: any) => infer R ? Awaited<R> : never;
|
|
1161
1484
|
type LeanOrHydratedDocument<T, O extends QueryOptions<T>> = O["lean"] extends false ? HydratedDocument<T> : Require_id<T>;
|
|
@@ -1278,6 +1601,14 @@ declare class MongoSchemaBuilder<Definition extends object = any> {
|
|
|
1278
1601
|
}>;
|
|
1279
1602
|
}
|
|
1280
1603
|
|
|
1604
|
+
declare const contextCommandHandler: EventBuilder<"interactionCreate">;
|
|
1605
|
+
|
|
1606
|
+
declare const prefixCommandHandler: EventBuilder<"messageCreate">;
|
|
1607
|
+
|
|
1608
|
+
declare const slashCommandHandler: EventBuilder<"interactionCreate">;
|
|
1609
|
+
|
|
1610
|
+
declare function validateCommandPermissions(permissions: CommandPermissions, client: Vimcord<true>, user: GuildMember | User, command: CommandInteraction | string): CommandPermissionResults;
|
|
1611
|
+
|
|
1281
1612
|
interface BetterCollectorOptions<T extends MessageComponentType> {
|
|
1282
1613
|
type?: T;
|
|
1283
1614
|
participants?: UserResolvable$1[];
|
|
@@ -1653,7 +1984,7 @@ declare function cleanMention(str: string | undefined): string | undefined;
|
|
|
1653
1984
|
* @param content - The message's clean content to parse. Will be used if message.mentions isn't populated.
|
|
1654
1985
|
* @param type - The type of mention.
|
|
1655
1986
|
* @param index - The argument index in the content. Default is `0`
|
|
1656
|
-
* @param idOnly - Whether to return the ID instead of the
|
|
1987
|
+
* @param idOnly - Whether to return the ID instead of the fetched object. */
|
|
1657
1988
|
declare function getMessageMention<M extends Message, T extends MentionType>(message: M, content: string | undefined | null, type: T, index: number, idOnly: true): Promise<string | null>;
|
|
1658
1989
|
declare function getMessageMention<M extends Message, T extends MentionType>(message: M, content: string | undefined | null, type: T, index?: number, idOnly?: false): Promise<FetchedMessageMention<T, M extends Message<true> ? true : false> | null>;
|
|
1659
1990
|
/** Get the ID of the first mention of a specified type from a message or message content.
|
|
@@ -1682,19 +2013,37 @@ declare function fetchMember(guild: Guild, memberId: string | undefined | null):
|
|
|
1682
2013
|
* @param channelId - The ID of the channel to fetch.
|
|
1683
2014
|
* @param type - The type of channel to fetch. */
|
|
1684
2015
|
declare function fetchChannel<T extends ChannelType>(guild: Guild, channelId: string | undefined | null, type?: T): Promise<FetchedChannel<T> | null>;
|
|
1685
|
-
/** Fetch a role from a guild, checking the cache first.
|
|
1686
|
-
* @param guild - The guild to fetch the role from.
|
|
1687
|
-
* @param roleId - The ID of the role to fetch. */
|
|
1688
|
-
declare function fetchRole(guild: Guild, roleId: string | undefined | null): Promise<Role | null>;
|
|
1689
2016
|
/** Fetch a message from a channel, checking the cache first.
|
|
1690
2017
|
* @param channel - The channel to fetch the message from.
|
|
1691
2018
|
* @param messageId - The ID of the message to fetch. */
|
|
1692
2019
|
declare function fetchMessage(channel: GuildTextBasedChannel | VoiceBasedChannel, messageId: string | undefined | null): Promise<Message | null>;
|
|
2020
|
+
/** Fetch a role from a guild, checking the cache first.
|
|
2021
|
+
* @param guild - The guild to fetch the role from.
|
|
2022
|
+
* @param roleId - The ID of the role to fetch. */
|
|
2023
|
+
declare function fetchRole(guild: Guild, roleId: string | undefined | null): Promise<Role | null>;
|
|
2024
|
+
|
|
2025
|
+
declare function sendCommandErrorEmbed(client: Vimcord, error: Error, guild: Guild | null | undefined, messageOrInteraction: Message | CommandInteraction): Promise<Message<boolean> | null>;
|
|
2026
|
+
|
|
2027
|
+
declare function createConfigFactory<T>(defaultConfig: T, validate?: (config: T) => void): (options?: PartialDeep<T>, existing?: T) => T;
|
|
2028
|
+
|
|
2029
|
+
declare function getProcessDir(): string;
|
|
2030
|
+
declare function importModulesFromDir<T extends any>(dir: string, suffix?: string): Promise<{
|
|
2031
|
+
module: T;
|
|
2032
|
+
path: string;
|
|
2033
|
+
}[]>;
|
|
2034
|
+
|
|
2035
|
+
/** Reads the `package.json` file from the current working directory. */
|
|
2036
|
+
declare function getPackageJson(): any;
|
|
2037
|
+
/** Checks if the process was ran using the `--dev` flag. */
|
|
2038
|
+
declare function getDevMode(): boolean;
|
|
1693
2039
|
|
|
2040
|
+
type VimcordCLIMode = "on" | "off";
|
|
1694
2041
|
interface VimcordCLIOptions {
|
|
1695
2042
|
prefix: string;
|
|
1696
2043
|
}
|
|
1697
2044
|
declare class VimcordCLI {
|
|
2045
|
+
static mode: VimcordCLIMode;
|
|
2046
|
+
static setMode(mode: VimcordCLIMode): void;
|
|
1698
2047
|
rl: Interface;
|
|
1699
2048
|
options: VimcordCLIOptions;
|
|
1700
2049
|
commands: Map<string, {
|
|
@@ -1708,24 +2057,6 @@ declare class VimcordCLI {
|
|
|
1708
2057
|
addCommand(commandName: string, description: string, fn: (args: string[], content: string) => void): void;
|
|
1709
2058
|
removeCommand(commandName: string): boolean;
|
|
1710
2059
|
}
|
|
1711
|
-
declare
|
|
1712
|
-
/** One-time function to be called during client creation */
|
|
1713
|
-
declare function initCLI(): void;
|
|
1714
|
-
|
|
1715
|
-
type VimcordConfigOptions = PartialDeep<VimcordConfig>;
|
|
1716
|
-
declare function useClient(clientId?: number): Vimcord<boolean> | undefined;
|
|
1717
|
-
declare function useReadyClient(clientId?: number): Promise<Vimcord<true> | undefined>;
|
|
1718
|
-
declare function createClient(options: ClientOptions, features?: VimcordFeatures, config?: VimcordConfigOptions): Vimcord<boolean>;
|
|
1719
|
-
|
|
1720
|
-
declare function getCallerFileName(): string | undefined;
|
|
1721
|
-
declare function getProcessDir(): string;
|
|
1722
|
-
declare function importModulesFromDir<T extends any>(dir: string, suffix?: string): Promise<{
|
|
1723
|
-
module: T;
|
|
1724
|
-
path: string;
|
|
1725
|
-
}[]>;
|
|
1726
|
-
|
|
1727
|
-
declare function sendCommandErrorEmbed(client: Vimcord, error: Error, guild: Guild | null | undefined, messageOrInteraction: Message | CommandInteraction): Promise<Message<boolean> | null>;
|
|
1728
|
-
|
|
1729
|
-
declare function validateCommandPermissions(permissions: CommandPermissions, client: Vimcord<true>, user: GuildMember | User, command: CommandInteraction | string): CommandPermissionResults;
|
|
2060
|
+
declare let CLI: VimcordCLI;
|
|
1730
2061
|
|
|
1731
|
-
export { type AnySlashCommandBuilder, type AppCommandDeployment, type AppConfig, type
|
|
2062
|
+
export { type AnySlashCommandBuilder, type AppCommandDeployment, type AppConfig, type AppModuleImports, type AwaitSubmitOptions, type BaseAppCommandConfig, BaseCommandBuilder, type BaseCommandConfig, BaseCommandManager, type BaseCommandParameters, type BetterChannelSelectComponent, BetterCollector, type BetterCollectorOptions, BetterContainer, type BetterContainerData, BetterEmbed, type BetterEmbedAuthor, type BetterEmbedContext, type BetterEmbedData, type BetterEmbedFooter, type BetterEmbedTitle, type BetterFileUploadSelectComponent, type BetterMentionableSelectComponent, BetterModal, type BetterModalComponent, type BetterModalOptions, type BetterRoleSelectComponent, type BetterStringSelectComponent, type BetterTextInputComponent, type BetterUserSelectComponent, type ButtonHandler, CLI, type Chapter, type ChapterData, type ClientActivity, type ClientStatus, CollectorTimeoutType, type CommandByCategory, type CommandErrorMessageConfig, type CommandFilter, type CommandInternalRateLimitData, CommandManager, type CommandMetadata, type CommandPermissionResults, type CommandPermissions, type CommandRateLimitOptions, CommandType, ContextCommandBuilder, type ContextCommandConfig, ContextCommandManager, type CustomButton, DEFAULT_MODULE_SUFFIXES, type DatabaseManager, DynaSend, type DynaSendOptions, type EmbedResolvable, ErrorHandler, EventBuilder, type EventConfig, type EventDeployment, EventManager, type EventMetadata, type EventParameters, type EventRateLimitOptions, type ExtractReturn, type FetchedChannel, type FetchedMessageMention, type GetMessageMentionOptions, type InteractionBasedSendHandler, type InteractionResolveable, LOGGER_COLORS, type LeanOrHydratedDocument, type ListenerOptions, LogLevel, Logger, type LoggerOptions, type MentionType, MissingPermissionReason, type ModalSubmitResult, type ModuleImportOptions, ModuleImporter, MongoDatabase, type MongoPlugin, MongoSchemaBuilder, type MongoSchemaOptions, type PageIndex, type PageResolvable, type PaginationEvent, PaginationTimeoutType, PaginationType, Paginator, type PaginatorData, type PaginatorOptions, PrefixCommandBuilder, type PrefixCommandConfig, PrefixCommandManager, Prompt, type PromptOptions, PromptResolveType, type PromptResult, RateLimitScope, type RequiredDynaSendOptions, type SendHandler, SendMethod, type SendableComponent, type SendableTextChannel, type SinglePageResolvable, SlashCommandBuilder, type SlashCommandConfig, SlashCommandManager, type StaffConfig, StatusManager, StatusType, type ToolsConfig, type UserResolvable, Vimcord, VimcordCLI, type VimcordCLIMode, type VimcordCLIOptions, type VimcordClientStatus, type VimcordCommandBuilderByType, type VimcordConfig, type VimcordCreateConfig, type VimcordFeatures, __zero, cleanMention, clientLoggerFactory, configSetters, contextCommandHandler, createAppConfig, createClient, createConfigFactory, createContextCommandConfig, createMongoPlugin, createMongoSchema, createPrefixCommandConfig, createSlashCommandConfig, createStaffConfig, createToolsConfig, createVimcordStatusConfig, defineClientOptions, defineGlobalToolsConfig, defineVimcordConfig, defineVimcordFeatures, dynaSend, fetchChannel, fetchGuild, fetchMember, fetchMessage, fetchRole, fetchUser, getDevMode, getFirstMentionId, getMessageMention, getPackageJson, getProcessDir, globalToolsConfig, importModulesFromDir, isMentionOrSnowflake, logger, moduleImporters, prefixCommandHandler, prompt, sendCommandErrorEmbed, slashCommandHandler, useClient, useReadyClient, validateCommandPermissions };
|