ahegao 1.69.46 → 1.69.48
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/dist/index.d.ts +9 -0
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -0
- package/dist/json/downside.json +75 -0
- package/dist/json/hiragana.json +527 -0
- package/dist/json/homoglyphs.json +31790 -0
- package/dist/json/letterArray.json +254 -0
- package/dist/json/superscript.json +96 -0
- package/dist/json/upside.json +78 -0
- package/dist/structures/structs.d.ts +77 -0
- package/dist/structures/structs.js +46 -45
- package/dist/structures/structs.js.map +1 -0
- package/dist/types/classes.d.ts +214 -0
- package/dist/types/classes.js +121 -122
- package/dist/types/classes.js.map +1 -0
- package/dist/types/discord_classes.d.ts +93 -0
- package/dist/types/discord_classes.js +140 -106
- package/dist/types/discord_classes.js.map +1 -0
- package/dist/types/discord_fields.d.ts +27 -0
- package/dist/types/discord_fields.js +28 -24
- package/dist/types/discord_fields.js.map +1 -0
- package/dist/types/discord_types.d.ts +51 -0
- package/dist/types/discord_types.js +6 -4
- package/dist/types/discord_types.js.map +1 -0
- package/dist/types/fields.d.ts +163 -0
- package/dist/types/fields.js +238 -232
- package/dist/types/fields.js.map +1 -0
- package/dist/types/types.d.ts +99 -0
- package/dist/types/types.js +3 -1
- package/dist/types/types.js.map +1 -0
- package/dist/utils/discord-util.d.ts +198 -0
- package/dist/utils/discord-util.js +370 -235
- package/dist/utils/discord-util.js.map +1 -0
- package/dist/utils/util.d.ts +504 -0
- package/dist/utils/util.js +1146 -694
- package/dist/utils/util.js.map +1 -0
- package/package.json +56 -57
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Channel, Client, Collection, Guild, GuildBasedChannel, GuildMember, InteractionReplyOptions, Message, MessagePayload, MessageReference, TextBasedChannel, TextChannel, ThreadChannel, User } from "discord.js";
|
|
2
|
+
import { CommandType, SendOptions, StringCommandFunction } from "./discord_types";
|
|
3
|
+
import { MESSAGE_TYPE, RECIPIENT_TYPE } from "./discord_fields";
|
|
4
|
+
import { ExtendedInteraction, MessageType } from "../utils/discord-util";
|
|
5
|
+
import { OneOrMoreArray } from "../structures/structs";
|
|
6
|
+
export declare class BaseDiscordClient extends Client {
|
|
7
|
+
readonly stringCommandsMap: Map<string, StringCommand>;
|
|
8
|
+
readonly stringCommandsSendOptions: Map<string, SendOptions>;
|
|
9
|
+
readonly stringCommandsSet: Set<StringCommand>;
|
|
10
|
+
readonly stringCommandsNamesSet: Set<string>;
|
|
11
|
+
readonly commands: Collection<string, CommandType>;
|
|
12
|
+
private noAccessGuilds;
|
|
13
|
+
private noAccessChannels;
|
|
14
|
+
private noAccessMessages;
|
|
15
|
+
private userCache;
|
|
16
|
+
private channelCache;
|
|
17
|
+
private slashCommands;
|
|
18
|
+
private readyToPostReactionQueue;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly nameLower: string;
|
|
21
|
+
protected styledName: string;
|
|
22
|
+
protected styledNameLower: string;
|
|
23
|
+
protected fgColor: import("chalk").Chalk;
|
|
24
|
+
readonly defaultEmbedColor: number;
|
|
25
|
+
startMessage: string;
|
|
26
|
+
private starting;
|
|
27
|
+
private started;
|
|
28
|
+
constructor(name: string);
|
|
29
|
+
get userId(): string;
|
|
30
|
+
setDefaultStartMessage(): void;
|
|
31
|
+
setFgColor(chalkColor: any): void;
|
|
32
|
+
isStartedOrStarting(): boolean;
|
|
33
|
+
onBeforeStart(): Promise<void>;
|
|
34
|
+
onAfterStart(): Promise<void>;
|
|
35
|
+
onAfterCacheInit(): Promise<void>;
|
|
36
|
+
getPreviousMessageOfChannel(channel: TextBasedChannel, indexFromLast?: number): Promise<Message<boolean>>;
|
|
37
|
+
start(token: string, resourcesPath: string): Promise<void>;
|
|
38
|
+
onStartFail(): void;
|
|
39
|
+
onError(error: Error): void;
|
|
40
|
+
importFile(filePath: string): Promise<any>;
|
|
41
|
+
private registerToDiscord;
|
|
42
|
+
protected registerBotEvents(resourcesPath: string): Promise<void>;
|
|
43
|
+
log(message?: any): void;
|
|
44
|
+
private onReady;
|
|
45
|
+
protected registerEverything(resourcesPath: string): Promise<void>;
|
|
46
|
+
protected registerSlashCommands(resourcesPath: string): Promise<void>;
|
|
47
|
+
protected registerStringCommands(resourcesPath: string): Promise<void>;
|
|
48
|
+
protected registerEvents(resourcesPath: string): Promise<void>;
|
|
49
|
+
edit(message: Message<boolean>, newContent: string): Promise<Message<boolean>>;
|
|
50
|
+
send(recipient: RECIPIENT_TYPE, message: MESSAGE_TYPE, options?: SendOptions): Promise<Message<boolean>>;
|
|
51
|
+
onEditedToReal(message: Message<boolean>): Promise<void>;
|
|
52
|
+
getUwuChance(): number;
|
|
53
|
+
getAiInterpretationChance(): number;
|
|
54
|
+
getAiRandomScenarioChance(): number;
|
|
55
|
+
sendToById(message: MESSAGE_TYPE, channelId: string, options?: SendOptions): Promise<Message<boolean>>;
|
|
56
|
+
trySendToById(messages: string[], channelId: string, options?: SendOptions): Promise<boolean>;
|
|
57
|
+
sendToByName(message: string | MessagePayload, guildId: string, channelName: string): Promise<Message<boolean>>;
|
|
58
|
+
dmUserById(userId: string, message: MESSAGE_TYPE): Promise<Message<boolean>>;
|
|
59
|
+
getOrCreateChannelByGuildName(guild: Guild, channelName: string): Promise<TextBasedChannel>;
|
|
60
|
+
findChannelByGuildName(guild: Guild, channelName: string): Promise<TextBasedChannel>;
|
|
61
|
+
findChannelByGuildIdName(guildId: string, channelName: string): Promise<TextBasedChannel>;
|
|
62
|
+
findGuildById(guildId: string): Promise<Guild>;
|
|
63
|
+
findMemberByGuildIdAndId(guildId: string, userId: string): Promise<GuildMember>;
|
|
64
|
+
findMemberByGuildAndId(guild: Guild, userId: string): Promise<GuildMember>;
|
|
65
|
+
findUserById(userId: string): Promise<User>;
|
|
66
|
+
findChannelById(channelId: string): Promise<Channel>;
|
|
67
|
+
memberHasRole(member: GuildMember, roleId: string): boolean;
|
|
68
|
+
trySetNickname(member: GuildMember, newName: string): Promise<boolean>;
|
|
69
|
+
followUp(interaction: ExtendedInteraction, options: string | MessagePayload | InteractionReplyOptions): Promise<Message<boolean>>;
|
|
70
|
+
renameGuildById(guildId: string, name: string): Promise<boolean>;
|
|
71
|
+
renameChannelById(channelId: string, name: string): Promise<boolean>;
|
|
72
|
+
renameMemberByGuildIdAndId(guildId: string, memberId: string, name: string): Promise<boolean>;
|
|
73
|
+
referenceToString(reference: MessageReference): Promise<string>;
|
|
74
|
+
delete(message: MessageType): Promise<boolean>;
|
|
75
|
+
setChannelMessagesTo(channel: TextChannel | ThreadChannel, msgs: string[]): Promise<void>;
|
|
76
|
+
stopIfDev(interaction: ExtendedInteraction): boolean;
|
|
77
|
+
stopIfNotTextChannel(interaction: ExtendedInteraction, channel: Channel): channel is Exclude<any, TextChannel>;
|
|
78
|
+
getUserNameById(userId: string): Promise<string>;
|
|
79
|
+
get loadingMessage(): string;
|
|
80
|
+
forEveryServer(doThis: (guild: Guild) => void | Promise<void>): Promise<void>;
|
|
81
|
+
forEveryMember(doThis: (member: GuildMember, guild: Guild) => void | Promise<void>): Promise<void>;
|
|
82
|
+
forEveryChannel(doThis: (channel: GuildBasedChannel, guild: Guild) => void | Promise<void>): Promise<void>;
|
|
83
|
+
getAllMembers(): Promise<Set<GuildMember>>;
|
|
84
|
+
getAllUsers(): Promise<Set<User>>;
|
|
85
|
+
getAllChannels(): Promise<Set<GuildBasedChannel>>;
|
|
86
|
+
}
|
|
87
|
+
export declare class StringCommand {
|
|
88
|
+
readonly name: OneOrMoreArray<string>;
|
|
89
|
+
readonly description: string;
|
|
90
|
+
readonly run: StringCommandFunction;
|
|
91
|
+
readonly options: SendOptions;
|
|
92
|
+
constructor(name: OneOrMoreArray<string>, description: string, run: StringCommandFunction, options?: SendOptions);
|
|
93
|
+
}
|
|
@@ -1,37 +1,68 @@
|
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.StringCommand = exports.BaseDiscordClient = void 0;
|
|
37
|
+
const util_1 = require("../utils/util");
|
|
38
|
+
const discord_js_1 = require("discord.js");
|
|
39
|
+
const discord_fields_1 = require("./discord_fields");
|
|
40
|
+
const discord_util_1 = require("../utils/discord-util");
|
|
41
|
+
const fields_1 = require("./fields");
|
|
42
|
+
const mathjs_1 = require("mathjs");
|
|
43
|
+
class BaseDiscordClient extends discord_js_1.Client {
|
|
29
44
|
constructor(name) {
|
|
30
45
|
super({
|
|
31
46
|
intents: 4194303,
|
|
32
47
|
closeTimeout: 120000,
|
|
33
48
|
waitGuildTimeout: 120000,
|
|
34
49
|
});
|
|
50
|
+
this.stringCommandsMap = new Map;
|
|
51
|
+
this.stringCommandsSendOptions = new Map;
|
|
52
|
+
this.stringCommandsSet = new Set;
|
|
53
|
+
this.stringCommandsNamesSet = new Set;
|
|
54
|
+
this.commands = new discord_js_1.Collection();
|
|
55
|
+
this.noAccessGuilds = new Set();
|
|
56
|
+
this.noAccessChannels = new Set();
|
|
57
|
+
this.noAccessMessages = new Set();
|
|
58
|
+
this.userCache = new Map();
|
|
59
|
+
this.channelCache = new Map();
|
|
60
|
+
this.slashCommands = [];
|
|
61
|
+
this.readyToPostReactionQueue = true;
|
|
62
|
+
this.fgColor = util_1.chalk.whiteBright;
|
|
63
|
+
this.defaultEmbedColor = 0xff0077;
|
|
64
|
+
this.starting = false;
|
|
65
|
+
this.started = false;
|
|
35
66
|
// super({ intents: [32767, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages, GatewayIntentBits.DirectMessages] })
|
|
36
67
|
this.name = name;
|
|
37
68
|
this.styledName = this.fgColor(this.name);
|
|
@@ -98,12 +129,14 @@ export class BaseDiscordClient extends Client {
|
|
|
98
129
|
this.log(`Error: ${error.name}\n${error.stack ? `${error.stack}\n` : ""}${error.cause ? `${error.cause}\n` : ""}${error.message}`);
|
|
99
130
|
}
|
|
100
131
|
async importFile(filePath) {
|
|
101
|
-
|
|
132
|
+
var _a;
|
|
133
|
+
return (_a = (await Promise.resolve(`${filePath}`).then(s => __importStar(require(s))))) === null || _a === void 0 ? void 0 : _a.default;
|
|
102
134
|
}
|
|
103
135
|
async registerToDiscord({ commands, guildId }) {
|
|
136
|
+
var _a;
|
|
104
137
|
if (guildId) {
|
|
105
|
-
await this.guilds.cache.get(guildId)
|
|
106
|
-
this.log(`Registering ${commands.length} ${STYLED_SLASH_COMMANDS} to ${guildId}`);
|
|
138
|
+
await ((_a = this.guilds.cache.get(guildId)) === null || _a === void 0 ? void 0 : _a.commands.set(commands));
|
|
139
|
+
this.log(`Registering ${commands.length} ${discord_fields_1.STYLED_SLASH_COMMANDS} to ${guildId}`);
|
|
107
140
|
}
|
|
108
141
|
else {
|
|
109
142
|
await this.application.commands.set(commands);
|
|
@@ -115,7 +148,7 @@ export class BaseDiscordClient extends Client {
|
|
|
115
148
|
}
|
|
116
149
|
log(message) {
|
|
117
150
|
// print(`${toStamp((Date.now() / 1000 % SECONDS_IN_DAY + SERVER_TIMEZONE_OFFSET_H * 3600) % SECONDS_IN_DAY)} ${this.styledName}: ${message}`)
|
|
118
|
-
print(message);
|
|
151
|
+
(0, util_1.print)(message);
|
|
119
152
|
}
|
|
120
153
|
async onReady(resourcesPath) {
|
|
121
154
|
await this.registerEverything(resourcesPath);
|
|
@@ -133,7 +166,7 @@ export class BaseDiscordClient extends Client {
|
|
|
133
166
|
await this.registerEvents(resourcesPath);
|
|
134
167
|
}
|
|
135
168
|
async registerSlashCommands(resourcesPath) {
|
|
136
|
-
const slashCommandsPath = makeUnixPath(resourcesPath, "slash_commands");
|
|
169
|
+
const slashCommandsPath = (0, util_1.makeUnixPath)(resourcesPath, "slash_commands");
|
|
137
170
|
this.log(`Registering ${this.styledNameLower}...`);
|
|
138
171
|
const registeredCommands = new Set();
|
|
139
172
|
//Slash Commands
|
|
@@ -156,7 +189,7 @@ export class BaseDiscordClient extends Client {
|
|
|
156
189
|
}
|
|
157
190
|
}
|
|
158
191
|
if (registeredCommands.has(command.name)) {
|
|
159
|
-
this.log(`${STYLED_WARNING}: Duplicate ${STYLED_SLASH_COMMAND} ${command.name}. ${chalk.underline(chalk.whiteBright("Skipping!"))}`);
|
|
192
|
+
this.log(`${discord_fields_1.STYLED_WARNING}: Duplicate ${discord_fields_1.STYLED_SLASH_COMMAND} ${command.name}. ${util_1.chalk.underline(util_1.chalk.whiteBright("Skipping!"))}`);
|
|
160
193
|
return;
|
|
161
194
|
}
|
|
162
195
|
// this.log(`Registering ${STYLED_SLASH_COMMAND} ${command.name}`)
|
|
@@ -164,30 +197,30 @@ export class BaseDiscordClient extends Client {
|
|
|
164
197
|
this.slashCommands.push(command);
|
|
165
198
|
registeredCommands.add(command.name);
|
|
166
199
|
};
|
|
167
|
-
const myCommandFilesPath = makeUnixPath(slashCommandsPath, this.nameLower, "*{.ts,.js}");
|
|
168
|
-
dogPaths(`myCommandFilesPath: "${myCommandFilesPath}"`);
|
|
169
|
-
const myCommandFiles = await globPromise(myCommandFilesPath);
|
|
200
|
+
const myCommandFilesPath = (0, util_1.makeUnixPath)(slashCommandsPath, this.nameLower, "*{.ts,.js}");
|
|
201
|
+
(0, util_1.dogPaths)(`myCommandFilesPath: "${myCommandFilesPath}"`);
|
|
202
|
+
const myCommandFiles = await (0, fields_1.globPromise)(myCommandFilesPath);
|
|
170
203
|
for (const slashCommand of myCommandFiles) {
|
|
171
204
|
await slashCommandRegisterer(slashCommand);
|
|
172
205
|
}
|
|
173
|
-
const sharedCommandFilesPath = makeUnixPath(slashCommandsPath, "shared", "*{.ts,.js}");
|
|
174
|
-
dogPaths(`sharedCommandFilesPath: "${sharedCommandFilesPath}"`);
|
|
175
|
-
const sharedCommandFiles = await globPromise(sharedCommandFilesPath);
|
|
206
|
+
const sharedCommandFilesPath = (0, util_1.makeUnixPath)(slashCommandsPath, "shared", "*{.ts,.js}");
|
|
207
|
+
(0, util_1.dogPaths)(`sharedCommandFilesPath: "${sharedCommandFilesPath}"`);
|
|
208
|
+
const sharedCommandFiles = await (0, fields_1.globPromise)(sharedCommandFilesPath);
|
|
176
209
|
for (const slashCommand of sharedCommandFiles) {
|
|
177
210
|
await slashCommandRegisterer(slashCommand);
|
|
178
211
|
}
|
|
179
212
|
const slashCommandsCount = myCommandFiles.length + sharedCommandFiles.length;
|
|
180
213
|
if (slashCommandsCount > 0) {
|
|
181
|
-
this.log(`Registered ${slashCommandsCount} ${if1Else(slashCommandsCount, STYLED_SLASH_COMMAND, STYLED_SLASH_COMMANDS)}.`);
|
|
214
|
+
this.log(`Registered ${slashCommandsCount} ${(0, util_1.if1Else)(slashCommandsCount, discord_fields_1.STYLED_SLASH_COMMAND, discord_fields_1.STYLED_SLASH_COMMANDS)}.`);
|
|
182
215
|
}
|
|
183
216
|
}
|
|
184
217
|
async registerStringCommands(resourcesPath) {
|
|
185
|
-
const stringCommandsPath = makeUnixPath(resourcesPath, "string_commands");
|
|
218
|
+
const stringCommandsPath = (0, util_1.makeUnixPath)(resourcesPath, "string_commands");
|
|
186
219
|
const stringCommandRegisterer = async (filePath) => {
|
|
187
220
|
const stringCommand = await this.importFile(filePath);
|
|
188
221
|
for (const name of stringCommand.name) {
|
|
189
222
|
if (this.stringCommandsMap.has(name)) {
|
|
190
|
-
this.log(`${STYLED_WARNING}: Duplicate ${STYLED_STRING_COMMAND} name ${name}!`);
|
|
223
|
+
this.log(`${discord_fields_1.STYLED_WARNING}: Duplicate ${discord_fields_1.STYLED_STRING_COMMAND} name ${name}!`);
|
|
191
224
|
continue;
|
|
192
225
|
}
|
|
193
226
|
this.stringCommandsMap.set(name, stringCommand);
|
|
@@ -201,25 +234,25 @@ export class BaseDiscordClient extends Client {
|
|
|
201
234
|
}
|
|
202
235
|
};
|
|
203
236
|
//String Commands
|
|
204
|
-
const myStringCommandFilesPath = makeUnixPath(stringCommandsPath, this.nameLower, "*{.ts,.js}");
|
|
205
|
-
dogPaths(`myStringCommandFilesPath: "${myStringCommandFilesPath}"`);
|
|
206
|
-
const myStringCommandFiles = await globPromise(myStringCommandFilesPath);
|
|
237
|
+
const myStringCommandFilesPath = (0, util_1.makeUnixPath)(stringCommandsPath, this.nameLower, "*{.ts,.js}");
|
|
238
|
+
(0, util_1.dogPaths)(`myStringCommandFilesPath: "${myStringCommandFilesPath}"`);
|
|
239
|
+
const myStringCommandFiles = await (0, fields_1.globPromise)(myStringCommandFilesPath);
|
|
207
240
|
for (const stringCommand of myStringCommandFiles) {
|
|
208
241
|
await stringCommandRegisterer(stringCommand);
|
|
209
242
|
}
|
|
210
|
-
const sharedStringCommandFilesPath = makeUnixPath(stringCommandsPath, "shared", "*{.ts,.js}");
|
|
211
|
-
const sharedStringCommandFiles = await globPromise(sharedStringCommandFilesPath);
|
|
212
|
-
dogPaths(`sharedStringCommandFilesPath: "${sharedStringCommandFilesPath}"`);
|
|
243
|
+
const sharedStringCommandFilesPath = (0, util_1.makeUnixPath)(stringCommandsPath, "shared", "*{.ts,.js}");
|
|
244
|
+
const sharedStringCommandFiles = await (0, fields_1.globPromise)(sharedStringCommandFilesPath);
|
|
245
|
+
(0, util_1.dogPaths)(`sharedStringCommandFilesPath: "${sharedStringCommandFilesPath}"`);
|
|
213
246
|
for (const stringCommand of sharedStringCommandFiles) {
|
|
214
247
|
await stringCommandRegisterer(stringCommand);
|
|
215
248
|
}
|
|
216
249
|
const stringCommandsCount = myStringCommandFiles.length + sharedStringCommandFiles.length;
|
|
217
250
|
if (stringCommandsCount > 0) {
|
|
218
|
-
this.log(`Registered ${stringCommandsCount} ${if1Else(stringCommandsCount, STYLED_STRING_COMMAND, STYLED_STRING_COMMANDS)}.`);
|
|
251
|
+
this.log(`Registered ${stringCommandsCount} ${(0, util_1.if1Else)(stringCommandsCount, discord_fields_1.STYLED_STRING_COMMAND, discord_fields_1.STYLED_STRING_COMMANDS)}.`);
|
|
219
252
|
}
|
|
220
253
|
}
|
|
221
254
|
async registerEvents(resourcesPath) {
|
|
222
|
-
const eventsPath = makeUnixPath(resourcesPath, "events");
|
|
255
|
+
const eventsPath = (0, util_1.makeUnixPath)(resourcesPath, "events");
|
|
223
256
|
//Event
|
|
224
257
|
const eventRegisterer = async (filePath) => {
|
|
225
258
|
const event = await this.importFile(filePath);
|
|
@@ -229,41 +262,42 @@ export class BaseDiscordClient extends Client {
|
|
|
229
262
|
this.on(event.event, (...args) => event.run(this, ...args));
|
|
230
263
|
// this.log(`Registering ${STYLED_EVENT} ${event.event}`)
|
|
231
264
|
};
|
|
232
|
-
const myEventFilesPath = makeUnixPath(eventsPath, this.nameLower, "*{.ts,.js}");
|
|
233
|
-
dogPaths(`myEventFilesPath: "${myEventFilesPath}"`);
|
|
234
|
-
const myEventFiles = await globPromise(myEventFilesPath);
|
|
265
|
+
const myEventFilesPath = (0, util_1.makeUnixPath)(eventsPath, this.nameLower, "*{.ts,.js}");
|
|
266
|
+
(0, util_1.dogPaths)(`myEventFilesPath: "${myEventFilesPath}"`);
|
|
267
|
+
const myEventFiles = await (0, fields_1.globPromise)(myEventFilesPath);
|
|
235
268
|
for (const event of myEventFiles) {
|
|
236
269
|
await eventRegisterer(event);
|
|
237
270
|
}
|
|
238
|
-
const sharedEventFilesPath = makeUnixPath(eventsPath, "shared", "*{.ts,.js}");
|
|
239
|
-
dogPaths(`sharedEventFilesPath: "${sharedEventFilesPath}"`);
|
|
240
|
-
const sharedEventFiles = await globPromise(sharedEventFilesPath);
|
|
271
|
+
const sharedEventFilesPath = (0, util_1.makeUnixPath)(eventsPath, "shared", "*{.ts,.js}");
|
|
272
|
+
(0, util_1.dogPaths)(`sharedEventFilesPath: "${sharedEventFilesPath}"`);
|
|
273
|
+
const sharedEventFiles = await (0, fields_1.globPromise)(sharedEventFilesPath);
|
|
241
274
|
for (const event of sharedEventFiles) {
|
|
242
275
|
await eventRegisterer(event);
|
|
243
276
|
}
|
|
244
277
|
const eventsCount = myEventFiles.length + sharedEventFiles.length;
|
|
245
278
|
if (eventsCount > 0) {
|
|
246
|
-
this.log(`Registered ${eventsCount} ${if1Else(eventsCount, STYLED_EVENT, STYLED_EVENTS)}.`);
|
|
279
|
+
this.log(`Registered ${eventsCount} ${(0, util_1.if1Else)(eventsCount, discord_fields_1.STYLED_EVENT, discord_fields_1.STYLED_EVENTS)}.`);
|
|
247
280
|
}
|
|
248
281
|
}
|
|
249
282
|
async edit(message, newContent) {
|
|
250
|
-
if (newContent.length > DISCORD_MESSAGE_LENGTH_LIMIT) {
|
|
283
|
+
if (newContent.length > fields_1.DISCORD_MESSAGE_LENGTH_LIMIT) {
|
|
251
284
|
newContent = newContent.slice(0, 1996) + "...";
|
|
252
|
-
this.log(`Tried to edit a message to length ${newContent.length}; Slicing to ${DISCORD_MESSAGE_LENGTH_LIMIT}...\n${newContent}`);
|
|
285
|
+
this.log(`Tried to edit a message to length ${newContent.length}; Slicing to ${fields_1.DISCORD_MESSAGE_LENGTH_LIMIT}...\n${newContent}`);
|
|
253
286
|
}
|
|
254
287
|
message = await message.edit(newContent);
|
|
255
288
|
return message;
|
|
256
289
|
}
|
|
257
|
-
async send(recipient, message, options = DEFAULT_SEND_OPTIONS) {
|
|
290
|
+
async send(recipient, message, options = discord_fields_1.DEFAULT_SEND_OPTIONS) {
|
|
291
|
+
var _a, _b;
|
|
258
292
|
if (recipient["send"] == null) {
|
|
259
|
-
this.log(chalk.redBright(`Tried to send a message; no ["send"]! Recipient: ${typeof recipient} | ${recipient}`));
|
|
293
|
+
this.log(util_1.chalk.redBright(`Tried to send a message; no ["send"]! Recipient: ${typeof recipient} | ${recipient}`));
|
|
260
294
|
return null;
|
|
261
295
|
}
|
|
262
296
|
if (recipient == null) {
|
|
263
297
|
this.log(`bot.send: Null recipient:\n${message}`);
|
|
264
298
|
return null;
|
|
265
299
|
}
|
|
266
|
-
let content = (isString(message) ? message : message["content"]
|
|
300
|
+
let content = ((0, util_1.isString)(message) ? message : (_a = message["content"]) !== null && _a !== void 0 ? _a : null);
|
|
267
301
|
if (content == null) {
|
|
268
302
|
return await (recipient["send"])(message);
|
|
269
303
|
}
|
|
@@ -271,10 +305,10 @@ export class BaseDiscordClient extends Client {
|
|
|
271
305
|
this.log(`Tried to send empty message`);
|
|
272
306
|
return null;
|
|
273
307
|
}
|
|
274
|
-
const dummyMessageEditToReal = options.dummyMessageEditToReal
|
|
308
|
+
const dummyMessageEditToReal = (_b = options.dummyMessageEditToReal) !== null && _b !== void 0 ? _b : discord_fields_1.DEFAULT_DUMMY_MESSAGE_EDIT_TO_REAL;
|
|
275
309
|
if (options.uwuAllowed) {
|
|
276
|
-
if (random() < this.getUwuChance()) {
|
|
277
|
-
const match = content.match(LINK_REGEX);
|
|
310
|
+
if ((0, mathjs_1.random)() < this.getUwuChance()) {
|
|
311
|
+
const match = content.match(fields_1.LINK_REGEX);
|
|
278
312
|
if (match == null) {
|
|
279
313
|
content = content
|
|
280
314
|
.replaceAll(/[rl]/g, "w")
|
|
@@ -289,22 +323,22 @@ export class BaseDiscordClient extends Client {
|
|
|
289
323
|
.replaceAll("Ni", "Nyai")
|
|
290
324
|
.replaceAll("pon", "pown")
|
|
291
325
|
.replaceAll("Pon", "Pown")
|
|
292
|
-
.replace(/([.!?])(\s|$)/g, (_, punc, space) => `${punc} ${getRandomUwuFace()}${space}`);
|
|
326
|
+
.replace(/([.!?])(\s|$)/g, (_, punc, space) => `${punc} ${(0, discord_util_1.getRandomUwuFace)()}${space}`);
|
|
293
327
|
}
|
|
294
328
|
}
|
|
295
329
|
}
|
|
296
|
-
if (tooLongForDiscord(content)) {
|
|
330
|
+
if ((0, discord_util_1.tooLongForDiscord)(content)) {
|
|
297
331
|
this.log(`Tried to send a message of length ${content}; Slicing to 2000`);
|
|
298
332
|
content = content.slice(0, 1996) + "...";
|
|
299
333
|
}
|
|
300
334
|
if (Math.random() <= 0.01523) {
|
|
301
|
-
if (tooLongForDiscord(content.length + VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE.length + 1)) {
|
|
302
|
-
content += `\n${VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE}`;
|
|
335
|
+
if ((0, discord_util_1.tooLongForDiscord)(content.length + discord_fields_1.VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE.length + 1)) {
|
|
336
|
+
content += `\n${discord_fields_1.VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE}`;
|
|
303
337
|
}
|
|
304
338
|
}
|
|
305
339
|
let liveMsg = null;
|
|
306
340
|
if (dummyMessageEditToReal) {
|
|
307
|
-
liveMsg = await (recipient["send"])(skyify(content));
|
|
341
|
+
liveMsg = await (recipient["send"])((0, util_1.skyify)(content));
|
|
308
342
|
if (liveMsg != null) {
|
|
309
343
|
liveMsg = await this.edit(liveMsg, content);
|
|
310
344
|
this.onEditedToReal(liveMsg);
|
|
@@ -326,9 +360,9 @@ export class BaseDiscordClient extends Client {
|
|
|
326
360
|
getAiRandomScenarioChance() {
|
|
327
361
|
return 0;
|
|
328
362
|
}
|
|
329
|
-
async sendToById(message, channelId, options = DEFAULT_SEND_OPTIONS) {
|
|
363
|
+
async sendToById(message, channelId, options = discord_fields_1.DEFAULT_SEND_OPTIONS) {
|
|
330
364
|
let channel = await this.findChannelById(channelId);
|
|
331
|
-
if (channel instanceof TextChannel) {
|
|
365
|
+
if (channel instanceof discord_js_1.TextChannel) {
|
|
332
366
|
return this.send(channel, message, options);
|
|
333
367
|
}
|
|
334
368
|
// else
|
|
@@ -337,14 +371,14 @@ export class BaseDiscordClient extends Client {
|
|
|
337
371
|
// }
|
|
338
372
|
return null;
|
|
339
373
|
}
|
|
340
|
-
async trySendToById(messages, channelId, options = DEFAULT_SEND_OPTIONS) {
|
|
374
|
+
async trySendToById(messages, channelId, options = discord_fields_1.DEFAULT_SEND_OPTIONS) {
|
|
341
375
|
for (let message of messages) {
|
|
342
376
|
const trimmedMessage = message.trim();
|
|
343
377
|
if (trimmedMessage.length <= 0) {
|
|
344
378
|
continue;
|
|
345
379
|
}
|
|
346
|
-
if (trimmedMessage.length > DISCORD_MESSAGE_LENGTH_LIMIT) {
|
|
347
|
-
this.log(`${STYLED_WARNING}: Tried to send a message that's too long ${trimmedMessage.length}. Trimming!`);
|
|
380
|
+
if (trimmedMessage.length > fields_1.DISCORD_MESSAGE_LENGTH_LIMIT) {
|
|
381
|
+
this.log(`${discord_fields_1.STYLED_WARNING}: Tried to send a message that's too long ${trimmedMessage.length}. Trimming!`);
|
|
348
382
|
message = message.slice(0, 1999);
|
|
349
383
|
}
|
|
350
384
|
const sentMessage = await this.sendToById(message, channelId, options);
|
|
@@ -369,7 +403,7 @@ export class BaseDiscordClient extends Client {
|
|
|
369
403
|
async dmUserById(userId, message) {
|
|
370
404
|
try {
|
|
371
405
|
const user = this.users.cache.get(userId);
|
|
372
|
-
return this.send(user, isString(message) ? message.slice(0, 1999) : message).catch(err => { print(err); });
|
|
406
|
+
return this.send(user, (0, util_1.isString)(message) ? message.slice(0, 1999) : message).catch(err => { (0, util_1.print)(err); });
|
|
373
407
|
// this.findUserById(userId).then((user: User) =>
|
|
374
408
|
// {
|
|
375
409
|
// this.send(user, message)
|
|
@@ -388,7 +422,7 @@ export class BaseDiscordClient extends Client {
|
|
|
388
422
|
channel = await guild.channels.create({ name: channelName });
|
|
389
423
|
}
|
|
390
424
|
catch (err) {
|
|
391
|
-
this.log(chalk.redBright(`Could not create channel in guild: ${guild.id} ${guild.name}, channel: ${channelName}\n${err}`));
|
|
425
|
+
this.log(util_1.chalk.redBright(`Could not create channel in guild: ${guild.id} ${guild.name}, channel: ${channelName}\n${err}`));
|
|
392
426
|
}
|
|
393
427
|
}
|
|
394
428
|
return channel;
|
|
@@ -494,19 +528,19 @@ export class BaseDiscordClient extends Client {
|
|
|
494
528
|
await member.setNickname(newName);
|
|
495
529
|
this.log(`${oldName} changed to ${newName}`);
|
|
496
530
|
}
|
|
497
|
-
catch {
|
|
531
|
+
catch (_a) {
|
|
498
532
|
this.log(`Couldn't set name!`);
|
|
499
533
|
return false;
|
|
500
534
|
}
|
|
501
535
|
return true;
|
|
502
536
|
}
|
|
503
537
|
async followUp(interaction, options) {
|
|
504
|
-
this.log(`Interaction: ${wrapTitle(interaction.commandName)} followUp: ${isString(options) ? options : `\n${stringify(options)}`}`);
|
|
538
|
+
this.log(`Interaction: ${(0, discord_util_1.wrapTitle)(interaction.commandName)} followUp: ${(0, util_1.isString)(options) ? options : `\n${(0, util_1.stringify)(options)}`}`);
|
|
505
539
|
try {
|
|
506
540
|
return await interaction.followUp(options);
|
|
507
541
|
}
|
|
508
|
-
catch {
|
|
509
|
-
print(chalk.redBright(`Error following up interaction; probably timed out! Oh well! Followup message:\n${options}`));
|
|
542
|
+
catch (_a) {
|
|
543
|
+
(0, util_1.print)(util_1.chalk.redBright(`Error following up interaction; probably timed out! Oh well! Followup message:\n${options}`));
|
|
510
544
|
}
|
|
511
545
|
return null;
|
|
512
546
|
}
|
|
@@ -515,15 +549,15 @@ export class BaseDiscordClient extends Client {
|
|
|
515
549
|
if (guild == null) {
|
|
516
550
|
return false;
|
|
517
551
|
}
|
|
518
|
-
renameGuildOrChannel(guild, name);
|
|
552
|
+
(0, discord_util_1.renameGuildOrChannel)(guild, name);
|
|
519
553
|
return true;
|
|
520
554
|
}
|
|
521
555
|
async renameChannelById(channelId, name) {
|
|
522
556
|
const channel = await this.findChannelById(channelId);
|
|
523
|
-
if (!(channel instanceof TextChannel)) {
|
|
557
|
+
if (!(channel instanceof discord_js_1.TextChannel)) {
|
|
524
558
|
return false;
|
|
525
559
|
}
|
|
526
|
-
await renameGuildOrChannel(channel, name);
|
|
560
|
+
await (0, discord_util_1.renameGuildOrChannel)(channel, name);
|
|
527
561
|
return true;
|
|
528
562
|
}
|
|
529
563
|
async renameMemberByGuildIdAndId(guildId, memberId, name) {
|
|
@@ -531,19 +565,20 @@ export class BaseDiscordClient extends Client {
|
|
|
531
565
|
if (member == null) {
|
|
532
566
|
return false;
|
|
533
567
|
}
|
|
534
|
-
await renameMember(member, name);
|
|
568
|
+
await (0, discord_util_1.renameMember)(member, name);
|
|
535
569
|
return true;
|
|
536
570
|
}
|
|
537
571
|
async referenceToString(reference) {
|
|
572
|
+
var _a;
|
|
538
573
|
let referenceString = "";
|
|
539
574
|
if (reference != null) {
|
|
540
575
|
try {
|
|
541
576
|
const referenceChannel = await this.findChannelById(reference.channelId);
|
|
542
|
-
const referenceMessage = await referenceChannel.messages.fetch(reference.messageId
|
|
543
|
-
referenceString = messageToReplyString(referenceMessage);
|
|
577
|
+
const referenceMessage = await referenceChannel.messages.fetch((_a = reference.messageId) !== null && _a !== void 0 ? _a : "");
|
|
578
|
+
referenceString = (0, discord_util_1.messageToReplyString)(referenceMessage);
|
|
544
579
|
}
|
|
545
580
|
catch (err) {
|
|
546
|
-
this.log(chalk.redBright(err));
|
|
581
|
+
this.log(util_1.chalk.redBright(err));
|
|
547
582
|
}
|
|
548
583
|
}
|
|
549
584
|
return referenceString;
|
|
@@ -562,18 +597,18 @@ export class BaseDiscordClient extends Client {
|
|
|
562
597
|
return false;
|
|
563
598
|
}
|
|
564
599
|
async setChannelMessagesTo(channel, msgs) {
|
|
565
|
-
await forEachMessage(channel, async (msg) => {
|
|
566
|
-
print(`Deleting old message ${msg.content}`);
|
|
600
|
+
await (0, discord_util_1.forEachMessage)(channel, async (msg) => {
|
|
601
|
+
(0, util_1.print)(`Deleting old message ${msg.content}`);
|
|
567
602
|
await this.delete(msg);
|
|
568
603
|
});
|
|
569
604
|
for (const msg of msgs) {
|
|
570
|
-
const liveMsg = await this.send(channel, msg, AI_NOT_ALLOWED);
|
|
571
|
-
print(`Posted new message ${liveMsg.content}`);
|
|
605
|
+
const liveMsg = await this.send(channel, msg, discord_fields_1.AI_NOT_ALLOWED);
|
|
606
|
+
(0, util_1.print)(`Posted new message ${liveMsg.content}`);
|
|
572
607
|
}
|
|
573
608
|
}
|
|
574
609
|
stopIfDev(interaction) {
|
|
575
|
-
if (isDev()) {
|
|
576
|
-
this.followUp(interaction, COMMAND_NOT_ALLOWED_IN_DEV_MESSAGE);
|
|
610
|
+
if ((0, discord_util_1.isDev)()) {
|
|
611
|
+
this.followUp(interaction, discord_util_1.COMMAND_NOT_ALLOWED_IN_DEV_MESSAGE);
|
|
577
612
|
return true;
|
|
578
613
|
}
|
|
579
614
|
return false;
|
|
@@ -582,14 +617,14 @@ export class BaseDiscordClient extends Client {
|
|
|
582
617
|
if (interaction.channel == null) {
|
|
583
618
|
return false;
|
|
584
619
|
}
|
|
585
|
-
if (isNotTextChannel(interaction.channel)) {
|
|
586
|
-
this.followUp(interaction, ONLY_TEXT_CHANNEL_SUPPORTED);
|
|
620
|
+
if ((0, discord_util_1.isNotTextChannel)(interaction.channel)) {
|
|
621
|
+
this.followUp(interaction, discord_util_1.ONLY_TEXT_CHANNEL_SUPPORTED);
|
|
587
622
|
return false;
|
|
588
623
|
}
|
|
589
624
|
return true;
|
|
590
625
|
}
|
|
591
626
|
async getUserNameById(userId) {
|
|
592
|
-
return getUserName(await this.findUserById(userId));
|
|
627
|
+
return (0, discord_util_1.getUserName)(await this.findUserById(userId));
|
|
593
628
|
}
|
|
594
629
|
get loadingMessage() {
|
|
595
630
|
return `Loading~`;
|
|
@@ -601,10 +636,10 @@ export class BaseDiscordClient extends Client {
|
|
|
601
636
|
}
|
|
602
637
|
}
|
|
603
638
|
async forEveryMember(doThis) {
|
|
604
|
-
await this.forEveryServer(guild => forEveryMemberInGuild(guild, member => doThis(member, guild)));
|
|
639
|
+
await this.forEveryServer(guild => (0, discord_util_1.forEveryMemberInGuild)(guild, member => doThis(member, guild)));
|
|
605
640
|
}
|
|
606
641
|
async forEveryChannel(doThis) {
|
|
607
|
-
await this.forEveryServer(guild => forEveryChannelInGuild(guild, channel => doThis(channel, guild)));
|
|
642
|
+
await this.forEveryServer(guild => (0, discord_util_1.forEveryChannelInGuild)(guild, channel => doThis(channel, guild)));
|
|
608
643
|
}
|
|
609
644
|
async getAllMembers() {
|
|
610
645
|
const members = new Set();
|
|
@@ -622,15 +657,14 @@ export class BaseDiscordClient extends Client {
|
|
|
622
657
|
return channels;
|
|
623
658
|
}
|
|
624
659
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
description
|
|
628
|
-
run;
|
|
629
|
-
options;
|
|
630
|
-
constructor(name, description, run, options = DEFAULT_SEND_OPTIONS) {
|
|
660
|
+
exports.BaseDiscordClient = BaseDiscordClient;
|
|
661
|
+
class StringCommand {
|
|
662
|
+
constructor(name, description, run, options = discord_fields_1.DEFAULT_SEND_OPTIONS) {
|
|
631
663
|
this.name = name;
|
|
632
664
|
this.description = description;
|
|
633
665
|
this.run = run;
|
|
634
666
|
this.options = options;
|
|
635
667
|
}
|
|
636
668
|
}
|
|
669
|
+
exports.StringCommand = StringCommand;
|
|
670
|
+
//# sourceMappingURL=discord_classes.js.map
|