aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-17 10:25:46 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-17 10:25:46 -0400
commitd1724227abfb8f0fcd9e573f7e9772cf0be8257a (patch)
tree52c9dbae1fbbbd3c777d9c16ab643c477141ae21 /src/lib/extensions
parent53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3 (diff)
downloadtanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.gz
tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.bz2
tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.zip
honestly no idea what I did at this point
Diffstat (limited to 'src/lib/extensions')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts30
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts5
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts2
3 files changed, 27 insertions, 10 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 6538ebf..6a08c54 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -45,6 +45,9 @@ import got from 'got';
import humanizeDuration from 'humanize-duration';
import { Op } from 'sequelize';
import { promisify } from 'util';
+import { BushNewsChannel } from '../discord.js/BushNewsChannel';
+import { BushTextChannel } from '../discord.js/BushTextChannel';
+import { BushUserResolvable } from './BushClient';
interface hastebinRes {
key: string;
@@ -322,7 +325,7 @@ export class BushClientUtil extends ClientUtil {
let curPage = 0;
if (typeof embeds !== 'object') throw 'embeds must be an object';
const msg: Message = await message.util.reply({
- content: text,
+ content: text || null,
embeds: [embeds[curPage]],
components: [getPaginationRow()]
});
@@ -527,16 +530,22 @@ export class BushClientUtil extends ClientUtil {
const environment = this.client.config.dev ? 'development' : 'production';
const row = await Global.findByPk(environment);
const oldValue: any[] = row[key];
+ const newValue = this.addOrRemoveFromArray(action, oldValue, value);
+ row[key] = newValue;
+ this.client.cache.global[key] = newValue;
+ return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
+ }
+
+ public addOrRemoveFromArray(action: 'add' | 'remove', array: any[], value: any): any[] {
let newValue: any[];
+ if (!array) return null;
if (action === 'add') {
- if (!oldValue.includes(action)) oldValue.push(value);
- newValue = oldValue;
+ if (!array.includes(action)) array.push(value);
+ newValue = array;
} else {
- newValue = oldValue.filter((ae) => ae !== value);
+ newValue = array.filter((ae) => ae !== value);
}
- row[key] = newValue;
- this.client.cache.global[key] = newValue;
- return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
+ return newValue;
}
/**
@@ -587,11 +596,13 @@ export class BushClientUtil extends ClientUtil {
moderator: BushGuildMember,
victim: BushGuildMember,
type: 'mute' | 'unmute' | 'warn' | 'kick' | 'ban' | 'unban' | 'add a punishment role to' | 'remove a punishment role from',
- checkModerator = true
+ checkModerator = true,
+ force = false
): true | string {
if (moderator.guild.id !== victim.guild.id) {
throw 'moderator and victim not in same guild';
}
+ if (force) return true;
const isOwner = moderator.guild.ownerId === moderator.id;
if (moderator.id === victim.id) {
return `${this.client.util.emojis.error} You cannot ${type} yourself.`;
@@ -708,7 +719,6 @@ export class BushClientUtil extends ClientUtil {
public async findExpiredEntries<K extends keyof punishmentModels>(type: K): Promise<punishmentModels[K][]> {
const dbModel = this.findPunishmentModel(type);
- console.log(dbModel);
//@ts-ignore: stfu idc
return await dbModel.findAll({
where: {
@@ -768,4 +778,6 @@ export class BushClientUtil extends ClientUtil {
return arrByte[1] + ', ' + arrByte[2] + ', ' + arrByte[3];
}
+
+ public async lockdownChannel(options: { channel: BushTextChannel | BushNewsChannel; moderator: BushUserResolvable }) {}
}
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index 90c68df..6cf981b 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -86,6 +86,7 @@ export interface BushCommandOptions extends CommandOptions {
};
args?: BushArgumentOptions[] | ArgumentGenerator;
category: string;
+ completelyHide?: boolean;
}
export class BushCommand extends Command {
@@ -104,12 +105,16 @@ export class BushCommand extends Command {
/** Whether the command is hidden from the help command. */
public hidden: boolean;
+ /** Completely hide this command from the help command. */
+ public completelyHide: boolean;
+
public constructor(id: string, options?: BushCommandOptions) {
super(id, options);
this.options = options;
this.hidden = options.hidden || false;
this.restrictedChannels = options.restrictedChannels;
this.restrictedGuilds = options.restrictedGuilds;
+ this.completelyHide = options.completelyHide;
}
public exec(message: BushMessage, args: any): any;
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index 6eca44d..f695f8b 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -12,7 +12,7 @@ export class BushGuild extends Guild {
}
public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
- return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id })).get(setting);
+ return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }))[setting];
}
public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> {