aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-30 13:04:24 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-30 13:04:24 -0400
commitf5c2b7b946487c2828365cc63bc6f471dd6cfc2f (patch)
treeb225533c2858105b85ba118588954d9cb1ee9781 /src/lib
parent1c6d451ffd63f9805b978e8565807e8a6b528681 (diff)
downloadtanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.tar.gz
tanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.tar.bz2
tanzanite-f5c2b7b946487c2828365cc63bc6f471dd6cfc2f.zip
clean up and fix stuff
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts85
-rw-r--r--src/lib/extensions/discord.js/BushClientEvents.d.ts3
-rw-r--r--src/lib/extensions/discord.js/BushMessage.ts8
3 files changed, 12 insertions, 84 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 926a529..b6c9c1f 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -40,8 +40,6 @@ import got from 'got';
import humanizeDuration from 'humanize-duration';
import moment from 'moment';
import { inspect, InspectOptions, promisify } from 'util';
-import _badLinks from '../../badlinks.json'; // Stolen from https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json
-import badWords from '../../badwords.json';
import { ActivePunishment, ActivePunishmentType } from '../../models/ActivePunishment';
import { BushNewsChannel } from '../discord.js/BushNewsChannel';
import { BushTextChannel } from '../discord.js/BushTextChannel';
@@ -455,17 +453,15 @@ export class BushClientUtil extends ClientUtil {
* * Embed Description Limit = 4096 characters
* * Embed Field Limit = 1024 characters
*/
- public async codeblock(code: string, length: number, language?: 'ts' | 'js' | 'sh' | 'json'): Promise<string> {
+ public async codeblock(code: string, length: number, language?: 'ts' | 'js' | 'sh' | 'json' | ''): Promise<string> {
let hasteOut = '';
const tildes = '```';
+ language = language ?? '';
const formattingLength = 2 * tildes.length + language?.length ?? 0 + 2 * '\n'.length;
if (code.length + formattingLength >= length) hasteOut = 'Too large to display. Hastebin: ' + (await this.haste(code));
const code2 = hasteOut ? code.substring(0, length - (hasteOut.length + '\n'.length + formattingLength)) : code;
- return (
- tildes + language ??
- '' + '\n' + Util.cleanCodeBlockContent(code2) + '\n' + tildes + (hasteOut.length ? '\n' + hasteOut : '')
- );
+ return tildes + language + '\n' + code2 + '\n' + tildes + (hasteOut.length ? '\n' + hasteOut : '');
}
private mapCredential(old: string) {
@@ -797,81 +793,6 @@ export class BushClientUtil extends ClientUtil {
public async lockdownChannel(options: { channel: BushTextChannel | BushNewsChannel; moderator: BushUserResolvable }) {}
/* eslint-enable @typescript-eslint/no-unused-vars */
- public async automod(message: BushMessage) {
- if (message.guild.id !== client.consts.mappings.guilds.bush) return; // just temporary
- /* await message.guild.getSetting('autoModPhases'); */
- const badLinks = _badLinks.map((link) => {
- return { [link]: 3 };
- });
-
- const wordArray = [...Object.keys(badWords), ...Object.keys(badLinks)];
- const offences: { [key: string]: number } = {};
- wordArray.forEach((word) => {
- if (message.content?.toLowerCase().replace(/ /g, '').includes(word.toLowerCase().replace(/ /g, ''))) {
- if (offences[word]) offences[word] = wordArray[word];
- }
- });
- if (!Object.keys(offences)?.length) return;
-
- const highestOffence = Object.values(offences).sort((a, b) => b - a)[0];
-
- switch (highestOffence) {
- case 0: {
- if (message.deletable) void message.delete();
- break;
- }
- case 1: {
- if (message.deletable) void message.delete();
- void message.member.warn({
- moderator: message.guild.me,
- reason: 'Saying a blacklisted word.'
- });
- break;
- }
- case 2: {
- if (message.deletable) void message.delete();
- void message.member.mute({
- moderator: message.guild.me,
- reason: 'Saying a blacklisted word.',
- duration: 900_000 // 15 minutes
- });
- break;
- }
- case 3: {
- if (message.deletable) void message.delete();
- void message.member.mute({
- moderator: message.guild.me,
- reason: 'Saying a blacklisted word.',
- duration: 0 // perm
- });
- break;
- }
- }
-
- const color =
- highestOffence === 0
- ? util.colors.lightGray
- : highestOffence === 1
- ? util.colors.yellow
- : highestOffence === 2
- ? util.colors.orange
- : util.colors.red;
- void (message.guild.channels.cache.get('783088333055066212') as TextChannel).send({
- embeds: [
- new MessageEmbed()
- .setTitle(`[Severity ${highestOffence}] Automod Action Performed`)
- .setDescription(
- `**User:** ${message.author} (${message.author.tag})\n**Blacklisted Words:** ${util
- .surroundArray(Object.keys(offences), '`')
- .join()}`
- )
- .addField('Message Content', `${this.codeblock(message.content, 1024)}`)
- .setColor(color)
- .setTimestamp()
- ]
- });
- }
-
public capitalizeFirstLetter(string: string): string {
return string.charAt(0)?.toUpperCase() + string.slice(1);
}
diff --git a/src/lib/extensions/discord.js/BushClientEvents.d.ts b/src/lib/extensions/discord.js/BushClientEvents.d.ts
index 6c1fec5..da5d647 100644
--- a/src/lib/extensions/discord.js/BushClientEvents.d.ts
+++ b/src/lib/extensions/discord.js/BushClientEvents.d.ts
@@ -1,6 +1,7 @@
import { ClientEvents } from 'discord.js';
-import { BushMessage } from './BushMessage';
+import { BushMessage, BushPartialMessage } from './BushMessage';
export interface BushClientEvents extends ClientEvents {
messageCreate: [message: BushMessage];
+ messageUpdate: [oldMessage: BushMessage | BushPartialMessage, newMessage: BushMessage | BushPartialMessage];
}
diff --git a/src/lib/extensions/discord.js/BushMessage.ts b/src/lib/extensions/discord.js/BushMessage.ts
index 68f3de0..7971a6d 100644
--- a/src/lib/extensions/discord.js/BushMessage.ts
+++ b/src/lib/extensions/discord.js/BushMessage.ts
@@ -1,4 +1,5 @@
-import { Message } from 'discord.js';
+/* eslint-disable @typescript-eslint/no-empty-interface */
+import { Message, Partialize } from 'discord.js';
import { BushClient } from '../discord-akairo/BushClient';
import { BushDMChannel } from './BushDMChannel';
import { BushGuild } from './BushGuild';
@@ -8,6 +9,8 @@ import { BushTextChannel } from './BushTextChannel';
import { BushThreadChannel } from './BushThreadChannel';
import { BushUser } from './BushUser';
+export interface BushPartialMessage
+ extends Partialize<BushMessage, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> {}
export class BushMessage extends Message {
public declare readonly client: BushClient;
// public util: BushCommandUtil;
@@ -23,4 +26,7 @@ export class BushMessage extends Message {
super(client, data, channel);
// this.util = new BushCommandUtil(client.commandHandler, this);
}
+ public fetch(force?: boolean): Promise<BushMessage> {
+ return super.fetch(force) as Promise<BushMessage>;
+ }
}