This repository has been archived by the owner on Nov 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Types.ts
110 lines (101 loc) · 3.13 KB
/
Types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import {
Message,
Client,
Emoji,
User,
MessageReaction,
PartialUser,
Snowflake,
} from 'discord.js';
/** A command that is triggered by the prefix followed by the name.
* Can be locked down to certain users or admins
*/
export type Command = {
/** The command trigger */
name: string;
/** A description of the arguments that this command takes, to display in the help menu */
args?: string;
/** Aliases for the command */
aliases?: Array<string>;
/** The description to display in the Help menu */
description?: string;
/** Should the command only work in a guild */
guildOnly?: boolean;
/** Command permissions, should effectively default to `public` */
requiredPerms?: 'public' | 'admin' | 'whitelist';
/** Whitelist */
whitelist?: Array<TypedSnowflake>;
/**
* The minimum number of args needed for the command
*/
minArgs?: number;
/** The code to run when triggered */
execute(
message: Message,
args: Array<string>,
client: Client
): Promise<void>;
};
/** A command that is triggered by a keyword within the message or something else */
export type TriggeredCommand = {
// TODO: Create a better name for this type
/** Determines if the message will trigger the command
* If `trigger` is a `String`, it will check if it is in the message (`message.content.includes(...)`)
* If `trigger` is a `RegExp`, it will be run against the message and the result will be passed to `execute(...)` in `args`
* If `trigger` is a `Function`, `execute` will be run if it returns `true`
*/
trigger: string | RegExp | TriggerDeterminer;
/** The code to run when triggered */
execute(message: Message, args: string[]): Promise<void>;
};
export type EditCommand = {
execute(oldMessage: Message, newMessage: Message): void;
};
export type ReactionCommand = {
trigger: string | Emoji | Array<string> | Array<Emoji>;
execute(
reaction: MessageReaction,
user: User | PartialUser,
args: unknown
): void;
};
/** A regular Discord.js `Snowflake`, but with a type annotation in front of it so it can select the right way to check
* `&` for a role
* nothing for a user
* eg.
* `716118096355786763` PDunks
* `&662365105559699487` Bot Boi in the school server
*/
export type TypedSnowflake = string;
export type TriggerDeterminer = (
message: Message
) => boolean | RegExpMatchArray | unknown;
/** Leaderboard Level Data */
export type LevelData = {
/** Message Count */
count: number;
/** Experience Points in Level */
xp: number;
/** Level Number */
level: number;
/** Timestamp of last message */
last: Date;
};
export type Config = {
prefix: string;
token: string;
memberCountGuild?: {
guild: string;
channel: string;
};
levels?: {
db?: string;
xpRange: number[];
timeout: number;
leaderboardCooldown: number;
commandChannels?: { [key: string]: string | string[] };
ignorePrefix: string[];
};
vcPing?: { [key: string]: string };
modMail: Snowflake;
};