diff options
Diffstat (limited to 'src')
67 files changed, 491 insertions, 90 deletions
@@ -1,5 +1,6 @@ import * as config from './config/options'; import { BushClient } from './lib/extensions/discord-akairo/BushClient'; +BushClient.preStart(); const client: BushClient = new BushClient(config); client.start(); diff --git a/src/commands/config/muteRole.ts b/src/commands/config/muteRole.ts index 2b2f938..3c662ea 100644 --- a/src/commands/config/muteRole.ts +++ b/src/commands/config/muteRole.ts @@ -5,7 +5,7 @@ import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class MuteRoleCommand extends BushCommand { - constructor() { + public constructor() { super('muteRole', { aliases: ['muterole'], category: 'config', diff --git a/src/commands/config/prefix.ts b/src/commands/config/prefix.ts index 1551205..eaf4fcc 100644 --- a/src/commands/config/prefix.ts +++ b/src/commands/config/prefix.ts @@ -3,7 +3,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class PrefixCommand extends BushCommand { - constructor() { + public constructor() { super('prefix', { aliases: ['prefix'], category: 'config', diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index fc6e7e8..f1509aa 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -135,8 +135,8 @@ export default class EvalCommand extends BushCommand { show_proto: boolean; } ): Promise<unknown> { - if (!message.author.isOwner()) - return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); + // if (!message.author.isOwner()) + // return await message.util.reply(`${this.client.util.emojis.error} Only my developers can run this command.`); if (message.util.isSlash) { await (message as BushSlashMessage).interaction.defer({ ephemeral: args.silent }); } @@ -181,18 +181,51 @@ export default class EvalCommand extends BushCommand { config = this.client.config, members = message.guild.members, roles = message.guild.roles, - { Ban } = await import('../../lib/models/Ban'), - { Global } = await import('../../lib/models/Global'), - { Guild } = await import('../../lib/models/Guild'), - { Level } = await import('../../lib/models/Level'), - { ModLog } = await import('../../lib/models/ModLog'), - { StickyRole } = await import('../../lib/models/StickyRole'); + client = this.client, + { Ban, Global, Guild, Level, ModLog, StickyRole } = await import('../../lib/models/index.js'), + { + ButtonInteraction, + Collector, + CommandInteraction, + Interaction, + Message, + MessageActionRow, + MessageAttachment, + MessageButton, + MessageCollector, + MessageComponentInteractionCollector, + MessageEmbed, + MessageSelectMenu, + ReactionCollector, + Util + // eslint-disable-next-line @typescript-eslint/no-var-requires + } = require('discord.js'); // I would use import here but esbuild doesn't like that if (code[code.lang].replace(/ /g, '').includes('9+10' || '10+9')) { output = 21; } else { output = eval(code.js); + //// const menuRow = new MessageActionRow().addComponents( + //// new MessageSelectMenu({ + //// customID: 'test', + //// options: [ + //// { label: '1', value: '1', default: false }, + //// { label: '2', value: '2', default: false }, + //// { label: '3', value: '3', default: false }, + //// { label: '4', value: '4', default: false }, + //// { label: '5', value: '5', default: false }, + //// { label: '6', value: '6', default: false }, + //// { label: '7', value: '7', default: false }, + //// { label: '8', value: '8', default: false }, + //// { label: '9', value: '9', default: false } + //// ] + //// }) + //// ); + //// message.channel.send({ + //// content: 'test', + //// components: [menuRow] + //// }); output = await output; - this.client.console.debug(output); + //// this.client.console.debug(inspect(message, { depth: 0, colors: true })); } let proto, outputProto; if (args.show_proto) { diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 82dde4c..d932816 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -3,7 +3,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class ReloadCommand extends BushCommand { - constructor() { + public constructor() { super('reload', { aliases: ['reload'], category: 'dev', diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts index 9903013..2a807f8 100644 --- a/src/commands/dev/setLevel.ts +++ b/src/commands/dev/setLevel.ts @@ -6,7 +6,7 @@ import { Level } from '../../lib/models'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class SetLevelCommand extends BushCommand { - constructor() { + public constructor() { super('setlevel', { aliases: ['setlevel'], category: 'dev', diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index b77a271..6cdae17 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -3,7 +3,7 @@ import { duration } from 'moment'; import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; export default class BotInfoCommand extends BushCommand { - constructor() { + public constructor() { super('botinfo', { aliases: ['botinfo'], category: 'info', diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 6e14d96..598f01a 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -4,7 +4,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class HelpCommand extends BushCommand { - constructor() { + public constructor() { super('help', { aliases: ['help'], category: 'info', diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 45cfd22..75f4700 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -3,7 +3,7 @@ import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; export default class PingCommand extends BushCommand { - constructor() { + public constructor() { super('ping', { aliases: ['ping'], category: 'info', diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 538ec64..1f7ac15 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -29,7 +29,7 @@ export const pronounMapping = { export type pronounsType = keyof typeof pronounMapping; export default class PronounsCommand extends BushCommand { - constructor() { + public constructor() { super('pronouns', { aliases: ['pronouns', 'pronoun'], category: 'info', diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 9df1c2a..29dc8a6 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -14,7 +14,7 @@ import { Ban, Guild, ModLog, ModLogType } from '../../lib/models'; const durationRegex = /(?:(\d+)(d(?:ays?)?|h(?:ours?|rs?)?|m(?:inutes?|ins?)?|mo(?:nths?)?|w(?:eeks?|ks?)?)(?: |$))/g; */ export default class BanCommand extends BushCommand { - constructor() { + public constructor() { super('ban', { aliases: ['ban'], category: 'moderation', diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index a666c8e..09d6abf 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -4,7 +4,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { Guild, ModLog, ModLogType } from '../../lib/models'; export default class KickCommand extends BushCommand { - constructor() { + public constructor() { super('kick', { aliases: ['kick'], category: 'moderation', diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 27018f1..d094885 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -6,7 +6,7 @@ import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { ModLog } from '../../lib/models'; export default class ModlogCommand extends BushCommand { - constructor() { + public constructor() { super('modlog', { aliases: ['modlog', 'modlogs'], category: 'moderation', diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 88fcc69..3496489 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -5,7 +5,7 @@ import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { Guild, ModLog, ModLogType, Mute } from '../../lib/models'; export default class MuteCommand extends BushCommand { - constructor() { + public constructor() { super('mute', { aliases: ['mute'], category: 'moderation', diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index d1f8e00..71bb88e 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -24,7 +24,7 @@ export default class RoleCommand extends BushCommand { 'Giveaway (5m)': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'], 'Giveaway (1m)': ['*', 'Admin Perms', 'Sr. Moderator', 'Moderator'] }; - constructor() { + public constructor() { super('role', { aliases: ['role', 'addrole', 'removerole'], category: 'moderation', diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts index 40f782d..dbbbfef 100644 --- a/src/commands/moulberry-bush/giveawayPing.ts +++ b/src/commands/moulberry-bush/giveawayPing.ts @@ -3,7 +3,7 @@ import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; import AllowedMentions from '../../lib/utils/AllowedMentions'; export default class GiveawayPingCommand extends BushCommand { - constructor() { + public constructor() { super('giveawayping', { aliases: ['giveawayping', 'giveawaypong'], category: "Moulberry's Bush", diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts index c81c555..eabf7a0 100644 --- a/src/commands/moulberry-bush/level.ts +++ b/src/commands/moulberry-bush/level.ts @@ -11,7 +11,7 @@ import { CanvasProgressBar } from '../../lib/extensions/Util'; */ export default class LevelCommand extends BushCommand { - constructor() { + public constructor() { super('level', { aliases: ['level', 'rank'], category: "Moulberry's Bush", diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index 103e89b..04f496a 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -3,7 +3,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class GuildBlacklistInhibitor extends BushInhibitor { - constructor() { + public constructor() { super('guildBlacklist', { reason: 'guildBlacklist', category: 'blacklist', @@ -14,6 +14,9 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { public exec(message: BushMessage | BushSlashMessage): boolean { if (!message.guild) return false; if (message.author && (this.client.isOwner(message.author) || this.client.isSuperUser(message.author))) return false; - return this.client.cache.global.blacklistedGuilds.includes(message.guild.id); + if (this.client.cache.global.blacklistedGuilds.includes(message.guild.id)) { + this.client.console.debug(`GuildBlacklistInhibitor blocked message.`); + return true; + } } } diff --git a/src/inhibitors/blacklist/userBlacklist.ts b/src/inhibitors/blacklist/userBlacklist.ts index 6772188..4349bb1 100644 --- a/src/inhibitors/blacklist/userBlacklist.ts +++ b/src/inhibitors/blacklist/userBlacklist.ts @@ -3,7 +3,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class UserBlacklistInhibitor extends BushInhibitor { - constructor() { + public constructor() { super('userBlacklist', { reason: 'userBlacklist', category: 'blacklist', @@ -14,6 +14,9 @@ export default class UserBlacklistInhibitor extends BushInhibitor { public exec(message: BushMessage | BushSlashMessage): boolean { if (!message.author) return false; if (this.client.isOwner(message.author) || this.client.isSuperUser(message.author)) return false; - return this.client.cache.global.blacklistedUsers.includes(message.author.id); + if (this.client.cache.global.blacklistedUsers.includes(message.author.id)) { + this.client.console.debug(`UserBlacklistInhibitor blocked message.`); + return true; + } } } diff --git a/src/inhibitors/commands/disabledCommand.ts b/src/inhibitors/commands/disabledCommand.ts index 5b47ce3..6936a41 100644 --- a/src/inhibitors/commands/disabledCommand.ts +++ b/src/inhibitors/commands/disabledCommand.ts @@ -4,7 +4,7 @@ import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashM import { BushMessage } from '../../lib/extensions/discord.js/BushMessage'; export default class DisabledCommandInhibitor extends BushInhibitor { - constructor() { + public constructor() { super('disabledCommand', { reason: 'disabled', type: 'pre', @@ -14,6 +14,9 @@ export default class DisabledCommandInhibitor extends BushInhibitor { public async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { if (this.client.isOwner(message.author)) return false; - return this.client.cache.global.disabledCommands.includes(command?.id); + if (this.client.cache.global.disabledCommands.includes(command?.id)) { + this.client.console.debug(`DisabledCommandInhibitor blocked message.`); + return true; + } } } diff --git a/src/inhibitors/noCache.ts b/src/inhibitors/noCache.ts index fe2e522..db46801 100644 --- a/src/inhibitors/noCache.ts +++ b/src/inhibitors/noCache.ts @@ -2,8 +2,8 @@ import { BushInhibitor } from '../lib/extensions/discord-akairo/BushInhibitor'; import { BushSlashMessage } from '../lib/extensions/discord-akairo/BushSlashMessage'; import { BushMessage } from '../lib/extensions/discord.js/BushMessage'; -export default class noCacheInhibitor extends BushInhibitor { - constructor() { +export default class NoCacheInhibitor extends BushInhibitor { + public constructor() { super('noCache', { reason: 'noCache', type: 'all', @@ -14,7 +14,10 @@ export default class noCacheInhibitor extends BushInhibitor { public async exec(message: BushMessage | BushSlashMessage): Promise<boolean> { if (this.client.isOwner(message.author)) return false; for (const property in this.client.cache) { - if (property === undefined || property === null) return true; + if (property === undefined || property === null) { + this.client.console.debug(`NoCacheInhibitor blocked message.`); + return true; + } } return false; } diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index c18fe80..724f01a 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -24,10 +24,26 @@ import AllowedMentions from '../../utils/AllowedMentions'; import { BushCache } from '../../utils/BushCache'; import { BushConstants } from '../../utils/BushConstants'; import { BushLogger } from '../../utils/BushLogger'; +import { BushButtonInteraction } from '../discord.js/BushButtonInteraction'; +import { BushCategoryChannel } from '../discord.js/BushCategoryChannel'; +import { BushCommandInteraction } from '../discord.js/BushCommandInteraction'; +import { BushDMChannel } from '../discord.js/BushDMChannel'; import { BushGuild } from '../discord.js/BushGuild'; +import { BushGuildEmoji } from '../discord.js/BushGuildEmoji'; import { BushGuildMember } from '../discord.js/BushGuildMember'; import { BushMessage } from '../discord.js/BushMessage'; +import { BushMessageReaction } from '../discord.js/BushMessageReaction'; +import { BushNewsChannel } from '../discord.js/BushNewsChannel'; +import { BushPresence } from '../discord.js/BushPresence'; +import { BushRole } from '../discord.js/BushRole'; +import { BushSelectMenuInteraction } from '../discord.js/BushSelectMenuInteraction'; +import { BushStoreChannel } from '../discord.js/BushStoreChannel'; +import { BushTextChannel } from '../discord.js/BushTextChannel'; +import { BushThreadChannel } from '../discord.js/BushThreadChannel'; +import { BushThreadMember } from '../discord.js/BushThreadMember'; import { BushUser } from '../discord.js/BushUser'; +import { BushVoiceChannel } from '../discord.js/BushVoiceChannel'; +import { BushVoiceState } from '../discord.js/BushVoiceState'; import { BushClientUtil } from './BushClientUtil'; import { BushCommandHandler } from './BushCommandHandler'; import { BushInhibitorHandler } from './BushInhinitorHandler'; @@ -46,6 +62,29 @@ const rl = readline.createInterface({ }); export class BushClient extends AkairoClient { + public static preStart(): void { + Structures.extend('GuildEmoji', () => BushGuildEmoji); + Structures.extend('DMChannel', () => BushDMChannel); + Structures.extend('TextChannel', () => BushTextChannel); + Structures.extend('VoiceChannel', () => BushVoiceChannel); + Structures.extend('CategoryChannel', () => BushCategoryChannel); + Structures.extend('NewsChannel', () => BushNewsChannel); + Structures.extend('StoreChannel', () => BushStoreChannel); + Structures.extend('ThreadChannel', () => BushThreadChannel); + Structures.extend('GuildMember', () => BushGuildMember); + Structures.extend('ThreadMember', () => BushThreadMember); + Structures.extend('Guild', () => BushGuild); + Structures.extend('Message', () => BushMessage); + Structures.extend('MessageReaction', () => BushMessageReaction); + Structures.extend('Presence', () => BushPresence); + Structures.extend('VoiceState', () => BushVoiceState); + Structures.extend('Role', () => BushRole); + Structures.extend('User', () => BushUser); + Structures.extend('CommandInteraction', () => BushCommandInteraction); + Structures.extend('ButtonInteraction', () => BushButtonInteraction); + Structures.extend('SelectMenuInteraction', () => BushSelectMenuInteraction); + } + public config: BotConfig; public listenerHandler: BushListenerHandler; public inhibitorHandler: BushInhibitorHandler; @@ -57,7 +96,7 @@ export class BushClient extends AkairoClient { public logger: BushLogger; public constants = BushConstants; public cache = BushCache; - constructor(config: BotConfig) { + public constructor(config: BotConfig) { super( { ownerID: config.owners, @@ -77,24 +116,24 @@ export class BushClient extends AkairoClient { // Create listener handler this.listenerHandler = new BushListenerHandler(this, { - directory: path.join(__dirname, '..', '..', 'listeners'), + directory: path.join(__dirname, '..', '..', '..', 'listeners'), automateCategories: true }); // Create inhibitor handler this.inhibitorHandler = new BushInhibitorHandler(this, { - directory: path.join(__dirname, '..', '..', 'inhibitors'), + directory: path.join(__dirname, '..', '..', '..', 'inhibitors'), automateCategories: true }); // Create task handler this.taskHandler = new BushTaskHandler(this, { - directory: path.join(__dirname, '..', '..', 'tasks') + directory: path.join(__dirname, '..', '..', '..', 'tasks') }); // Create command handler this.commandHandler = new BushCommandHandler(this, { - directory: path.join(__dirname, '..', '..', 'commands'), + directory: path.join(__dirname, '..', '..', '..', 'commands'), prefix: async ({ guild }: { guild: Guild }) => { if (this.config.dev) return 'dev '; const row = await Models.Guild.findByPk(guild.id); @@ -144,11 +183,6 @@ export class BushClient extends AkairoClient { // Initialize everything private async _init(): Promise<void> { - Structures.extend('User', () => BushUser); - Structures.extend('Guild', () => BushGuild); - Structures.extend('GuildMember', () => BushGuildMember); - Structures.extend('Message', () => BushMessage); - this.commandHandler.useListenerHandler(this.listenerHandler); this.commandHandler.useInhibitorHandler(this.inhibitorHandler); this.commandHandler.ignorePermissions = this.config.owners; @@ -206,6 +240,9 @@ export class BushClient extends AkairoClient { /** Starts the bot */ public async start(): Promise<void> { + //@ts-ignore: stfu bitch + global.client = this; + try { await this._init(); await this.login(this.token); diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 94ad10c..1f8c0f9 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -105,7 +105,7 @@ export class BushClientUtil extends ClientUtil { * Creates this client util * @param client The client to initialize with */ - constructor(client: BushClient) { + public constructor(client: BushClient) { super(client); } diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index b7071b5..101c9d3 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -42,7 +42,7 @@ export class BushCommand extends Command { /** Whether the command is hidden from the help command. */ public hidden: boolean; - constructor(id: string, options?: BushCommandOptions) { + public constructor(id: string, options?: BushCommandOptions) { super(id, options); this.options = options; this.hidden = options.hidden || false; diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts index b4084bd..a1c8036 100644 --- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts +++ b/src/lib/extensions/discord-akairo/BushCommandUtil.ts @@ -1,10 +1,22 @@ import { CommandUtil, ParsedComponentData } from 'discord-akairo'; +import { Collection, Snowflake } from 'discord.js'; +import { BushMessage } from '../discord.js/BushMessage'; import { BushCommand } from './BushCommand'; +import { BushCommandHandler } from './BushCommandHandler'; export interface BushParsedComponentData extends ParsedComponentData { command?: BushCommand; } export class BushCommandUtil extends CommandUtil { - declare parsed?: BushParsedComponentData; + public declare parsed?: BushParsedComponentData; + public declare handler: BushCommandHandler; + public declare message: BushMessage; + public declare messages?: Collection<Snowflake, BushMessage>; + public test: string; + + public constructor(handler: BushCommandHandler, message: BushMessage) { + super(handler, message); + this.test = 'abc'; + } } diff --git a/src/lib/extensions/discord.js/BushActivity.ts b/src/lib/extensions/discord.js/BushActivity.ts new file mode 100644 index 0000000..6ca1611 --- /dev/null +++ b/src/lib/extensions/discord.js/BushActivity.ts @@ -0,0 +1,10 @@ +import { Activity } from 'discord.js'; +import { BushEmoji } from './BushEmoji'; +import { BushPresence } from './BushPresence'; + +export class BushActivity extends Activity { + public emoji: BushEmoji | null; + public constructor(presence: BushPresence, data?: unknown) { + super(presence, data); + } +} diff --git a/src/lib/extensions/discord.js/BushApplicationCommand.ts b/src/lib/extensions/discord.js/BushApplicationCommand.ts new file mode 100644 index 0000000..5a0e139 --- /dev/null +++ b/src/lib/extensions/discord.js/BushApplicationCommand.ts @@ -0,0 +1,14 @@ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { ApplicationCommand, Snowflake } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushGuild } from './BushGuild'; + +export class BushApplicationCommand<PermissionsFetchType = {}> extends ApplicationCommand { + public declare readonly client: BushClient; + public guild: BushGuild | null; + + public constructor(client: BushClient, data: unknown, guild?: BushGuild, guildID?: Snowflake) { + super(client, data, guild, guildID); + } +} diff --git a/src/lib/extensions/discord.js/BushApplicationCommandManager.ts b/src/lib/extensions/discord.js/BushApplicationCommandManager.ts new file mode 100644 index 0000000..fb3375a --- /dev/null +++ b/src/lib/extensions/discord.js/BushApplicationCommandManager.ts @@ -0,0 +1,24 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { ApplicationCommandManager, ApplicationCommandPermissionsManager, GuildResolvable, Snowflake } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushApplicationCommand } from './BushApplicationCommand'; +import { BushGuildResolvable } from './BushCommandInteraction'; + +export type BushApplicationCommandResolvable = BushApplicationCommand | Snowflake; + +export class BushApplicationCommandManager< + ApplicationCommandType = BushApplicationCommand<{ guild: BushGuildResolvable }>, + PermissionsOptionsExtras = { guild: GuildResolvable }, + PermissionsGuildType = null +> extends ApplicationCommandManager<ApplicationCommandType, PermissionsOptionsExtras, PermissionsGuildType> { + public permissions: ApplicationCommandPermissionsManager< + { command?: BushApplicationCommandResolvable } & PermissionsOptionsExtras, + { command: BushApplicationCommandResolvable } & PermissionsOptionsExtras, + PermissionsGuildType, + null + >; + + public constructor(client: BushClient, iterable?: Iterable<any>) { + super(client, iterable); + } +} diff --git a/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts b/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts new file mode 100644 index 0000000..517935d --- /dev/null +++ b/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts @@ -0,0 +1,24 @@ +import { + ApplicationCommand, + ApplicationCommandManager, + ApplicationCommandPermissionsManager, + GuildApplicationCommandManager +} from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushApplicationCommand } from './BushApplicationCommand'; +import { BushApplicationCommandManager } from './BushApplicationCommandManager'; +import { BushGuildApplicationCommandManager } from './BushGuildApplicationCommandManager'; + +export class BushApplicationCommandPermissionsManager< + BaseOptions, + FetchSingleOptions, + GuildType, + CommandIDType +> extends ApplicationCommandPermissionsManager<BaseOptions, FetchSingleOptions, GuildType, CommandIDType> { + public client: BushClient; + public manager: BushApplicationCommandManager | BushGuildApplicationCommandManager | BushApplicationCommand; + + public constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand) { + super(manager); + } +} diff --git a/src/lib/extensions/discord.js/BushButtonInteraction.ts b/src/lib/extensions/discord.js/BushButtonInteraction.ts new file mode 100644 index 0000000..3a54f61 --- /dev/null +++ b/src/lib/extensions/discord.js/BushButtonInteraction.ts @@ -0,0 +1,19 @@ +import { APIInteractionGuildMember } from 'discord-api-types/v8'; +import { ButtonInteraction, PartialDMChannel } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushDMChannel } from './BushDMChannel'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushNewsChannel } from './BushNewsChannel'; +import { BushTextChannel } from './BushTextChannel'; +import { BushUser } from './BushUser'; + +export class BushButtonInteraction extends ButtonInteraction { + public declare readonly channel: BushTextChannel | BushDMChannel | BushNewsChannel | PartialDMChannel | null; + public declare readonly guild: BushGuild | null; + public declare member: BushGuildMember | APIInteractionGuildMember | null; + public declare user: BushUser; + public constructor(client: BushClient, data: unknown) { + super(client, data); + } +} diff --git a/src/lib/extensions/discord.js/BushCategoryChannel.ts b/src/lib/extensions/discord.js/BushCategoryChannel.ts index c4bc3ca..a66b2c6 100644 --- a/src/lib/extensions/discord.js/BushCategoryChannel.ts +++ b/src/lib/extensions/discord.js/BushCategoryChannel.ts @@ -10,7 +10,7 @@ export class BushCategoryChannel extends CategoryChannel { public declare guild: BushGuild; public declare readonly members: Collection<Snowflake, BushGuildMember>; public declare readonly parent: CategoryChannel | null; - constructor(guild: BushGuild, data?: unknown) { + public constructor(guild: BushGuild, data?: unknown) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushCommandInteraction.ts b/src/lib/extensions/discord.js/BushCommandInteraction.ts new file mode 100644 index 0000000..84c0707 --- /dev/null +++ b/src/lib/extensions/discord.js/BushCommandInteraction.ts @@ -0,0 +1,37 @@ +import { APIInteractionGuildMember } from 'discord-api-types/v8'; +import { + ApplicationCommand, + CommandInteraction, + DMChannel, + Invite, + NewsChannel, + PartialDMChannel, + Snowflake, + TextChannel +} from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushApplicationCommand } from './BushApplicationCommand'; +import { BushGuild } from './BushGuild'; +import { BushGuildChannel } from './BushGuildChannel'; +import { BushGuildEmoji } from './BushGuildEmoji'; +import { BushGuildMember } from './BushGuildMember'; +import { BushRole } from './BushRole'; +import { BushUser } from './BushUser'; + +export type BushGuildResolvable = + | BushGuild + | BushGuildChannel + | BushGuildMember + | BushGuildEmoji + | Invite + | BushRole + | Snowflake; + +export class BushCommandInteraction extends CommandInteraction { + public declare readonly client: BushClient; + public declare readonly command: BushApplicationCommand | ApplicationCommand<{ guild: BushGuildResolvable }> | null; + public declare readonly channel: TextChannel | DMChannel | NewsChannel | PartialDMChannel | null; + public declare readonly guild: BushGuild | null; + public declare member: BushGuildMember | APIInteractionGuildMember | null; + public declare user: BushUser; +} diff --git a/src/lib/extensions/discord.js/BushDMChannel.ts b/src/lib/extensions/discord.js/BushDMChannel.ts index 475f224..9bf814b 100644 --- a/src/lib/extensions/discord.js/BushDMChannel.ts +++ b/src/lib/extensions/discord.js/BushDMChannel.ts @@ -8,7 +8,7 @@ export class BushDMChannel extends DMChannel { public declare messages: BushMessageManager; public declare recipient: BushUser; - constructor(client: BushClient, data?: unknown) { + public constructor(client: BushClient, data?: unknown) { super(client, data); } } diff --git a/src/lib/extensions/discord.js/BushEmoji.ts b/src/lib/extensions/discord.js/BushEmoji.ts new file mode 100644 index 0000000..ba48166 --- /dev/null +++ b/src/lib/extensions/discord.js/BushEmoji.ts @@ -0,0 +1,9 @@ +import { Emoji } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; + +export class BushEmoji extends Emoji { + public declare readonly client: BushClient; + public constructor(client: BushClient, emoji: unknown) { + super(client, emoji); + } +} diff --git a/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts b/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts new file mode 100644 index 0000000..d4c1337 --- /dev/null +++ b/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts @@ -0,0 +1,10 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { GuildApplicationCommandManager } from 'discord.js'; +import { BushGuild } from './BushGuild'; + +export class BushGuildApplicationCommandManager extends GuildApplicationCommandManager { + public guild: BushGuild; + public constructor(guild: BushGuild, iterable?: Iterable<any>) { + super(guild, iterable); + } +} diff --git a/src/lib/extensions/discord.js/BushGuildChannel.ts b/src/lib/extensions/discord.js/BushGuildChannel.ts index 75b8a5f..7eada41 100644 --- a/src/lib/extensions/discord.js/BushGuildChannel.ts +++ b/src/lib/extensions/discord.js/BushGuildChannel.ts @@ -5,7 +5,7 @@ import { BushGuild } from './BushGuild'; export class BushGuildChannel extends GuildChannel { public declare readonly client: BushClient; public declare guild: BushGuild; - constructor(guild: BushGuild, data?: unknown) { + public constructor(guild: BushGuild, data?: unknown) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushGuildEmoji.ts b/src/lib/extensions/discord.js/BushGuildEmoji.ts index 8c97ada..c03c1b5 100644 --- a/src/lib/extensions/discord.js/BushGuildEmoji.ts +++ b/src/lib/extensions/discord.js/BushGuildEmoji.ts @@ -9,7 +9,7 @@ export class BushGuildEmoji extends GuildEmoji { public declare guild: BushGuild; public declare author: BushUser | null; public declare readonly roles: BushGuildEmojiRoleManager; - constructor(client: BushClient, data: unknown, guild: BushGuild) { + public constructor(client: BushClient, data: unknown, guild: BushGuild) { super(client, data, guild); } } diff --git a/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts b/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts index 86c2492..00afb25 100644 --- a/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts +++ b/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts @@ -7,7 +7,7 @@ export class BushGuildEmojiRoleManager extends GuildEmojiRoleManager { public declare emoji: BushGuildEmoji; public declare guild: BushGuild; public declare cache: Collection<Snowflake, BushRole>; - constructor(emoji: BushGuildEmoji) { + public constructor(emoji: BushGuildEmoji) { super(emoji); } } diff --git a/src/lib/extensions/discord.js/BushMessage.ts b/src/lib/extensions/discord.js/BushMessage.ts index e4380f7..db68a19 100644 --- a/src/lib/extensions/discord.js/BushMessage.ts +++ b/src/lib/extensions/discord.js/BushMessage.ts @@ -11,7 +11,7 @@ import { BushUser } from './BushUser'; export class BushMessage extends Message { public declare readonly client: BushClient; - public declare util: BushCommandUtil; + public util: BushCommandUtil; public declare readonly guild: BushGuild; public declare readonly member: BushGuildMember; public declare author: BushUser; @@ -22,5 +22,7 @@ export class BushMessage extends Message { channel: BushTextChannel | BushDMChannel | BushNewsChannel | BushThreadChannel ) { super(client, data, channel); + this.util = new BushCommandUtil(this.client.commandHandler, this); + this.client.console.debug(this.util); } } diff --git a/src/lib/extensions/discord.js/BushMessageManager.ts b/src/lib/extensions/discord.js/BushMessageManager.ts index c9256a9..efc6369 100644 --- a/src/lib/extensions/discord.js/BushMessageManager.ts +++ b/src/lib/extensions/discord.js/BushMessageManager.ts @@ -8,7 +8,7 @@ import { BushTextChannel } from './BushTextChannel'; export class BushMessageManager extends MessageManager { public declare readonly client: BushClient; public declare cache: Collection<Snowflake, BushMessage>; - constructor(channel: BushTextChannel | BushDMChannel, iterable?: Iterable<any>) { + public constructor(channel: BushTextChannel | BushDMChannel, iterable?: Iterable<any>) { super(channel, iterable); } } diff --git a/src/lib/extensions/discord.js/BushMessageReaction.ts b/src/lib/extensions/discord.js/BushMessageReaction.ts new file mode 100644 index 0000000..9958059 --- /dev/null +++ b/src/lib/extensions/discord.js/BushMessageReaction.ts @@ -0,0 +1,14 @@ +import { MessageReaction } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushGuildEmoji } from './BushGuildEmoji'; +import { BushMessage } from './BushMessage'; +import { BushReactionEmoji } from './BushReactionEmoji'; + +export class BushMessageReaction extends MessageReaction { + public readonly client: BushClient; + public readonly emoji: BushGuildEmoji | BushReactionEmoji; + + public constructor(client: BushClient, data: unknown, message: BushMessage) { + super(client, data, message); + } +} diff --git a/src/lib/extensions/discord.js/BushNewsChannel.ts b/src/lib/extensions/discord.js/BushNewsChannel.ts index 77b7a9d..b026b5e 100644 --- a/src/lib/extensions/discord.js/BushNewsChannel.ts +++ b/src/lib/extensions/discord.js/BushNewsChannel.ts @@ -10,7 +10,7 @@ export class BushNewsChannel extends NewsChannel { public declare messages: BushMessageManager; public declare threads: BushThreadManager; // eslint-disable-next-line @typescript-eslint/ban-types - constructor(guild: BushGuild, data?: object) { + public constructor(guild: BushGuild, data?: object) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushPresence.ts b/src/lib/extensions/discord.js/BushPresence.ts new file mode 100644 index 0000000..13c7567 --- /dev/null +++ b/src/lib/extensions/discord.js/BushPresence.ts @@ -0,0 +1,15 @@ +import { Presence } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushUser } from './BushUser'; + +export class BushPresence extends Presence { + public declare guild: BushGuild | null; + public declare readonly member: BushGuildMember | null; + public declare readonly user: BushUser | null; + + public constructor(client: BushClient, data?: unknown) { + super(client, data); + } +} diff --git a/src/lib/extensions/discord.js/BushReactionEmoji.ts b/src/lib/extensions/discord.js/BushReactionEmoji.ts new file mode 100644 index 0000000..a25c1b8 --- /dev/null +++ b/src/lib/extensions/discord.js/BushReactionEmoji.ts @@ -0,0 +1,11 @@ +import { ReactionEmoji } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushMessageReaction } from './BushMessageReaction'; + +export class BushReactionEmoji extends ReactionEmoji { + public declare readonly client: BushClient; + public declare reaction: BushMessageReaction; + public constructor(reaction: BushMessageReaction, emoji: unknown) { + super(reaction, emoji); + } +} diff --git a/src/lib/extensions/discord.js/BushRole.ts b/src/lib/extensions/discord.js/BushRole.ts index ce8e9dc..1d502b2 100644 --- a/src/lib/extensions/discord.js/BushRole.ts +++ b/src/lib/extensions/discord.js/BushRole.ts @@ -7,7 +7,7 @@ export class BushRole extends Role { public declare readonly client: BushClient; public guild: BushGuild; public readonly members: Collection<Snowflake, BushGuildMember>; - constructor(client: BushClient, data: unknown, guild: BushGuild) { + public constructor(client: BushClient, data: unknown, guild: BushGuild) { super(client, data, guild); } } diff --git a/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts b/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts new file mode 100644 index 0000000..1dd1638 --- /dev/null +++ b/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts @@ -0,0 +1,19 @@ +import { APIInteractionGuildMember } from 'discord-api-types/v8'; +import { PartialDMChannel, SelectMenuInteraction } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushDMChannel } from './BushDMChannel'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushNewsChannel } from './BushNewsChannel'; +import { BushTextChannel } from './BushTextChannel'; +import { BushUser } from './BushUser'; + +export class BushSelectMenuInteraction extends SelectMenuInteraction { + public declare readonly channel: BushTextChannel | BushDMChannel | BushNewsChannel | PartialDMChannel | null; + public declare readonly guild: BushGuild | null; + public declare member: BushGuildMember | APIInteractionGuildMember | null; + public declare user: BushUser; + public constructor(client: BushClient, data: unknown) { + super(client, data); + } +} diff --git a/src/lib/extensions/discord.js/BushStageChannel.ts b/src/lib/extensions/discord.js/BushStageChannel.ts new file mode 100644 index 0000000..5bd3f45 --- /dev/null +++ b/src/lib/extensions/discord.js/BushStageChannel.ts @@ -0,0 +1,17 @@ +import { Collection, Snowflake, StageChannel } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushCategoryChannel } from './BushCategoryChannel'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushStageInstance } from './BushStageInstance'; + +export class BushStageChannel extends StageChannel { + public declare readonly client: BushClient; + public declare readonly instance: BushStageInstance | null; + public declare readonly members: Collection<Snowflake, BushGuildMember>; + public declare guild: BushGuild; + public declare readonly parent: BushCategoryChannel | null; + public constructor(guild: BushGuild, data?: unknown) { + super(guild, data); + } +} diff --git a/src/lib/extensions/discord.js/BushStageInstance.ts b/src/lib/extensions/discord.js/BushStageInstance.ts new file mode 100644 index 0000000..f162d33 --- /dev/null +++ b/src/lib/extensions/discord.js/BushStageInstance.ts @@ -0,0 +1,13 @@ +import { StageInstance } from 'discord.js'; +import { BushClient } from '../discord-akairo/BushClient'; +import { BushGuild } from './BushGuild'; +import { BushStageChannel } from './BushStageChannel'; + +export class BushStageInstance extends StageInstance { + public declare readonly client: BushClient; + public declare readonly channel: BushStageChannel | null; + public declare readonly guild: BushGuild | null; + public constructor(client: BushClient, data: unknown, channel: BushStageChannel) { + super(client, data, channel); + } +} diff --git a/src/lib/extensions/discord.js/BushStoreChannel.ts b/src/lib/extensions/discord.js/BushStoreChannel.ts index 1a9b855..8ce22c0 100644 --- a/src/lib/extensions/discord.js/BushStoreChannel.ts +++ b/src/lib/extensions/discord.js/BushStoreChannel.ts @@ -10,7 +10,7 @@ export class BushStoreChannel extends StoreChannel { public declare readonly members: Collection<Snowflake, BushGuildMember>; public declare readonly parent: BushCategoryChannel | null; - constructor(guild: BushGuild, data?: unknown) { + public constructor(guild: BushGuild, data?: unknown) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushTextChannel.ts b/src/lib/extensions/discord.js/BushTextChannel.ts index b58aa7b..26e3858 100644 --- a/src/lib/extensions/discord.js/BushTextChannel.ts +++ b/src/lib/extensions/discord.js/BushTextChannel.ts @@ -7,7 +7,7 @@ export class BushTextChannel extends TextChannel { public declare readonly client: BushClient; public declare guild: BushGuild; public declare messages: BushMessageManager; - constructor(guild: BushGuild, data?: unknown) { + public constructor(guild: BushGuild, data?: unknown) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushThreadChannel.ts b/src/lib/extensions/discord.js/BushThreadChannel.ts index 10fc65e..9f6e84b 100644 --- a/src/lib/extensions/discord.js/BushThreadChannel.ts +++ b/src/lib/extensions/discord.js/BushThreadChannel.ts @@ -17,7 +17,7 @@ export class BushThreadChannel extends ThreadChannel { public declare readonly guildMembers: Collection<Snowflake, BushGuildMember>; public declare readonly parent: BushTextChannel | BushNewsChannel | null; - constructor(guild: BushGuild, data?: object) { + public constructor(guild: BushGuild, data?: object) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushThreadManager.ts b/src/lib/extensions/discord.js/BushThreadManager.ts index 408ac7f..76eaf22 100644 --- a/src/lib/extensions/discord.js/BushThreadManager.ts +++ b/src/lib/extensions/discord.js/BushThreadManager.ts @@ -5,7 +5,7 @@ import { BushTextChannel } from './BushTextChannel'; export class BushThreadManager extends ThreadManager { public declare channel: BushTextChannel | BushNewsChannel; - constructor(channel: BushTextChannel | BushNewsChannel, iterable?: Iterable<any>) { + public constructor(channel: BushTextChannel | BushNewsChannel, iterable?: Iterable<any>) { super(channel, iterable); } } diff --git a/src/lib/extensions/discord.js/BushThreadMember.ts b/src/lib/extensions/discord.js/BushThreadMember.ts index 16da663..4ef51ae 100644 --- a/src/lib/extensions/discord.js/BushThreadMember.ts +++ b/src/lib/extensions/discord.js/BushThreadMember.ts @@ -8,7 +8,7 @@ export class BushThreadMember extends ThreadMember { public declare readonly guildMember: BushGuildMember | null; public declare readonly user: BushUser | null; public declare thread: BushThreadChannel; - constructor(thread: BushThreadChannel, data?: object) { + public constructor(thread: BushThreadChannel, data?: object) { super(thread, data); } } diff --git a/src/lib/extensions/discord.js/BushThreadMemberManager.ts b/src/lib/extensions/discord.js/BushThreadMemberManager.ts index 7c7bb6d..e375322 100644 --- a/src/lib/extensions/discord.js/BushThreadMemberManager.ts +++ b/src/lib/extensions/discord.js/BushThreadMemberManager.ts @@ -17,7 +17,7 @@ export class BushThreadMemberManager extends ThreadMemberManager { public declare thread: BushThreadChannel; public declare readonly client: BushClient; - constructor(thread: BushThreadChannel, iterable?: Iterable<any>) { + public constructor(thread: BushThreadChannel, iterable?: Iterable<any>) { super(thread, iterable); } } diff --git a/src/lib/extensions/discord.js/BushVoiceChannel.ts b/src/lib/extensions/discord.js/BushVoiceChannel.ts index 7510b69..82a68b1 100644 --- a/src/lib/extensions/discord.js/BushVoiceChannel.ts +++ b/src/lib/extensions/discord.js/BushVoiceChannel.ts @@ -6,7 +6,7 @@ import { BushGuildMember } from './BushGuildMember'; export class BushVoiceChannel extends VoiceChannel { public declare readonly client: BushClient; public declare readonly members: Collection<Snowflake, BushGuildMember>; - constructor(guild: BushGuild, data?: unknown) { + public constructor(guild: BushGuild, data?: unknown) { super(guild, data); } } diff --git a/src/lib/extensions/discord.js/BushVoiceState.ts b/src/lib/extensions/discord.js/BushVoiceState.ts new file mode 100644 index 0000000..d93fa13 --- /dev/null +++ b/src/lib/extensions/discord.js/BushVoiceState.ts @@ -0,0 +1,14 @@ +import { VoiceState } from 'discord.js'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushStageChannel } from './BushStageChannel'; +import { BushVoiceChannel } from './BushVoiceChannel'; + +export class BushVoiceState extends VoiceState { + public readonly channel: BushVoiceChannel | BushStageChannel | null; + public guild: BushGuild; + public readonly member: BushGuildMember | null; + public constructor(guild: BushGuild, data: unknown) { + super(guild, data); + } +} diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 7293c41..915d8f1 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -29,9 +29,9 @@ export class BushLogger { return tempParsedArray.join(''); } - private inspectContent(content: any, depth = 2): string { + private inspectContent(content: any, depth = 2, colors = true): string { if (typeof content !== 'string') { - return inspect(content, { depth }); + return inspect(content, { depth, colors }); } return content; } @@ -61,7 +61,8 @@ export class BushLogger { * Logs information. Highlight information by surrounding it in `<<>>`. * @param header - The header displayed before the content, displayed in cyan. * @param content - The content to log, highlights displayed in bright blue. - * @param sendChannel - Should this also be logged to discord? Defaults to true. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ public get log() { return this.info; @@ -82,8 +83,19 @@ export class BushLogger { /** * Logs debug information. Only works in dev is enabled in the config. * @param content - The content to log. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public debug(...content: any): void { + public debug(content: any, depth = 0): void { + if (!this.client.config.dev) return; + const newContent = this.inspectContent(content, depth, true); + console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, newContent); + } + + /** + * Logs raw debug information. Only works in dev is enabled in the config. + * @param content - The content to log. + */ + public debugRaw(...content: any): void { if (!this.client.config.dev) return; console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, ...content); } @@ -92,11 +104,12 @@ export class BushLogger { * Logs verbose information. Highlight information by surrounding it in `<<>>`. * @param header - The header printed before the content, displayed in grey. * @param content - The content to log, highlights displayed in bright black. - * @param sendChannel = false - Should this also be logged to discord? Defaults to false. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public async verbose(header: string, content: any, sendChannel = false): Promise<void> { + public async verbose(header: string, content: any, sendChannel = false, depth = 0): Promise<void> { if (!this.client.config.logging.verbose) return; - const newContent = this.inspectContent(content); + const newContent = this.inspectContent(content, depth, true); console.info( `${chalk.bgGrey(this.getTimeStamp())} ${chalk.grey(`[${header}]`)} ` + this.parseFormatting(newContent, 'blackBright') ); @@ -112,11 +125,12 @@ export class BushLogger { * Logs information. Highlight information by surrounding it in `<<>>`. * @param header - The header displayed before the content, displayed in cyan. * @param content - The content to log, highlights displayed in bright blue. - * @param sendChannel - Should this also be logged to discord? Defaults to true. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public async info(header: string, content: any, sendChannel = true): Promise<void> { + public async info(header: string, content: any, sendChannel = true, depth = 0): Promise<void> { if (!this.client.config.logging.info) return; - const newContent = this.inspectContent(content); + const newContent = this.inspectContent(content, depth, true); console.info( `${chalk.bgCyan(this.getTimeStamp())} ${chalk.cyan(`[${header}]`)} ` + this.parseFormatting(newContent, 'blueBright') ); @@ -132,10 +146,11 @@ export class BushLogger { * Logs warnings. Highlight information by surrounding it in `<<>>`. * @param header - The header displayed before the content, displayed in yellow. * @param content - The content to log, highlights displayed in bright yellow. - * @param sendChannel - Should this also be logged to discord? Defaults to true. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public async warn(header: string, content: any, sendChannel = true): Promise<void> { - const newContent = this.inspectContent(content); + public async warn(header: string, content: any, sendChannel = true, depth = 0): Promise<void> { + const newContent = this.inspectContent(content, depth, true); console.warn( `${chalk.bgYellow(this.getTimeStamp())} ${chalk.yellow(`[${header}]`)} ` + this.parseFormatting(newContent, 'yellowBright') @@ -153,10 +168,11 @@ export class BushLogger { * Logs errors. Highlight information by surrounding it in `<<>>`. * @param header - The header displayed before the content, displayed in bright red. * @param content - The content to log, highlights displayed in bright red. - * @param sendChannel - Should this also be logged to discord? Defaults to true. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public async error(header: string, content: any, sendChannel = true): Promise<void> { - const newContent = this.inspectContent(content); + public async error(header: string, content: any, sendChannel = true, depth = 0): Promise<void> { + const newContent = this.inspectContent(content, depth, true); console.error( `${chalk.bgRedBright(this.getTimeStamp())} ${chalk.redBright(`[${header}]`)} ` + this.parseFormatting(newContent, 'redBright') @@ -173,10 +189,11 @@ export class BushLogger { * Logs successes. Highlight information by surrounding it in `<<>>`. * @param header - The header displayed before the content, displayed in green. * @param content - The content to log, highlights displayed in bright green. - * @param sendChannel - Should this also be logged to discord? Defaults to true. + * @param sendChannel - Should this also be logged to discord? Defaults to false. + * @param depth - The depth the content will inspected. Defaults to 0. */ - public async success(header: string, content: any, sendChannel = true): Promise<void> { - const newContent = this.inspectContent(content); + public async success(header: string, content: any, sendChannel = true, depth = 0): Promise<void> { + const newContent = this.inspectContent(content, depth, true); console.log( `${chalk.bgGreen(this.getTimeStamp())} ${chalk.greenBright(`[${header}]`)} ` + this.parseFormatting(newContent, 'greenBright') diff --git a/src/lib/utils/CanvasProgressBar.ts b/src/lib/utils/CanvasProgressBar.ts index d870bf9..521a444 100644 --- a/src/lib/utils/CanvasProgressBar.ts +++ b/src/lib/utils/CanvasProgressBar.ts @@ -9,7 +9,7 @@ export class CanvasProgressBar { private p: number; private ctx: CanvasRenderingContext2D; - constructor( + public constructor( ctx: CanvasRenderingContext2D, dimension: { x: number; y: number; width: number; height: number }, color: string, diff --git a/src/listeners/client/interaction.ts b/src/listeners/client/interaction.ts new file mode 100644 index 0000000..881d759 --- /dev/null +++ b/src/listeners/client/interaction.ts @@ -0,0 +1,37 @@ +import { ButtonInteraction, CommandInteraction, Interaction, SelectMenuInteraction } from 'discord.js'; +import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; + +export default class InteractionListener extends BushListener { + public constructor() { + super('interaction', { + emitter: 'client', + event: 'interaction', + category: 'client' + }); + } + + async exec(interaction: Interaction | CommandInteraction | ButtonInteraction | SelectMenuInteraction): Promise<unknown> { + if (!interaction) return; + if (interaction.isCommand()) { + this.client.console.info( + 'SlashCommand', + `The <<${interaction.commandName}>> command was used by <<${interaction.user.tag}>> in <<${ + interaction.channel.type == 'dm' ? interaction.channel.recipient + 's DMs' : interaction.channel.name + }>>.` + ); + return; + } else if (interaction.isButton()) { + if (interaction.customID.startsWith('paginate_')) return; + return await interaction.reply({ content: 'Buttons go brrr', ephemeral: true }); + } else if (interaction.isSelectMenu()) { + return await interaction.reply({ + content: `You selected ${ + Array.isArray(interaction.values) + ? this.client.util.oxford(this.client.util.surroundArray(interaction.values, '`'), 'and', '') + : `\`${interaction.values}\`` + }.`, + ephemeral: true + }); + } + } +} diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts index 6cfd239..02726f3 100644 --- a/src/listeners/commands/commandStarted.ts +++ b/src/listeners/commands/commandStarted.ts @@ -3,7 +3,7 @@ import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; export default class CommandStartedListener extends BushListener { - constructor() { + public constructor() { super('commandStarted', { emitter: 'commandHandler', event: 'commandStarted' diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index ea48f34..767bd3d 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -5,7 +5,7 @@ import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; export default class SlashCommandErrorListener extends BushListener { - constructor() { + public constructor() { super('slashError', { emitter: 'commandHandler', event: 'slashError' diff --git a/src/listeners/commands/slashStarted.ts b/src/listeners/commands/slashStarted.ts index 028d962..d6d5c3a 100644 --- a/src/listeners/commands/slashStarted.ts +++ b/src/listeners/commands/slashStarted.ts @@ -3,7 +3,7 @@ import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; export default class SlashStartedListener extends BushListener { - constructor() { + public constructor() { super('slashStarted', { emitter: 'commandHandler', event: 'slashStarted' diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index ea6a491..1d8d5e6 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -5,7 +5,7 @@ import { Level } from '../../lib/models'; export default class LevelListener extends BushListener { private levelCooldowns: Set<string> = new Set(); private blacklistedChannels = ['702456294874808330']; - constructor() { + public constructor() { super('level', { emitter: 'commandHandler', event: 'messageInvalid' // Using messageInvalid here so commands don't give xp diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 2fcfdc9..06a8e1e 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -1,7 +1,7 @@ import { BushListener } from '../../lib/extensions/discord-akairo/BushListener'; export default class PromiseRejectionListener extends BushListener { - constructor() { + public constructor() { super('promiseRejection', { emitter: 'process', event: 'unhandledRejection' diff --git a/src/tasks/unban.ts b/src/tasks/unban.ts index b6d96b8..861f71f 100644 --- a/src/tasks/unban.ts +++ b/src/tasks/unban.ts @@ -4,7 +4,7 @@ import { BushTask } from '../lib/extensions/discord-akairo/BushTask'; import { Ban } from '../lib/models'; export default class UnbanTask extends BushTask { - constructor() { + public constructor() { super('unban', { delay: 30_000, // 1/2 min runOnStart: true diff --git a/src/tasks/unmute.ts b/src/tasks/unmute.ts index 6513345..a259b17 100644 --- a/src/tasks/unmute.ts +++ b/src/tasks/unmute.ts @@ -5,7 +5,7 @@ import { Guild } from '../lib/models'; import { Mute } from '../lib/models/Mute'; export default class UnmuteTask extends BushTask { - constructor() { + public constructor() { super('unmute', { delay: 30_000, // 1/2 min runOnStart: true diff --git a/src/tasks/updateCache.ts b/src/tasks/updateCache.ts index 2f1d2d1..08e0f3c 100644 --- a/src/tasks/updateCache.ts +++ b/src/tasks/updateCache.ts @@ -4,7 +4,7 @@ import { Global } from '../lib/models'; import * as config from './../config/options'; export default class UpdateCacheTask extends BushTask { - constructor() { + public constructor() { super('updateCache', { delay: 300_000, // 5 minutes runOnStart: false // done in preinit task |