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.
Files changed (37) hide show
  1. package/dist/index.js +9 -25
  2. package/dist/structures/structs.js +45 -46
  3. package/dist/types/classes.js +122 -121
  4. package/dist/types/discord_classes.js +106 -140
  5. package/dist/types/discord_fields.js +24 -28
  6. package/dist/types/discord_types.js +4 -6
  7. package/dist/types/fields.js +232 -238
  8. package/dist/types/types.js +1 -3
  9. package/dist/utils/discord-util.js +235 -370
  10. package/dist/utils/util.js +694 -1146
  11. package/package.json +2 -1
  12. package/dist/data/downside.json +0 -75
  13. package/dist/data/hiragana.json +0 -527
  14. package/dist/data/homoglyphs.json +0 -31790
  15. package/dist/data/letterArray.json +0 -254
  16. package/dist/data/superscript.json +0 -96
  17. package/dist/data/upside.json +0 -78
  18. package/dist/index.d.ts +0 -9
  19. package/dist/index.js.map +0 -1
  20. package/dist/structures/structs.d.ts +0 -77
  21. package/dist/structures/structs.js.map +0 -1
  22. package/dist/types/classes.d.ts +0 -214
  23. package/dist/types/classes.js.map +0 -1
  24. package/dist/types/discord_classes.d.ts +0 -93
  25. package/dist/types/discord_classes.js.map +0 -1
  26. package/dist/types/discord_fields.d.ts +0 -27
  27. package/dist/types/discord_fields.js.map +0 -1
  28. package/dist/types/discord_types.d.ts +0 -51
  29. package/dist/types/discord_types.js.map +0 -1
  30. package/dist/types/fields.d.ts +0 -163
  31. package/dist/types/fields.js.map +0 -1
  32. package/dist/types/types.d.ts +0 -99
  33. package/dist/types/types.js.map +0 -1
  34. package/dist/utils/discord-util.d.ts +0 -198
  35. package/dist/utils/discord-util.js.map +0 -1
  36. package/dist/utils/util.d.ts +0 -504
  37. package/dist/utils/util.js.map +0 -1
@@ -1,68 +1,37 @@
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 {
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
- var _a;
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 ((_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}`);
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
- (0, util_1.print)(message);
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 = (0, util_1.makeUnixPath)(resourcesPath, "slash_commands");
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(`${discord_fields_1.STYLED_WARNING}: Duplicate ${discord_fields_1.STYLED_SLASH_COMMAND} ${command.name}. ${util_1.chalk.underline(util_1.chalk.whiteBright("Skipping!"))}`);
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 = (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);
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 = (0, util_1.makeUnixPath)(slashCommandsPath, "shared", "*{.ts,.js}");
207
- (0, util_1.dogPaths)(`sharedCommandFilesPath: "${sharedCommandFilesPath}"`);
208
- const sharedCommandFiles = await (0, fields_1.globPromise)(sharedCommandFilesPath);
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} ${(0, util_1.if1Else)(slashCommandsCount, discord_fields_1.STYLED_SLASH_COMMAND, discord_fields_1.STYLED_SLASH_COMMANDS)}.`);
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 = (0, util_1.makeUnixPath)(resourcesPath, "string_commands");
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(`${discord_fields_1.STYLED_WARNING}: Duplicate ${discord_fields_1.STYLED_STRING_COMMAND} name ${name}!`);
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 = (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);
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 = (0, util_1.makeUnixPath)(stringCommandsPath, "shared", "*{.ts,.js}");
244
- const sharedStringCommandFiles = await (0, fields_1.globPromise)(sharedStringCommandFilesPath);
245
- (0, util_1.dogPaths)(`sharedStringCommandFilesPath: "${sharedStringCommandFilesPath}"`);
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} ${(0, util_1.if1Else)(stringCommandsCount, discord_fields_1.STYLED_STRING_COMMAND, discord_fields_1.STYLED_STRING_COMMANDS)}.`);
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 = (0, util_1.makeUnixPath)(resourcesPath, "events");
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 = (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);
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 = (0, util_1.makeUnixPath)(eventsPath, "shared", "*{.ts,.js}");
272
- (0, util_1.dogPaths)(`sharedEventFilesPath: "${sharedEventFilesPath}"`);
273
- const sharedEventFiles = await (0, fields_1.globPromise)(sharedEventFilesPath);
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} ${(0, util_1.if1Else)(eventsCount, discord_fields_1.STYLED_EVENT, discord_fields_1.STYLED_EVENTS)}.`);
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 > fields_1.DISCORD_MESSAGE_LENGTH_LIMIT) {
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 ${fields_1.DISCORD_MESSAGE_LENGTH_LIMIT}...\n${newContent}`);
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 = discord_fields_1.DEFAULT_SEND_OPTIONS) {
291
- var _a, _b;
257
+ async send(recipient, message, options = DEFAULT_SEND_OPTIONS) {
292
258
  if (recipient["send"] == null) {
293
- this.log(util_1.chalk.redBright(`Tried to send a message; no ["send"]! Recipient: ${typeof recipient} | ${recipient}`));
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 = ((0, util_1.isString)(message) ? message : (_a = message["content"]) !== null && _a !== void 0 ? _a : null);
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 = (_b = options.dummyMessageEditToReal) !== null && _b !== void 0 ? _b : discord_fields_1.DEFAULT_DUMMY_MESSAGE_EDIT_TO_REAL;
274
+ const dummyMessageEditToReal = options.dummyMessageEditToReal ?? DEFAULT_DUMMY_MESSAGE_EDIT_TO_REAL;
309
275
  if (options.uwuAllowed) {
310
- if ((0, mathjs_1.random)() < this.getUwuChance()) {
311
- const match = content.match(fields_1.LINK_REGEX);
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} ${(0, discord_util_1.getRandomUwuFace)()}${space}`);
292
+ .replace(/([.!?])(\s|$)/g, (_, punc, space) => `${punc} ${getRandomUwuFace()}${space}`);
327
293
  }
328
294
  }
329
295
  }
330
- if ((0, discord_util_1.tooLongForDiscord)(content)) {
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 ((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}`;
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"])((0, util_1.skyify)(content));
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 = discord_fields_1.DEFAULT_SEND_OPTIONS) {
329
+ async sendToById(message, channelId, options = DEFAULT_SEND_OPTIONS) {
364
330
  let channel = await this.findChannelById(channelId);
365
- if (channel instanceof discord_js_1.TextChannel) {
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 = discord_fields_1.DEFAULT_SEND_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 > 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!`);
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, (0, util_1.isString)(message) ? message.slice(0, 1999) : message).catch(err => { (0, util_1.print)(err); });
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(util_1.chalk.redBright(`Could not create channel in guild: ${guild.id} ${guild.name}, channel: ${channelName}\n${err}`));
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 (_a) {
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: ${(0, discord_util_1.wrapTitle)(interaction.commandName)} followUp: ${(0, util_1.isString)(options) ? options : `\n${(0, util_1.stringify)(options)}`}`);
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 (_a) {
543
- (0, util_1.print)(util_1.chalk.redBright(`Error following up interaction; probably timed out! Oh well! Followup message:\n${options}`));
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
- (0, discord_util_1.renameGuildOrChannel)(guild, name);
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 discord_js_1.TextChannel)) {
523
+ if (!(channel instanceof TextChannel)) {
558
524
  return false;
559
525
  }
560
- await (0, discord_util_1.renameGuildOrChannel)(channel, name);
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 (0, discord_util_1.renameMember)(member, name);
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((_a = reference.messageId) !== null && _a !== void 0 ? _a : "");
578
- referenceString = (0, discord_util_1.messageToReplyString)(referenceMessage);
542
+ const referenceMessage = await referenceChannel.messages.fetch(reference.messageId ?? "");
543
+ referenceString = messageToReplyString(referenceMessage);
579
544
  }
580
545
  catch (err) {
581
- this.log(util_1.chalk.redBright(err));
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 (0, discord_util_1.forEachMessage)(channel, async (msg) => {
601
- (0, util_1.print)(`Deleting old message ${msg.content}`);
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, discord_fields_1.AI_NOT_ALLOWED);
606
- (0, util_1.print)(`Posted new message ${liveMsg.content}`);
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 ((0, discord_util_1.isDev)()) {
611
- this.followUp(interaction, discord_util_1.COMMAND_NOT_ALLOWED_IN_DEV_MESSAGE);
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 ((0, discord_util_1.isNotTextChannel)(interaction.channel)) {
621
- this.followUp(interaction, discord_util_1.ONLY_TEXT_CHANNEL_SUPPORTED);
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 (0, discord_util_1.getUserName)(await this.findUserById(userId));
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 => (0, discord_util_1.forEveryMemberInGuild)(guild, member => doThis(member, guild)));
604
+ await this.forEveryServer(guild => forEveryMemberInGuild(guild, member => doThis(member, guild)));
640
605
  }
641
606
  async forEveryChannel(doThis) {
642
- await this.forEveryServer(guild => (0, discord_util_1.forEveryChannelInGuild)(guild, channel => doThis(channel, 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
- exports.BaseDiscordClient = BaseDiscordClient;
661
- class StringCommand {
662
- constructor(name, description, run, options = discord_fields_1.DEFAULT_SEND_OPTIONS) {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_SEND_OPTIONS = exports.STYLED_ERROR_WARNING = exports.STYLED_WARNING = exports.STYLED_EVENTS = exports.STYLED_EVENT = exports.STYLED_STRING_COMMANDS = exports.STYLED_STRING_COMMAND = exports.STYLED_SLASH_COMMANDS = exports.STYLED_SLASH_COMMAND = exports.NO_EDITING_ALLOWED = exports.EDIT_TO_REAL_NO_AI = exports.EDIT_TO_REAL_WITH_AI = exports.EDIT_TO_REAL = exports.UWU_NOT_ALLOWED = exports.AI_NOT_ALLOWED = exports.AI_ALLOWED = exports.DEFAULT_AI_ALLOWED = exports.DEFAULT_DUMMY_MESSAGE_EDIT_TO_REAL = exports.DEFAULT_UWU_ALLOWED = exports.VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE = void 0;
4
- const util_1 = require("../utils/util");
5
- exports.VERIFIED_BY_DISCORD_ADMINS_EASTER_EGG_MESSAGE = `-# This message is verified by Discord Admins - [Dismiss Message](<https://www.youtube.com/watch?v=dQw4w9WgXcQ>)`;
6
- exports.DEFAULT_UWU_ALLOWED = true;
7
- exports.DEFAULT_DUMMY_MESSAGE_EDIT_TO_REAL = false;
8
- exports.DEFAULT_AI_ALLOWED = false;
9
- exports.AI_ALLOWED = { aiAllowed: true };
10
- exports.AI_NOT_ALLOWED = { aiAllowed: false };
11
- exports.UWU_NOT_ALLOWED = { uwuAllowed: false };
12
- exports.EDIT_TO_REAL = { dummyMessageEditToReal: true };
13
- exports.EDIT_TO_REAL_WITH_AI = (0, util_1.mergeObjs)(exports.EDIT_TO_REAL, exports.AI_ALLOWED);
14
- exports.EDIT_TO_REAL_NO_AI = (0, util_1.mergeObjs)(exports.EDIT_TO_REAL, exports.AI_NOT_ALLOWED);
15
- exports.NO_EDITING_ALLOWED = (0, util_1.mergeObjs)(exports.UWU_NOT_ALLOWED, exports.AI_NOT_ALLOWED);
16
- exports.STYLED_SLASH_COMMAND = util_1.chalk.magentaBright("slash command");
17
- exports.STYLED_SLASH_COMMANDS = util_1.chalk.magentaBright("slash commands");
18
- exports.STYLED_STRING_COMMAND = util_1.chalk.cyanBright("string command");
19
- exports.STYLED_STRING_COMMANDS = util_1.chalk.cyanBright("string commands");
20
- exports.STYLED_EVENT = util_1.chalk.greenBright("event");
21
- exports.STYLED_EVENTS = util_1.chalk.greenBright("events");
22
- exports.STYLED_WARNING = util_1.chalk.red("WARNING");
23
- exports.STYLED_ERROR_WARNING = util_1.chalk.redBright("ERROR");
24
- exports.DEFAULT_SEND_OPTIONS = {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiscordEvent = void 0;
4
- class DiscordEvent {
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