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