diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-25 12:38:13 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-25 12:38:13 -0400 |
commit | 6d27d53623d84127c43d3146619106e540549038 (patch) | |
tree | f797712108f295b222da6db803f175a814fa6e28 /src/lib/extensions | |
parent | 432b602b5416d61d7f11ade478914fc14a8fc971 (diff) | |
download | tanzanite-6d27d53623d84127c43d3146619106e540549038.tar.gz tanzanite-6d27d53623d84127c43d3146619106e540549038.tar.bz2 tanzanite-6d27d53623d84127c43d3146619106e540549038.zip |
cleaned up eval command, ported test command, fixed listeners, fixed workflow, changed args typings
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 6 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 20 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommand.ts | 21 |
3 files changed, 31 insertions, 16 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 8496d2a..3caae38 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -3,13 +3,15 @@ import { AkairoClient } from 'discord-akairo'; import { Guild, Intents, + InteractionReplyOptions, Message, MessageEditOptions, MessageOptions, MessagePayload, ReplyMessageOptions, Snowflake, - Structures + Structures, + WebhookEditMessageOptions } from 'discord.js'; import * as path from 'path'; import { exit } from 'process'; @@ -57,6 +59,8 @@ import { BushTaskHandler } from './BushTaskHandler'; export type BushReplyMessageType = string | MessagePayload | ReplyMessageOptions; export type BushEditMessageType = string | MessageEditOptions | MessagePayload; +export type BushSlashSendMessageType = string | MessagePayload | InteractionReplyOptions +export type BushSlashEditMessageType = string | MessagePayload | WebhookEditMessageOptions export type BushSendMessageType = string | MessagePayload | MessageOptions; export type BushThreadMemberResolvable = BushThreadMember | BushUserResolvable; export type BushUserResolvable = BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember; diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 306e049..3a50480 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -31,12 +31,11 @@ import { MessageEditOptions, MessageEmbed, MessageOptions, - MessagePayload, + Snowflake, TextChannel, User, - Util, - WebhookEditMessageOptions + Util } from 'discord.js'; import got from 'got'; import humanizeDuration from 'humanize-duration'; @@ -44,7 +43,7 @@ import { promisify } from 'util'; import { ActivePunishment, ActivePunishmentType } from '../../models/ActivePunishment'; import { BushNewsChannel } from '../discord.js/BushNewsChannel'; import { BushTextChannel } from '../discord.js/BushTextChannel'; -import { BushUserResolvable } from './BushClient'; +import { BushSlashEditMessageType, BushSlashSendMessageType, BushUserResolvable } from './BushClient'; interface hastebinRes { key: string; @@ -458,9 +457,9 @@ export class BushClientUtil extends ClientUtil { let hasteOut = ''; const tildes = '```'; const formattingLength = 2 * tildes.length + language.length + 2 * '\n'.length; - if (code.length + formattingLength > length) hasteOut = 'Too large to display. Hastebin: ' + (await this.haste(code)); + if (code.length + formattingLength >= length) hasteOut = 'Too large to display. Hastebin: ' + (await this.haste(code)); - const code2 = code.length > length ? code.substring(0, length - (hasteOut.length + '\n'.length + formattingLength)) : 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 : '') ); @@ -468,9 +467,9 @@ export class BushClientUtil extends ClientUtil { public async slashRespond( interaction: CommandInteraction, - responseOptions: string | MessagePayload | WebhookEditMessageOptions + responseOptions: BushSlashSendMessageType|BushSlashEditMessageType ): Promise<Message | APIMessage> { - let newResponseOptions: string | MessagePayload | WebhookEditMessageOptions = {}; + let newResponseOptions: BushSlashSendMessageType|BushSlashEditMessageType = {}; if (typeof responseOptions === 'string') { newResponseOptions.content = responseOptions; } else { @@ -751,4 +750,9 @@ export class BushClientUtil extends ClientUtil { /* eslint-disable @typescript-eslint/no-unused-vars */ public async lockdownChannel(options: { channel: BushTextChannel | BushNewsChannel; moderator: BushUserResolvable }) {} /* eslint-enable @typescript-eslint/no-unused-vars */ + + public async automod(message: BushMessage) { + const autoModPhases = await message.guild.getSetting('autoModPhases'); + if (autoModPhases.includes(message.content.toString()) && message.deletable) message.delete() + } } diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 6cf981b..0127a59 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -44,6 +44,10 @@ type BushArgumentType = | 'newsChannels' | 'storeChannel' | 'storeChannels' + | 'stageChannel' + | 'stageChannels' + | 'threadChannel' + | 'threadChannels' | 'role' | 'roles' | 'emoji' @@ -63,17 +67,19 @@ type BushArgumentType = | 'command' | 'inhibitor' | 'listener' - | 'duration' - | (string | string[])[] - | RegExp - | string; + | 'duration'; -export interface BushArgumentOptions extends ArgumentOptions { - type?: BushArgumentType | ArgumentTypeCaster; +interface BaseBushArgumentOptions extends ArgumentOptions { id: string; description?: string; prompt?: ArgumentPromptOptions; } +export interface BushArgumentOptions extends BaseBushArgumentOptions { + type?: BushArgumentType; +} +export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { + type?: ArgumentTypeCaster | (string | string[])[] | RegExp | string; +} export interface BushCommandOptions extends CommandOptions { hidden?: boolean; @@ -84,7 +90,7 @@ export interface BushCommandOptions extends CommandOptions { usage: string | string[]; examples: string | string[]; }; - args?: BushArgumentOptions[] | ArgumentGenerator; + args?: BushArgumentOptions[] | CustomBushArgumentOptions[] | ArgumentGenerator; category: string; completelyHide?: boolean; } @@ -110,6 +116,7 @@ export class BushCommand extends Command { public constructor(id: string, options?: BushCommandOptions) { super(id, options); + options.category; this.options = options; this.hidden = options.hidden || false; this.restrictedChannels = options.restrictedChannels; |