aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/lib
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/common/AutoMod.ts12
-rw-r--r--src/lib/common/ButtonPaginator.ts25
-rw-r--r--src/lib/common/ConfirmationPrompt.ts8
-rw-r--r--src/lib/common/DeleteButton.ts10
-rw-r--r--src/lib/common/HighlightManager.ts10
-rw-r--r--src/lib/common/util/Arg.ts16
-rw-r--r--src/lib/common/util/Moderation.ts51
-rw-r--r--src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts146
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts49
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts87
-rw-r--r--src/lib/extensions/discord-akairo/BushCommandHandler.ts45
-rw-r--r--src/lib/extensions/discord-akairo/BushCommandUtil.ts22
-rw-r--r--src/lib/extensions/discord-akairo/BushInhibitor.ts9
-rw-r--r--src/lib/extensions/discord-akairo/BushInhibitorHandler.ts5
-rw-r--r--src/lib/extensions/discord-akairo/BushListener.ts3
-rw-r--r--src/lib/extensions/discord-akairo/BushListenerHandler.ts5
-rw-r--r--src/lib/extensions/discord-akairo/BushSlashMessage.ts34
-rw-r--r--src/lib/extensions/discord-akairo/BushTask.ts11
-rw-r--r--src/lib/extensions/discord-akairo/BushTaskHandler.ts9
-rw-r--r--src/lib/extensions/discord-akairo/SlashMessage.ts3
-rw-r--r--src/lib/extensions/discord.js/BushActivity.ts14
-rw-r--r--src/lib/extensions/discord.js/BushApplicationCommand.ts16
-rw-r--r--src/lib/extensions/discord.js/BushApplicationCommandManager.ts151
-rw-r--r--src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts184
-rw-r--r--src/lib/extensions/discord.js/BushBaseGuildEmojiManager.ts19
-rw-r--r--src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts28
-rw-r--r--src/lib/extensions/discord.js/BushBaseGuildVoiceChannel.ts13
-rw-r--r--src/lib/extensions/discord.js/BushButtonInteraction.ts30
-rw-r--r--src/lib/extensions/discord.js/BushCategoryChannel.ts41
-rw-r--r--src/lib/extensions/discord.js/BushCategoryChannelChildManager.ts44
-rw-r--r--src/lib/extensions/discord.js/BushChannel.ts39
-rw-r--r--src/lib/extensions/discord.js/BushChannelManager.ts25
-rw-r--r--src/lib/extensions/discord.js/BushChatInputCommandInteraction.ts49
-rw-r--r--src/lib/extensions/discord.js/BushClientEvents.ts291
-rw-r--r--src/lib/extensions/discord.js/BushClientUser.ts98
-rw-r--r--src/lib/extensions/discord.js/BushDMChannel.ts45
-rw-r--r--src/lib/extensions/discord.js/BushEmoji.ts14
-rw-r--r--src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts114
-rw-r--r--src/lib/extensions/discord.js/BushGuildBan.ts15
-rw-r--r--src/lib/extensions/discord.js/BushGuildChannel.ts47
-rw-r--r--src/lib/extensions/discord.js/BushGuildChannelManager.ts183
-rw-r--r--src/lib/extensions/discord.js/BushGuildEmoji.ts20
-rw-r--r--src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts55
-rw-r--r--src/lib/extensions/discord.js/BushGuildManager.ts35
-rw-r--r--src/lib/extensions/discord.js/BushGuildMemberManager.ts177
-rw-r--r--src/lib/extensions/discord.js/BushMessage.ts63
-rw-r--r--src/lib/extensions/discord.js/BushMessageManager.ts113
-rw-r--r--src/lib/extensions/discord.js/BushMessageReaction.ts20
-rw-r--r--src/lib/extensions/discord.js/BushModalSubmitInteraction.ts96
-rw-r--r--src/lib/extensions/discord.js/BushNewsChannel.ts15
-rw-r--r--src/lib/extensions/discord.js/BushPresence.ts19
-rw-r--r--src/lib/extensions/discord.js/BushReactionEmoji.ts16
-rw-r--r--src/lib/extensions/discord.js/BushRole.ts18
-rw-r--r--src/lib/extensions/discord.js/BushSelectMenuInteraction.ts30
-rw-r--r--src/lib/extensions/discord.js/BushStageChannel.ts20
-rw-r--r--src/lib/extensions/discord.js/BushStageInstance.ts17
-rw-r--r--src/lib/extensions/discord.js/BushTextChannel.ts42
-rw-r--r--src/lib/extensions/discord.js/BushThreadChannel.ts47
-rw-r--r--src/lib/extensions/discord.js/BushThreadManager.ts84
-rw-r--r--src/lib/extensions/discord.js/BushThreadMember.ts19
-rw-r--r--src/lib/extensions/discord.js/BushThreadMemberManager.ts62
-rw-r--r--src/lib/extensions/discord.js/BushUser.ts34
-rw-r--r--src/lib/extensions/discord.js/BushUserManager.ts60
-rw-r--r--src/lib/extensions/discord.js/BushVoiceChannel.ts40
-rw-r--r--src/lib/extensions/discord.js/BushVoiceState.ts20
-rw-r--r--src/lib/extensions/discord.js/ExtendedGuild.ts (renamed from src/lib/extensions/discord.js/BushGuild.ts)194
-rw-r--r--src/lib/extensions/discord.js/ExtendedGuildMember.ts (renamed from src/lib/extensions/discord.js/BushGuildMember.ts)185
-rw-r--r--src/lib/extensions/discord.js/ExtendedMessage.ts12
-rw-r--r--src/lib/extensions/discord.js/ExtendedUser.ts35
-rw-r--r--src/lib/extensions/discord.js/other.ts188
-rw-r--r--src/lib/index.ts53
-rw-r--r--src/lib/utils/BushLogger.ts6
73 files changed, 626 insertions, 3193 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index f30eab7..982e0e8 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -1,4 +1,4 @@
-import { banResponse, Moderation, type BushButtonInteraction, type BushMessage } from '#lib';
+import { banResponse, Moderation } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
import {
@@ -8,6 +8,8 @@ import {
EmbedBuilder,
GuildMember,
PermissionFlagsBits,
+ type ButtonInteraction,
+ type Message,
type TextChannel
} from 'discord.js';
@@ -18,7 +20,7 @@ export class AutoMod {
/**
* The message to check for blacklisted phrases on
*/
- private message: BushMessage;
+ private message: Message;
/**
* Whether or not a punishment has already been given to the user
@@ -28,7 +30,7 @@ export class AutoMod {
/**
* @param message The message to check and potentially perform automod actions to
*/
- public constructor(message: BushMessage) {
+ public constructor(message: Message) {
this.message = message;
if (message.author.id === client.user?.id) return;
void this.handle();
@@ -355,7 +357,7 @@ export class AutoMod {
* Handles the ban button in the automod log.
* @param interaction The button interaction.
*/
- public static async handleInteraction(interaction: BushButtonInteraction) {
+ public static async handleInteraction(interaction: ButtonInteraction) {
if (!interaction.memberPermissions?.has(PermissionFlagsBits.BanMembers))
return interaction.reply({
content: `${util.emojis.error} You are missing the **Ban Members** permission.`,
@@ -382,7 +384,7 @@ export class AutoMod {
user: userId,
reason,
moderator: interaction.user.id,
- evidence: (interaction.message as BushMessage).url ?? undefined
+ evidence: (interaction.message as Message).url ?? undefined
});
const victimUserFormatted = (await util.resolveNonCachedUser(userId))?.tag ?? userId;
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index cc95601..64870cf 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -1,7 +1,14 @@
-import { DeleteButton, type BushMessage, type BushSlashMessage } from '#lib';
+import { DeleteButton, type CommandMessage, type SlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
-import { APIEmbed } from 'discord-api-types/v10';
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, type MessageComponentInteraction } from 'discord.js';
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ type APIEmbed,
+ type Message,
+ type MessageComponentInteraction
+} from 'discord.js';
/**
* Sends multiple embeds with controls to switch between them
@@ -10,7 +17,7 @@ export class ButtonPaginator {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* The embeds to paginate
@@ -35,7 +42,7 @@ export class ButtonPaginator {
/**
* The paginator message
*/
- protected sentMessage: BushMessage | undefined;
+ protected sentMessage: Message | undefined;
/**
* @param message The message to respond to
@@ -45,7 +52,7 @@ export class ButtonPaginator {
* @param startOn The page to start from (**not** the index)
*/
protected constructor(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
embeds: EmbedBuilder[] | APIEmbed[],
text: string | null,
deleteOnExit: boolean,
@@ -80,11 +87,11 @@ export class ButtonPaginator {
* Sends the paginator message
*/
protected async send() {
- this.sentMessage = (await this.message.util.reply({
+ this.sentMessage = await this.message.util.reply({
content: this.text,
embeds: [this.embeds[this.curPage]],
components: [this.getPaginationRow()]
- })) as BushMessage;
+ });
const collector = this.sentMessage.createMessageComponentCollector({
filter: (i) => i.customId.startsWith('paginate_'),
@@ -214,7 +221,7 @@ export class ButtonPaginator {
* @param startOn The page to start from (**not** the index)
*/
public static async send(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
embeds: EmbedBuilder[] | APIEmbed[],
text: string | null = null,
deleteOnExit = true,
diff --git a/src/lib/common/ConfirmationPrompt.ts b/src/lib/common/ConfirmationPrompt.ts
index c611fd3..c95dbbc 100644
--- a/src/lib/common/ConfirmationPrompt.ts
+++ b/src/lib/common/ConfirmationPrompt.ts
@@ -1,4 +1,4 @@
-import { type BushMessage, type BushSlashMessage } from '#lib';
+import { type CommandMessage, type SlashMessage } from '#lib';
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type MessageComponentInteraction, type MessageOptions } from 'discord.js';
/**
@@ -13,13 +13,13 @@ export class ConfirmationPrompt {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* @param message The message to respond to
* @param options The send message options
*/
- protected constructor(message: BushMessage | BushSlashMessage, messageOptions: MessageOptions) {
+ protected constructor(message: CommandMessage | SlashMessage, messageOptions: MessageOptions) {
this.message = message;
this.messageOptions = messageOptions;
}
@@ -71,7 +71,7 @@ export class ConfirmationPrompt {
* @param message The message to respond to
* @param options The send message options
*/
- public static async send(message: BushMessage | BushSlashMessage, sendOptions: MessageOptions): Promise<boolean> {
+ public static async send(message: CommandMessage | SlashMessage, sendOptions: MessageOptions): Promise<boolean> {
return new ConfirmationPrompt(message, sendOptions).send();
}
}
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index 03e2639..91f4bfa 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -1,4 +1,4 @@
-import { PaginateEmojis, type BushMessage, type BushSlashMessage } from '#lib';
+import { PaginateEmojis, type CommandMessage, type SlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
import {
ActionRowBuilder,
@@ -22,13 +22,13 @@ export class DeleteButton {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* @param message The message to respond to
* @param options The send message options
*/
- protected constructor(message: BushMessage | BushSlashMessage, options: MessageOptions) {
+ protected constructor(message: CommandMessage | SlashMessage, options: MessageOptions) {
this.message = message;
this.messageOptions = options;
}
@@ -39,7 +39,7 @@ export class DeleteButton {
protected async send() {
this.updateComponents();
- const msg = (await this.message.util.reply(this.messageOptions)) as BushMessage;
+ const msg = await this.message.util.reply(this.messageOptions);
const collector = msg.createMessageComponentCollector({
filter: (interaction) => interaction.customId == 'paginate__stop' && interaction.message?.id == msg.id,
@@ -85,7 +85,7 @@ export class DeleteButton {
* @param message The message to respond to
* @param options The send message options
*/
- public static async send(message: BushMessage | BushSlashMessage, options: Omit<MessageOptions, 'components'>) {
+ public static async send(message: CommandMessage | SlashMessage, options: Omit<MessageOptions, 'components'>) {
return new DeleteButton(message, options).send();
}
}
diff --git a/src/lib/common/HighlightManager.ts b/src/lib/common/HighlightManager.ts
index fffb266..fdec322 100644
--- a/src/lib/common/HighlightManager.ts
+++ b/src/lib/common/HighlightManager.ts
@@ -1,6 +1,6 @@
-import { Highlight, type BushMessage, type HighlightWord } from '#lib';
+import { Highlight, type HighlightWord } from '#lib';
import assert from 'assert';
-import { Collection, type Snowflake } from 'discord.js';
+import { Collection, type Message, type Snowflake } from 'discord.js';
import { Time } from '../utils/BushConstants.js';
const NOTIFY_COOLDOWN = 5 * Time.Minute;
@@ -75,7 +75,7 @@ export class HighlightManager {
* @param message The message to check.
* @returns A collection users mapped to the highlight matched
*/
- public checkMessage(message: BushMessage): Collection<Snowflake, HighlightWord> {
+ public checkMessage(message: Message): Collection<Snowflake, HighlightWord> {
// even if there are multiple matches, only the first one is returned
const ret = new Collection<Snowflake, HighlightWord>();
if (!message.content || !message.inGuild()) return ret;
@@ -225,7 +225,7 @@ export class HighlightManager {
* @param hl The highlight that was matched.
* @returns Whether or a dm was sent.
*/
- public async notify(message: BushMessage, user: Snowflake, hl: HighlightWord): Promise<boolean> {
+ public async notify(message: Message, user: Snowflake, hl: HighlightWord): Promise<boolean> {
assert(message.inGuild());
dmCooldown: {
@@ -301,7 +301,7 @@ export class HighlightManager {
* Updates the time that a user last talked in a particular guild.
* @param message The message the user sent.
*/
- public updateLastTalked(message: BushMessage): void {
+ public updateLastTalked(message: Message): void {
if (!message.inGuild()) return;
const lastTalked = (
this.userLastTalkedCooldown.has(message.guildId)
diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts
index 01d3b0b..51d8065 100644
--- a/src/lib/common/util/Arg.ts
+++ b/src/lib/common/util/Arg.ts
@@ -1,4 +1,10 @@
-import { type BaseBushArgumentType, type BushArgumentType, type BushArgumentTypeCaster, type BushSlashMessage } from '#lib';
+import {
+ type BaseBushArgumentType,
+ type BushArgumentType,
+ type BushArgumentTypeCaster,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import { Argument, type Flag, type ParsedValuePredicate } from 'discord-akairo';
import { type Message } from 'discord.js';
@@ -12,10 +18,10 @@ export class Arg {
* @param message - Message that called the command.
* @param phrase - Phrase to process.
*/
- public static async cast<T extends ATC>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<ATCR<T>>;
- public static async cast<T extends KBAT>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<BAT[T]>;
- public static async cast(type: AT | ATC, message: Message | BushSlashMessage, phrase: string): Promise<any>;
- public static async cast(type: ATC | AT, message: Message | BushSlashMessage, phrase: string): Promise<any> {
+ public static async cast<T extends ATC>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<ATCR<T>>;
+ public static async cast<T extends KBAT>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<BAT[T]>;
+ public static async cast(type: AT | ATC, message: CommandMessage | SlashMessage, phrase: string): Promise<any>;
+ public static async cast(type: ATC | AT, message: CommandMessage | SlashMessage, phrase: string): Promise<any> {
return Argument.cast(type as any, client.commandHandler.resolver, message as Message, phrase);
}
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index 9f93375..6cdc141 100644
--- a/src/lib/common/util/Moderation.ts
+++ b/src/lib/common/util/Moderation.ts
@@ -1,17 +1,18 @@
-import {
- ActivePunishment,
- ActivePunishmentType,
- Guild,
- ModLog,
- type BushGuild,
- type BushGuildMember,
- type BushGuildMemberResolvable,
- type BushGuildResolvable,
- type BushUserResolvable,
- type ModLogType
-} from '#lib';
+import { ActivePunishment, ActivePunishmentType, Guild as GuildDB, ModLog, type ModLogType } from '#lib';
import assert from 'assert';
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, PermissionFlagsBits, type Snowflake } from 'discord.js';
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ PermissionFlagsBits,
+ type Guild,
+ type GuildMember,
+ type GuildMemberResolvable,
+ type GuildResolvable,
+ type Snowflake,
+ type UserResolvable
+} from 'discord.js';
enum punishMap {
'warned' = 'warn',
@@ -52,8 +53,8 @@ export class Moderation {
* @returns `true` if the moderator can perform the action otherwise a reason why they can't.
*/
public static async permissionCheck(
- moderator: BushGuildMember,
- victim: BushGuildMember,
+ moderator: GuildMember,
+ victim: GuildMember,
type:
| 'mute'
| 'unmute'
@@ -146,7 +147,7 @@ export class Moderation {
getCaseNumber = false
): Promise<{ log: ModLog | null; caseNum: number | null }> {
// If guild does not exist create it so the modlog can reference a guild.
- await Guild.findOrCreate({
+ await GuildDB.findOrCreate({
where: { id: options.guild },
defaults: { id: options.guild }
});
@@ -349,17 +350,17 @@ export interface CreateModLogEntryOptions extends BaseCreateModLogEntryOptions {
/**
* The user that a modlog entry is created for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The moderator that created the modlog entry.
*/
- moderator: BushGuildMemberResolvable;
+ moderator: GuildMemberResolvable;
/**
* The guild that the punishment is created for.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
}
/**
@@ -394,7 +395,7 @@ export interface CreatePunishmentEntryOptions {
/**
* The user that the punishment is created for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The length of time the punishment lasts for.
@@ -404,7 +405,7 @@ export interface CreatePunishmentEntryOptions {
/**
* The guild that the punishment is created for.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
/**
* The id of the modlog that is linked to the punishment entry.
@@ -429,12 +430,12 @@ export interface RemovePunishmentEntryOptions {
/**
* The user that the punishment is destroyed for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The guild that the punishment was in.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
/**
* Extra information for the punishment. The role for role punishments and the channel for blocks.
@@ -454,12 +455,12 @@ export interface PunishDMOptions {
/**
* The guild that the punishment is taking place in.
*/
- guild: BushGuild;
+ guild: Guild;
/**
* The user that is being punished.
*/
- user: BushUserResolvable;
+ user: UserResolvable;
/**
* The punishment that the user has received.
diff --git a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts
index 7a9a3db..def7ad6 100644
--- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts
+++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts
@@ -1,3 +1,3 @@
-import { type BushMessage } from '#lib';
+import { type CommandMessage } from '#lib';
-export type BushArgumentTypeCaster<R = unknown> = (message: BushMessage, phrase: string) => R;
+export type BushArgumentTypeCaster<R = unknown> = (message: CommandMessage, phrase: string) => R;
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index db0ad91..2644231 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -10,28 +10,20 @@ import {
roleWithDuration,
snowflake
} from '#args';
-import type {
- BushBaseGuildEmojiManager,
- BushChannelManager,
- BushClientEvents,
- BushClientUser,
- BushGuildManager,
- BushUserManager,
- BushUserResolvable,
- Config
-} from '#lib';
+import type { BushClientEvents, Config } from '#lib';
import { patch, type PatchedElements } from '@notenoughupdates/events-intercept';
import * as Sentry from '@sentry/node';
import {
AkairoClient,
- ArgumentPromptData,
ContextMenuCommandHandler,
- OtherwiseContentSupplier,
- version as akairoVersion
+ version as akairoVersion,
+ type ArgumentPromptData,
+ type ClientUtil,
+ type OtherwiseContentSupplier
} from 'discord-akairo';
-import { GatewayIntentBits } from 'discord-api-types/v10';
import {
ActivityType,
+ GatewayIntentBits,
MessagePayload,
Options,
Partials,
@@ -45,19 +37,21 @@ import {
type MessageOptions,
type ReplyMessageOptions,
type Snowflake,
+ type UserResolvable,
type WebhookEditMessageOptions
} from 'discord.js';
-import EventEmitter from 'events';
+import type EventEmitter from 'events';
import { google } from 'googleapis';
import path from 'path';
import readline from 'readline';
import type { Options as SequelizeOptions, Sequelize as SequelizeType } from 'sequelize';
import { fileURLToPath } from 'url';
+import { tinyColor } from '../../../arguments/tinyColor.js';
import UpdateCacheTask from '../../../tasks/updateCache.js';
import UpdateStatsTask from '../../../tasks/updateStats.js';
import { HighlightManager } from '../../common/HighlightManager.js';
import { ActivePunishment } from '../../models/instance/ActivePunishment.js';
-import { Guild as GuildModel } from '../../models/instance/Guild.js';
+import { Guild as GuildDB } from '../../models/instance/Guild.js';
import { Highlight } from '../../models/instance/Highlight.js';
import { Level } from '../../models/instance/Level.js';
import { ModLog } from '../../models/instance/ModLog.js';
@@ -71,26 +65,10 @@ import { AllowedMentions } from '../../utils/AllowedMentions.js';
import { BushCache } from '../../utils/BushCache.js';
import { BushConstants } from '../../utils/BushConstants.js';
import { BushLogger } from '../../utils/BushLogger.js';
-import { BushButtonInteraction } from '../discord.js/BushButtonInteraction.js';
-import { BushCategoryChannel } from '../discord.js/BushCategoryChannel.js';
-import { BushChatInputCommandInteraction } from '../discord.js/BushChatInputCommandInteraction.js';
-import { BushDMChannel } from '../discord.js/BushDMChannel.js';
-import { BushGuild } from '../discord.js/BushGuild.js';
-import { BushGuildEmoji } from '../discord.js/BushGuildEmoji.js';
-import { BushGuildMember } from '../discord.js/BushGuildMember.js';
-import { BushMessage } from '../discord.js/BushMessage.js';
-import { BushMessageReaction } from '../discord.js/BushMessageReaction.js';
-import { BushModalSubmitInteraction } from '../discord.js/BushModalSubmitInteraction.js';
-import { BushNewsChannel } from '../discord.js/BushNewsChannel.js';
-import { BushPresence } from '../discord.js/BushPresence.js';
-import { BushRole } from '../discord.js/BushRole.js';
-import { BushSelectMenuInteraction } from '../discord.js/BushSelectMenuInteraction.js';
-import { BushTextChannel } from '../discord.js/BushTextChannel.js';
-import { BushThreadChannel } from '../discord.js/BushThreadChannel.js';
-import { BushThreadMember } from '../discord.js/BushThreadMember.js';
-import { BushUser } from '../discord.js/BushUser.js';
-import { BushVoiceChannel } from '../discord.js/BushVoiceChannel.js';
-import { BushVoiceState } from '../discord.js/BushVoiceState.js';
+import { ExtendedGuild } from '../discord.js/ExtendedGuild.js';
+import { ExtendedGuildMember } from '../discord.js/ExtendedGuildMember.js';
+import { ExtendedMessage } from '../discord.js/ExtendedMessage.js';
+import { ExtendedUser } from '../discord.js/ExtendedUser.js';
import { BushClientUtil } from './BushClientUtil.js';
import { BushCommandHandler } from './BushCommandHandler.js';
import { BushInhibitorHandler } from './BushInhibitorHandler.js';
@@ -98,11 +76,43 @@ import { BushListenerHandler } from './BushListenerHandler.js';
import { BushTaskHandler } from './BushTaskHandler.js';
const { Sequelize } = (await import('sequelize')).default;
-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;
+declare module 'discord.js' {
+ export interface Client extends EventEmitter {
+ /**
+ * The ID of the owner(s).
+ */
+ ownerID: Snowflake | Snowflake[];
+ /**
+ * The ID of the superUser(s).
+ */
+ superUserID: Snowflake | Snowflake[];
+ /**
+ * Utility methods.
+ */
+ util: ClientUtil | BushClientUtil;
+ on<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
+ once<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
+ emit<K extends keyof BushClientEvents>(event: K, ...args: BushClientEvents[K]): boolean;
+ off<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
+ removeAllListeners<K extends keyof BushClientEvents>(event?: K): this;
+ /**
+ * Checks if a user is the owner of this bot.
+ * @param user - User to check.
+ */
+ isOwner(user: UserResolvable): boolean;
+ /**
+ * Checks if a user is a super user of this bot.
+ * @param user - User to check.
+ */
+ isSuperUser(user: UserResolvable): boolean;
+ }
+}
+
+export type ReplyMessageType = string | MessagePayload | ReplyMessageOptions;
+export type EditMessageType = string | MessageEditOptions | MessagePayload;
+export type SlashSendMessageType = string | MessagePayload | InteractionReplyOptions;
+export type SlashEditMessageType = string | MessagePayload | WebhookEditMessageOptions;
+export type SendMessageType = string | MessagePayload | MessageOptions;
const rl = readline.createInterface({
input: process.stdin,
@@ -116,12 +126,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
* The main hub for interacting with the Discord API.
*/
export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Ready> {
- public declare channels: BushChannelManager;
- public declare guilds: BushGuildManager;
- public declare user: If<Ready, BushClientUser>;
- public declare users: BushUserManager;
- public declare util: BushClientUtil;
public declare ownerID: Snowflake[];
+ public declare superUserID: Snowflake[];
+ public declare util: BushClientUtil;
/**
* Whether or not the client is ready.
@@ -272,7 +279,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
prefix: async ({ guild }: Message) => {
if (this.config.isDevelopment) return 'dev ';
if (!guild) return this.config.prefix;
- const prefix = await (guild as BushGuild).getSetting('prefix');
+ const prefix = await guild.getSetting('prefix');
return (prefix ?? this.config.prefix) as string;
},
allowMention: true,
@@ -296,7 +303,6 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
automateCategories: false,
autoRegisterSlashCommands: true,
skipBuiltInPostInhibitors: true,
- useSlashPermissions: false,
aliasReplacement: /-/g
});
this.contextMenuCommandHandler = new ContextMenuCommandHandler(this, {
@@ -342,26 +348,10 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
* Extends discord.js structures before the client is instantiated.
*/
public static extendStructures(): 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('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('ChatInputCommandInteraction', () => BushChatInputCommandInteraction);
- Structures.extend('ButtonInteraction', () => BushButtonInteraction);
- Structures.extend('SelectMenuInteraction', () => BushSelectMenuInteraction);
- Structures.extend('ModalSubmitInteraction', () => BushModalSubmitInteraction);
+ Structures.extend('GuildMember', () => ExtendedGuildMember);
+ Structures.extend('Guild', () => ExtendedGuild);
+ Structures.extend('Message', () => ExtendedMessage);
+ Structures.extend('User', () => ExtendedUser);
}
/**
@@ -407,7 +397,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
abbreviatedNumber,
durationSeconds,
globalUser,
- messageLink
+ messageLink,
+ tinyColor
});
this.sentry = Sentry;
@@ -448,7 +439,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
public async dbPreInit() {
try {
await this.instanceDB.authenticate();
- GuildModel.initModel(this.instanceDB, this);
+ GuildDB.initModel(this.instanceDB, this);
ModLog.initModel(this.instanceDB);
ActivePunishment.initModel(this.instanceDB);
Level.initModel(this.instanceDB);
@@ -527,33 +518,22 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
}
}
- public override isOwner(user: BushUserResolvable): boolean {
+ public override isOwner(user: UserResolvable): boolean {
return this.config.owners.includes(this.users.resolveId(user!)!);
}
- public override isSuperUser(user: BushUserResolvable): boolean {
+ public override isSuperUser(user: UserResolvable): boolean {
const userID = this.users.resolveId(user)!;
return client.cache.shared.superUsers.includes(userID) || this.config.owners.includes(userID);
}
}
export interface BushClient<Ready extends boolean = boolean> extends EventEmitter, PatchedElements, AkairoClient<Ready> {
- get emojis(): BushBaseGuildEmojiManager;
-
on<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
- // on<S extends string | symbol>(event: Exclude<S, keyof BushClientEvents>, listener: (...args: any[]) => Awaitable<void>): this;
-
once<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
- // once<S extends string | symbol>(event: Exclude<S, keyof BushClientEvents>, listener: (...args: any[]) => Awaitable<void>): this;
-
emit<K extends keyof BushClientEvents>(event: K, ...args: BushClientEvents[K]): boolean;
- // emit<S extends string | symbol>(event: Exclude<S, keyof BushClientEvents>, ...args: unknown[]): boolean;
-
off<K extends keyof BushClientEvents>(event: K, listener: (...args: BushClientEvents[K]) => Awaitable<void>): this;
- // off<S extends string | symbol>(event: Exclude<S, keyof BushClientEvents>, listener: (...args: any[]) => Awaitable<void>): this;
-
removeAllListeners<K extends keyof BushClientEvents>(event?: K): this;
- // removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof BushClientEvents>): this;
}
export interface BushStats {
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 9fe70fa..19810bd 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -1,41 +1,43 @@
import {
Arg,
- BaseBushArgumentType,
BushConstants,
+ CommandMessage,
Global,
Shared,
- SharedCache,
+ type BaseBushArgumentType,
type BushClient,
type BushInspectOptions,
- type BushMessage,
- type BushSlashEditMessageType,
- type BushSlashMessage,
- type BushSlashSendMessageType,
- type BushUser,
type CodeBlockLang,
type GlobalCache,
type Pronoun,
- type PronounCode
+ type PronounCode,
+ type SharedCache,
+ type SlashEditMessageType,
+ type SlashMessage,
+ type SlashSendMessageType
} from '#lib';
import { humanizeDuration } from '@notenoughupdates/humanize-duration';
import assert from 'assert';
import { exec } from 'child_process';
import deepLock from 'deep-lock';
import { ClientUtil, Util as AkairoUtil } from 'discord-akairo';
-import { APIEmbed, APIMessage, OAuth2Scopes, Routes } from 'discord-api-types/v10';
import {
Constants as DiscordConstants,
EmbedBuilder,
GuildMember,
Message,
+ OAuth2Scopes,
PermissionFlagsBits,
PermissionsBitField,
- PermissionsString,
+ Routes,
ThreadMember,
User,
Util as DiscordUtil,
+ type APIEmbed,
+ type APIMessage,
type CommandInteraction,
type InteractionReplyOptions,
+ type PermissionsString,
type Snowflake,
type TextChannel,
type UserResolvable
@@ -377,7 +379,7 @@ export class BushClientUtil extends ClientUtil {
*/
public async slashRespond(
interaction: CommandInteraction,
- responseOptions: BushSlashSendMessageType | BushSlashEditMessageType
+ responseOptions: SlashSendMessageType | SlashEditMessageType
): Promise<Message | APIMessage | undefined> {
const newResponseOptions = typeof responseOptions === 'string' ? { content: responseOptions } : responseOptions;
if (interaction.replied || interaction.deferred) {
@@ -696,17 +698,17 @@ export class BushClientUtil extends ClientUtil {
* @param user The user to fetch
* @returns Undefined if the user is not found, otherwise the user.
*/
- public async resolveNonCachedUser(user: UserResolvable | undefined | null): Promise<BushUser | undefined> {
+ public async resolveNonCachedUser(user: UserResolvable | undefined | null): Promise<User | undefined> {
if (user == null) return undefined;
const resolvedUser =
user instanceof User
- ? <BushUser>user
+ ? user
: user instanceof GuildMember
- ? <BushUser>user.user
+ ? user.user
: user instanceof ThreadMember
- ? <BushUser>user.user
+ ? user.user
: user instanceof Message
- ? <BushUser>user.author
+ ? user.author
: undefined;
return resolvedUser ?? (await client.users.fetch(user as Snowflake).catch(() => undefined));
@@ -831,9 +833,10 @@ export class BushClientUtil extends ClientUtil {
* @returns The missing permissions or null if none are missing.
*/
public userGuildPermCheck(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
permissions: typeof PermissionFlagsBits[keyof typeof PermissionFlagsBits][]
): PermissionsString[] | null {
+ if (!message.inGuild()) return null;
const missing = message.member?.permissions.missing(permissions) ?? [];
return missing.length ? missing : null;
@@ -845,7 +848,7 @@ export class BushClientUtil extends ClientUtil {
* @param permissions The permissions to check for.
* @returns The missing permissions or null if none are missing.
*/
- public clientGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]): PermissionsString[] | null {
+ public clientGuildPermCheck(message: CommandMessage | SlashMessage, permissions: bigint[]): PermissionsString[] | null {
const missing = message.guild?.members.me?.permissions.missing(permissions) ?? [];
return missing.length ? missing : null;
@@ -860,7 +863,7 @@ export class BushClientUtil extends ClientUtil {
* @returns The missing permissions or null if none are missing.
*/
public clientSendAndPermCheck(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
permissions: bigint[] = [],
checkChannel = false
): PermissionsString[] | null {
@@ -868,7 +871,7 @@ export class BushClientUtil extends ClientUtil {
const sendPerm = message.channel!.isThread() ? 'SendMessages' : 'SendMessagesInThreads';
if (!message.inGuild()) return null;
- if (!message.guild.members.me!.permissionsIn(message.channel.id).has(sendPerm)) missing.push(sendPerm);
+ if (!message.guild.members.me!.permissionsIn(message.channel!.id).has(sendPerm)) missing.push(sendPerm);
missing.push(
...(checkChannel
@@ -884,7 +887,7 @@ export class BushClientUtil extends ClientUtil {
* @param message The message to get the prefix from.
* @returns The prefix.
*/
- public prefix(message: BushMessage | BushSlashMessage): string {
+ public prefix(message: CommandMessage | SlashMessage): string {
return message.util.isSlash
? '/'
: client.config.isDevelopment
@@ -970,7 +973,7 @@ export class BushClientUtil extends ClientUtil {
*/
public async castDurationContent(
arg: string | ParsedDuration | null,
- message: BushMessage | BushSlashMessage
+ message: CommandMessage | SlashMessage
): Promise<ParsedDurationRes> {
const res = typeof arg === 'string' ? await util.arg.cast('contentWithDuration', message, arg) : arg;
@@ -987,7 +990,7 @@ export class BushClientUtil extends ClientUtil {
public async cast<T extends keyof BaseBushArgumentType>(
type: T,
arg: BaseBushArgumentType[T] | string,
- message: BushMessage | BushSlashMessage
+ message: CommandMessage | SlashMessage
) {
return typeof arg === 'string' ? await util.arg.cast(type, message, arg) : arg;
}
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index c727e98..5fb4e06 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -1,33 +1,17 @@
import { type DiscordEmojiInfo, type RoleWithDuration } from '#args';
import {
type BushArgumentTypeCaster,
- type BushBaseGuildVoiceChannel,
- type BushCategoryChannel,
type BushClient,
type BushCommandHandler,
- type BushEmoji,
- type BushGuild,
- type BushGuildBasedChannel,
- type BushGuildChannel,
- type BushGuildEmoji,
- type BushGuildMember,
type BushInhibitor,
type BushListener,
- type BushMessage,
- type BushNewsChannel,
- type BushRole,
- type BushSlashMessage,
- type BushStageChannel,
type BushTask,
- type BushTextChannel,
- type BushThreadChannel,
- type BushUser,
- type BushVoiceChannel,
type ParsedDuration
} from '#lib';
import {
ArgumentMatch,
Command,
+ CommandUtil,
type AkairoApplicationCommandAutocompleteOption,
type AkairoApplicationCommandChannelOptionData,
type AkairoApplicationCommandChoicesData,
@@ -47,51 +31,17 @@ import {
type SlashResolveType
} from 'discord-akairo';
import {
+ Message,
+ User,
type ApplicationCommandOptionChoiceData,
- type Collection,
- type Invite,
type PermissionResolvable,
type PermissionsString,
type Snowflake
} from 'discord.js';
import _ from 'lodash';
+import { SlashMessage } from './SlashMessage.js';
export interface OverriddenBaseArgumentType extends BaseArgumentType {
- user: BushUser | null;
- users: Collection<string, BushUser> | null;
- member: BushGuildMember | null;
- members: Collection<string, BushGuildMember> | null;
- relevant: BushUser | BushGuildMember | null;
- relevants: Collection<string, BushUser> | Collection<string, BushGuildMember> | null;
- channel: BushGuildBasedChannel | BushBaseGuildVoiceChannel | null;
- channels: Collection<string, BushGuildBasedChannel | BushBaseGuildVoiceChannel> | null;
- textChannel: BushTextChannel | null;
- textChannels: Collection<string, BushTextChannel> | null;
- voiceChannel: BushVoiceChannel | null;
- voiceChannels: Collection<string, BushVoiceChannel> | null;
- categoryChannel: BushCategoryChannel | null;
- categoryChannels: Collection<string, BushCategoryChannel> | null;
- newsChannel: BushNewsChannel | null;
- newsChannels: Collection<string, BushNewsChannel> | null;
- stageChannel: BushStageChannel | null;
- stageChannels: Collection<string, BushStageChannel> | null;
- threadChannel: BushThreadChannel | null;
- threadChannels: Collection<string, BushThreadChannel> | null;
- role: BushRole | null;
- roles: Collection<string, BushRole> | null;
- emoji: BushEmoji | null;
- emojis: Collection<string, BushEmoji> | null;
- guild: BushGuild | null;
- guilds: Collection<string, BushGuild> | null;
- message: BushMessage | null;
- guildMessage: BushMessage | null;
- relevantMessage: BushMessage | null;
- invite: Invite | null;
- userMention: BushUser | null;
- memberMention: BushGuildMember | null;
- channelMention: BushThreadChannel | BushGuildChannel | null;
- roleMention: BushRole | null;
- emojiMention: BushGuildEmoji | null;
commandAlias: BushCommand | null;
command: BushCommand | null;
inhibitor: BushInhibitor | null;
@@ -108,9 +58,10 @@ export interface BaseBushArgumentType extends OverriddenBaseArgumentType {
discordEmoji: DiscordEmojiInfo | null;
roleWithDuration: RoleWithDuration | null;
abbreviatedNumber: number | null;
- globalUser: BushUser | null;
- messageLink: BushMessage | null;
+ globalUser: User | null;
+ messageLink: Message | null;
durationSeconds: number | null;
+ tinyColor: string | null;
}
export type BushArgumentType = keyof BaseBushArgumentType | RegExp;
@@ -247,6 +198,7 @@ export interface BushArgumentOptions extends BaseBushArgumentOptions {
*/
type?: BushArgumentType | (keyof BaseBushArgumentType)[] | BushArgumentTypeCaster;
}
+
export interface CustomBushArgumentOptions extends BaseBushArgumentOptions {
/**
* An array of strings can be used to restrict input to only those strings, case insensitive.
@@ -259,7 +211,7 @@ export interface CustomBushArgumentOptions extends BaseBushArgumentOptions {
customType?: (string | string[])[] | RegExp | string | null;
}
-export type BushMissingPermissionSupplier = (message: BushMessage | BushSlashMessage) => Promise<any> | any;
+export type BushMissingPermissionSupplier = (message: CommandMessage | SlashMessage) => Promise<any> | any;
interface ExtendedCommandOptions {
/**
@@ -407,9 +359,7 @@ export interface ArgsInfo {
export class BushCommand extends Command {
public declare client: BushClient;
-
public declare handler: BushCommandHandler;
-
public declare description: string;
/**
@@ -595,13 +545,13 @@ export interface BushCommand extends Command {
* @param message - Message that triggered the command.
* @param args - Evaluated arguments.
*/
- exec(message: BushMessage, args: any): any;
+ exec(message: CommandMessage, args: any): any;
/**
* Executes the command.
* @param message - Message that triggered the command.
* @param args - Evaluated arguments.
*/
- exec(message: BushMessage | BushSlashMessage, args: any): any;
+ exec(message: CommandMessage | SlashMessage, args: any): any;
}
type SlashOptionKeys =
@@ -615,7 +565,22 @@ type SlashOptionKeys =
interface PseudoArguments extends BaseBushArgumentType {
boolean: boolean;
+ flag: boolean;
+ regex: { match: RegExpMatchArray; matches: RegExpExecArray[] };
}
export type ArgType<T extends keyof PseudoArguments> = NonNullable<PseudoArguments[T]>;
export type OptArgType<T extends keyof PseudoArguments> = PseudoArguments[T];
+
+/**
+ * `util` is always defined for messages after `'all'` inhibitors
+ */
+export type CommandMessage = Message & {
+ /**
+ * Extra properties applied to the Discord.js message object.
+ * Utilities for command responding.
+ * Available on all messages after 'all' inhibitors and built-in inhibitors (bot, client).
+ * Not all properties of the util are available, depending on the input.
+ * */
+ util: CommandUtil<Message>;
+};
diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
index 2c1903f..f095356 100644
--- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
@@ -1,35 +1,30 @@
-import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { type BushClient, type BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { CommandHandler, type Category, type CommandHandlerEvents, type CommandHandlerOptions } from 'discord-akairo';
-import { type Collection, type PermissionsString } from 'discord.js';
+import { type Collection, type Message, type PermissionsString } from 'discord.js';
export type BushCommandHandlerOptions = CommandHandlerOptions;
export interface BushCommandHandlerEvents extends CommandHandlerEvents {
- commandBlocked: [message: BushMessage, command: BushCommand, reason: string];
- commandBreakout: [message: BushMessage, command: BushCommand, breakMessage: BushMessage];
- commandCancelled: [message: BushMessage, command: BushCommand, retryMessage?: BushMessage];
- commandFinished: [message: BushMessage, command: BushCommand, args: any, returnValue: any];
- commandInvalid: [message: BushMessage, command: BushCommand];
- commandLocked: [message: BushMessage, command: BushCommand];
- commandStarted: [message: BushMessage, command: BushCommand, args: any];
- cooldown: [message: BushMessage | BushSlashMessage, command: BushCommand, remaining: number];
- error: [error: Error, message: BushMessage, command?: BushCommand];
- inPrompt: [message: BushMessage];
+ commandBlocked: [message: CommandMessage, command: BushCommand, reason: string];
+ commandBreakout: [message: CommandMessage, command: BushCommand, /* no util */ breakMessage: Message];
+ commandCancelled: [message: CommandMessage, command: BushCommand, /* no util */ retryMessage?: Message];
+ commandFinished: [message: CommandMessage, command: BushCommand, args: any, returnValue: any];
+ commandInvalid: [message: CommandMessage, command: BushCommand];
+ commandLocked: [message: CommandMessage, command: BushCommand];
+ commandStarted: [message: CommandMessage, command: BushCommand, args: any];
+ cooldown: [message: CommandMessage | SlashMessage, command: BushCommand, remaining: number];
+ error: [error: Error, message: /* no util */ Message, command?: BushCommand];
+ inPrompt: [message: /* no util */ Message];
load: [command: BushCommand, isReload: boolean];
- messageBlocked: [message: BushMessage | BushSlashMessage, reason: string];
- messageInvalid: [message: BushMessage];
- missingPermissions: [message: BushMessage, command: BushCommand, type: 'client' | 'user', missing: PermissionsString[]];
+ messageBlocked: [message: /* no util */ Message | CommandMessage | SlashMessage, reason: string];
+ messageInvalid: [message: CommandMessage];
+ missingPermissions: [message: CommandMessage, command: BushCommand, type: 'client' | 'user', missing: PermissionsString[]];
remove: [command: BushCommand];
- slashBlocked: [message: BushSlashMessage, command: BushCommand, reason: string];
- slashError: [error: Error, message: BushSlashMessage, command: BushCommand];
- slashFinished: [message: BushSlashMessage, command: BushCommand, args: any, returnValue: any];
- slashMissingPermissions: [
- message: BushSlashMessage,
- command: BushCommand,
- type: 'client' | 'user',
- missing: PermissionsString[]
- ];
- slashStarted: [message: BushSlashMessage, command: BushCommand, args: any];
+ slashBlocked: [message: SlashMessage, command: BushCommand, reason: string];
+ slashError: [error: Error, message: SlashMessage, command: BushCommand];
+ slashFinished: [message: SlashMessage, command: BushCommand, args: any, returnValue: any];
+ slashMissingPermissions: [message: SlashMessage, command: BushCommand, type: 'client' | 'user', missing: PermissionsString[]];
+ slashStarted: [message: SlashMessage, command: BushCommand, args: any];
}
export class BushCommandHandler extends CommandHandler {
diff --git a/src/lib/extensions/discord-akairo/BushCommandUtil.ts b/src/lib/extensions/discord-akairo/BushCommandUtil.ts
deleted file mode 100644
index 7a06b35..0000000
--- a/src/lib/extensions/discord-akairo/BushCommandUtil.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { type BushCommand, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '#lib';
-import { CommandUtil, type ParsedComponentData } from 'discord-akairo';
-import { type Collection, type Snowflake } from 'discord.js';
-
-export interface BushParsedComponentData extends ParsedComponentData {
- command?: BushCommand;
-}
-
-export class BushCommandUtil<BushMessageType extends BushMessage | BushSlashMessage> extends CommandUtil<BushMessageType> {
- public declare parsed: BushParsedComponentData | null;
- public declare handler: BushCommandHandler;
- public declare message: BushMessageType;
- public declare messages: Collection<Snowflake, BushMessage> | null;
-
- public constructor(handler: BushCommandHandler, message: BushMessageType) {
- super(handler, message);
- }
-}
-
-export interface BushCommandUtil<BushMessageType extends BushMessage | BushSlashMessage> extends CommandUtil<BushMessageType> {
- isSlashMessage(message: BushMessage | BushSlashMessage): message is BushSlashMessage;
-}
diff --git a/src/lib/extensions/discord-akairo/BushInhibitor.ts b/src/lib/extensions/discord-akairo/BushInhibitor.ts
index 7f13594..12b2baf 100644
--- a/src/lib/extensions/discord-akairo/BushInhibitor.ts
+++ b/src/lib/extensions/discord-akairo/BushInhibitor.ts
@@ -1,4 +1,4 @@
-import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
+import { type BushClient, type BushCommand, type CommandMessage, type SlashMessage } from '#lib';
import { Inhibitor } from 'discord-akairo';
export class BushInhibitor extends Inhibitor {
@@ -10,9 +10,12 @@ export interface BushInhibitor {
* Checks if message should be blocked.
* A return value of true will block the message.
* If returning a Promise, a resolved value of true will block the message.
+ *
+ * **Note:** `all` type inhibitors do not have `message.util` defined.
+ *
* @param message - Message being handled.
* @param command - Command to check.
*/
- exec(message: BushMessage, command: BushCommand): any;
- exec(message: BushMessage | BushSlashMessage, command: BushCommand): any;
+ exec(message: CommandMessage, command: BushCommand): any;
+ exec(message: CommandMessage | SlashMessage, command: BushCommand): any;
}
diff --git a/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts
index a607bf7..5e4fb6c 100644
--- a/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushInhibitorHandler.ts
@@ -1,6 +1,3 @@
-import { type BushClient } from '#lib';
import { InhibitorHandler } from 'discord-akairo';
-export class BushInhibitorHandler extends InhibitorHandler {
- public declare client: BushClient;
-}
+export class BushInhibitorHandler extends InhibitorHandler {}
diff --git a/src/lib/extensions/discord-akairo/BushListener.ts b/src/lib/extensions/discord-akairo/BushListener.ts
index f6247ec..3efe527 100644
--- a/src/lib/extensions/discord-akairo/BushListener.ts
+++ b/src/lib/extensions/discord-akairo/BushListener.ts
@@ -1,10 +1,7 @@
-import { type BushClient } from '#lib';
import { Listener } from 'discord-akairo';
import type EventEmitter from 'events';
export class BushListener extends Listener {
- public declare client: BushClient;
-
public constructor(
id: string,
options: {
diff --git a/src/lib/extensions/discord-akairo/BushListenerHandler.ts b/src/lib/extensions/discord-akairo/BushListenerHandler.ts
index 517fb55..9c3e4af 100644
--- a/src/lib/extensions/discord-akairo/BushListenerHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushListenerHandler.ts
@@ -1,6 +1,3 @@
-import { type BushClient } from '#lib';
import { ListenerHandler } from 'discord-akairo';
-export class BushListenerHandler extends ListenerHandler {
- public declare client: BushClient;
-}
+export class BushListenerHandler extends ListenerHandler {}
diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts
deleted file mode 100644
index 0860964..0000000
--- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import {
- BushCommandHandler,
- BushGuildTextBasedChannel,
- type BushClient,
- type BushCommandUtil,
- type BushGuild,
- type BushGuildMember,
- type BushTextBasedChannel,
- type BushUser
-} from '#lib';
-import { AkairoMessage } from 'discord-akairo';
-import { type ChatInputCommandInteraction } from 'discord.js';
-
-export class BushSlashMessage extends AkairoMessage {
- public declare client: BushClient;
- public declare util: BushCommandUtil<BushSlashMessage> & { handler: BushCommandHandler };
- public declare author: BushUser;
- public declare member: BushGuildMember | null;
- public declare interaction: ChatInputCommandInteraction;
- public constructor(client: BushClient, interaction: ChatInputCommandInteraction) {
- super(client, interaction);
- }
-}
-
-export interface BushSlashMessage extends AkairoMessage {
- get channel(): BushTextBasedChannel | null;
- get guild(): BushGuild | null;
- inGuild(): this is BushSlashMessageInGuild & this;
-}
-
-interface BushSlashMessageInGuild {
- guild: BushGuild;
- channel: BushGuildTextBasedChannel;
-}
diff --git a/src/lib/extensions/discord-akairo/BushTask.ts b/src/lib/extensions/discord-akairo/BushTask.ts
index b4359ce..9f5c0cd 100644
--- a/src/lib/extensions/discord-akairo/BushTask.ts
+++ b/src/lib/extensions/discord-akairo/BushTask.ts
@@ -1,10 +1,3 @@
-import { type BushClient } from '#lib';
-import { Task, type TaskOptions } from 'discord-akairo';
+import { Task } from 'discord-akairo';
-export class BushTask extends Task {
- public declare client: BushClient;
-
- public constructor(id: string, options: TaskOptions) {
- super(id, options);
- }
-}
+export class BushTask extends Task {}
diff --git a/src/lib/extensions/discord-akairo/BushTaskHandler.ts b/src/lib/extensions/discord-akairo/BushTaskHandler.ts
index ed6b91d..f667ead 100644
--- a/src/lib/extensions/discord-akairo/BushTaskHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushTaskHandler.ts
@@ -1,12 +1,5 @@
-import { type BushClient } from '#lib';
import { TaskHandler, type AkairoHandlerOptions } from 'discord-akairo';
export type BushTaskHandlerOptions = AkairoHandlerOptions;
-export class BushTaskHandler extends TaskHandler {
- public declare client: BushClient;
-
- public constructor(client: BushClient, options: BushTaskHandlerOptions) {
- super(client, options);
- }
-}
+export class BushTaskHandler extends TaskHandler {}
diff --git a/src/lib/extensions/discord-akairo/SlashMessage.ts b/src/lib/extensions/discord-akairo/SlashMessage.ts
new file mode 100644
index 0000000..0a6669b
--- /dev/null
+++ b/src/lib/extensions/discord-akairo/SlashMessage.ts
@@ -0,0 +1,3 @@
+import { AkairoMessage } from 'discord-akairo';
+
+export class SlashMessage extends AkairoMessage {}
diff --git a/src/lib/extensions/discord.js/BushActivity.ts b/src/lib/extensions/discord.js/BushActivity.ts
deleted file mode 100644
index 3f19232..0000000
--- a/src/lib/extensions/discord.js/BushActivity.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { BushEmoji, BushPresence } from '#lib';
-import { Activity } from 'discord.js';
-import type { RawActivityData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents an activity that is part of a user's presence.
- */
-export class BushActivity extends Activity {
- public declare emoji: BushEmoji | null;
-
- public constructor(presence: BushPresence, data?: RawActivityData) {
- super(presence, data);
- }
-}
diff --git a/src/lib/extensions/discord.js/BushApplicationCommand.ts b/src/lib/extensions/discord.js/BushApplicationCommand.ts
deleted file mode 100644
index 8298830..0000000
--- a/src/lib/extensions/discord.js/BushApplicationCommand.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/* eslint-disable @typescript-eslint/ban-types */
-import type { BushClient, BushGuild } from '#lib';
-import { ApplicationCommand, type Snowflake } from 'discord.js';
-import type { RawApplicationCommandData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents an application command.
- */
-export class BushApplicationCommand<PermissionsFetchType = {}> extends ApplicationCommand<PermissionsFetchType> {
- public declare readonly client: BushClient;
- public declare guild: BushGuild | null;
-
- public constructor(client: BushClient, data: RawApplicationCommandData, 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
deleted file mode 100644
index dc27dbf..0000000
--- a/src/lib/extensions/discord.js/BushApplicationCommandManager.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import type {
- BushApplicationCommand,
- BushApplicationCommandPermissionsManager,
- BushApplicationCommandResolvable,
- BushClient,
- BushGuildResolvable,
- StripPrivate
-} from '#lib';
-import type { APIApplicationCommand } from 'discord-api-types/v10';
-import {
- ApplicationCommandManager,
- CachedManager,
- type ApplicationCommandData,
- type Collection,
- type FetchApplicationCommandOptions,
- type Snowflake
-} from 'discord.js';
-
-/**
- * Manages API methods for application commands and stores their cache.
- */
-export declare class BushApplicationCommandManager<
- ApplicationCommandScope = BushApplicationCommand<{ guild: BushGuildResolvable }>,
- PermissionsOptionsExtras = { guild: BushGuildResolvable },
- PermissionsGuildType = null
- >
- extends CachedManager<Snowflake, ApplicationCommandScope, BushApplicationCommandResolvable>
- implements StripPrivate<ApplicationCommandManager<ApplicationCommandScope, PermissionsOptionsExtras, PermissionsGuildType>>
-{
- public constructor(client: BushClient, iterable?: Iterable<unknown>);
-
- /**
- * The manager for permissions of arbitrary commands on arbitrary guilds
- */
- public permissions: BushApplicationCommandPermissionsManager<
- { command?: BushApplicationCommandResolvable } & PermissionsOptionsExtras,
- { command: BushApplicationCommandResolvable } & PermissionsOptionsExtras,
- PermissionsOptionsExtras,
- PermissionsGuildType,
- null
- >;
-
- /**
- * The APIRouter path to the commands
- * @param id The application command's id
- * @param guildId The guild's id to use in the path,
- * ignored when using a {@link GuildApplicationCommandManager}
- */
- private commandPath({ id, guildId }: { id?: Snowflake; guildId?: Snowflake }): unknown;
-
- /**
- * Creates an application command.
- * @param command The command
- * @param guildId The guild's id to create this command in, ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Create a new command
- * client.application.commands.create({
- * name: 'test',
- * description: 'A test command',
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- public create(command: BushApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope>;
-
- /**
- * Deletes an application command.
- * @param command The command to delete
- * @param guildId The guild's id where the command is registered,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Delete a command
- * guild.commands.delete('123456789012345678')
- * .then(console.log)
- * .catch(console.error);
- */
- public delete(command: BushApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope | null>;
-
- /**
- * Edits an application command.
- * @param command The command to edit
- * @param data The data to update the command with
- * @param guildId The guild's id where the command registered,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Edit an existing command
- * client.application.commands.edit('123456789012345678', {
- * description: 'New description',
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- public edit(command: BushApplicationCommandResolvable, data: ApplicationCommandData): Promise<ApplicationCommandScope>;
- public edit(
- command: BushApplicationCommandResolvable,
- data: ApplicationCommandData,
- guildId: Snowflake
- ): Promise<BushApplicationCommand>;
-
- /**
- * Obtains one or multiple application commands from Discord, or the cache if it's already available.
- * @param id The application command's id
- * @param options Additional options for this fetch
- * @example
- * // Fetch a single command
- * client.application.commands.fetch('123456789012345678')
- * .then(command => console.log(`Fetched command ${command.name}`))
- * .catch(console.error);
- * @example
- * // Fetch all commands
- * guild.commands.fetch()
- * .then(commands => console.log(`Fetched ${commands.size} commands`))
- * .catch(console.error);
- */
- public fetch(id: Snowflake, options: FetchApplicationCommandOptions & { guildId: Snowflake }): Promise<BushApplicationCommand>;
- public fetch(options: FetchApplicationCommandOptions): Promise<Collection<string, ApplicationCommandScope>>;
- public fetch(id: Snowflake, options?: FetchApplicationCommandOptions): Promise<ApplicationCommandScope>;
- public fetch(id?: Snowflake, options?: FetchApplicationCommandOptions): Promise<Collection<Snowflake, ApplicationCommandScope>>;
-
- /**
- * Sets all the commands for this application or guild.
- * @param commands The commands
- * @param guildId The guild's id to create the commands in,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Set all commands to just this one
- * client.application.commands.set([
- * {
- * name: 'test',
- * description: 'A test command',
- * },
- * ])
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Remove all commands
- * guild.commands.set([])
- * .then(console.log)
- * .catch(console.error);
- */
- public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
- public set(commands: ApplicationCommandData[], guildId: Snowflake): Promise<Collection<Snowflake, BushApplicationCommand>>;
-
- /**
- * Transforms an {@link ApplicationCommandData} object into something that can be used with the API.
- * @param command The command to transform
- */
- private static transformCommand(
- command: ApplicationCommandData
- ): Omit<APIApplicationCommand, 'id' | 'application_id' | 'guild_id'>;
-}
diff --git a/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts b/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts
deleted file mode 100644
index 401f3e2..0000000
--- a/src/lib/extensions/discord.js/BushApplicationCommandPermissionsManager.ts
+++ /dev/null
@@ -1,184 +0,0 @@
-import type { BushClient, BushRoleResolvable, BushUserResolvable } from '#lib';
-import type { APIApplicationCommandPermission } from 'discord-api-types/v10';
-import {
- ApplicationCommandPermissionType,
- BaseManager,
- type ApplicationCommand,
- type ApplicationCommandManager,
- type ApplicationCommandPermissionData,
- type ApplicationCommandPermissions,
- type Collection,
- type GuildApplicationCommandManager,
- type GuildApplicationCommandPermissionData,
- type Snowflake
-} from 'discord.js';
-
-/**
- * Manages API methods for permissions of Application Commands.
- */
-export declare class BushApplicationCommandPermissionsManager<
- BaseOptions,
- FetchSingleOptions,
- FullPermissionsOptions,
- GuildType,
- CommandIdType
-> extends BaseManager {
- public constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand);
-
- /**
- * The manager or command that this manager belongs to
- */
- private manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand;
-
- /**
- * The client that instantiated this Manager
- */
- public client: BushClient;
-
- /**
- * The id of the command this manager acts on
- */
- public commandId: CommandIdType;
-
- /**
- * The guild that this manager acts on
- */
- public guild: GuildType;
-
- /**
- * The id of the guild that this manager acts on
- */
- public guildId: Snowflake | null;
-
- /**
- * Add permissions to a command.
- * @param options Options used to add permissions
- * @example
- * // Block a role from the command permissions
- * guild.commands.permissions.add({ command: '123456789012345678', permissions: [
- * {
- * id: '876543211234567890',
- * type: 'ROLE',
- * permission: false
- * },
- * ]})
- * .then(console.log)
- * .catch(console.error);
- */
- public add(
- options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }
- ): Promise<ApplicationCommandPermissions[]>;
-
- /**
- * Check whether a permission exists for a user or role
- * @param options Options used to check permissions
- * @example
- * // Check whether a user has permission to use a command
- * guild.commands.permissions.has({ command: '123456789012345678', permissionId: '876543210123456789' })
- * .then(console.log)
- * .catch(console.error);
- */
- public has(options: FetchSingleOptions & { permissionId: BushUserResolvable | BushRoleResolvable }): Promise<boolean>;
-
- /**
- * Fetches the permissions for one or multiple commands.
- * @param options Options used to fetch permissions
- * @example
- * // Fetch permissions for one command
- * guild.commands.permissions.fetch({ command: '123456789012345678' })
- * .then(perms => console.log(`Fetched permissions for ${perms.length} users`))
- * .catch(console.error);
- * @example
- * // Fetch permissions for all commands in a guild
- * client.application.commands.permissions.fetch({ guild: '123456789012345678' })
- * .then(perms => console.log(`Fetched permissions for ${perms.size} commands`))
- * .catch(console.error);
- */
- public fetch(options: FetchSingleOptions): Promise<ApplicationCommandPermissions[]>;
- public fetch(options: BaseOptions): Promise<Collection<Snowflake, ApplicationCommandPermissions[]>>;
-
- /**
- * Remove permissions from a command.
- * @param options Options used to remove permissions
- * @example
- * // Remove a user permission from this command
- * guild.commands.permissions.remove({ command: '123456789012345678', users: '876543210123456789' })
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Remove multiple roles from this command
- * guild.commands.permissions.remove({
- * command: '123456789012345678', roles: ['876543210123456789', '765432101234567890']
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- public remove(
- options:
- | (FetchSingleOptions & {
- users: BushUserResolvable | BushUserResolvable[];
- roles?: BushRoleResolvable | BushRoleResolvable[];
- })
- | (FetchSingleOptions & {
- users?: BushUserResolvable | BushUserResolvable[];
- roles: BushRoleResolvable | BushRoleResolvable[];
- })
- ): Promise<ApplicationCommandPermissions[]>;
-
- /**
- * Sets the permissions for one or more commands.
- * @param options Options used to set permissions
- * @example
- * // Set the permissions for one command
- * client.application.commands.permissions.set({ guild: '892455839386304532', command: '123456789012345678',
- * permissions: [
- * {
- * id: '876543210987654321',
- * type: 'USER',
- * permission: false,
- * },
- * ]})
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Set the permissions for all commands
- * guild.commands.permissions.set({ fullPermissions: [
- * {
- * id: '123456789012345678',
- * permissions: [{
- * id: '876543210987654321',
- * type: 'USER',
- * permission: false,
- * }],
- * },
- * ]})
- * .then(console.log)
- * .catch(console.error);
- */
- public set(
- options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] }
- ): Promise<ApplicationCommandPermissions[]>;
- public set(
- options: FullPermissionsOptions & {
- fullPermissions: GuildApplicationCommandPermissionData[];
- }
- ): Promise<Collection<Snowflake, ApplicationCommandPermissions[]>>;
-
- /**
- * The APIRouter path to the commands
- * @param guildId The guild's id to use in the path,
- * @param commandId The application command's id
- */
- private permissionsPath(guildId: Snowflake, commandId?: Snowflake): unknown;
-
- /**
- * Transforms an {@link ApplicationCommandPermissionData} object into something that can be used with the API.
- * @param permissions The permissions to transform
- * @param received Whether these permissions have been received from Discord
- */
- private static transformPermissions(
- permissions: ApplicationCommandPermissionData,
- received: true
- ): Omit<APIApplicationCommandPermission, 'type'> & { type: keyof ApplicationCommandPermissionType };
- private static transformPermissions(permissions: ApplicationCommandPermissionData): APIApplicationCommandPermission;
-}
diff --git a/src/lib/extensions/discord.js/BushBaseGuildEmojiManager.ts b/src/lib/extensions/discord.js/BushBaseGuildEmojiManager.ts
deleted file mode 100644
index 66abbc2..0000000
--- a/src/lib/extensions/discord.js/BushBaseGuildEmojiManager.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { BushClient, BushEmojiIdentifierResolvable, BushEmojiResolvable, BushGuildEmoji } from '#lib';
-import { BaseGuildEmojiManager, CachedManager, type Snowflake } from 'discord.js';
-import { type RawGuildEmojiData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Holds methods to resolve GuildEmojis and stores their cache.
- */
-export declare class BushBaseGuildEmojiManager
- extends CachedManager<Snowflake, BushGuildEmoji, BushEmojiResolvable>
- implements BaseGuildEmojiManager
-{
- public constructor(client: BushClient, iterable?: Iterable<RawGuildEmojiData>);
-
- /**
- * Resolves an EmojiResolvable to an emoji identifier.
- * @param emoji The emoji resolvable to resolve
- */
- public resolveIdentifier(emoji: BushEmojiIdentifierResolvable): string | null;
-}
diff --git a/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts b/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts
deleted file mode 100644
index 5cc74c4..0000000
--- a/src/lib/extensions/discord.js/BushBaseGuildTextChannel.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import type { BushCategoryChannel, BushClient, BushGuild, BushGuildMember, BushMessageManager, BushThreadManager } from '#lib';
-import {
- BaseGuildTextChannel,
- type AllowedThreadTypeForNewsChannel,
- type AllowedThreadTypeForTextChannel,
- type Collection,
- type Snowflake
-} from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a text-based guild channel on Discord.
- */
-export class BushBaseGuildTextChannel extends BaseGuildTextChannel {
- public declare messages: BushMessageManager;
- public declare threads: BushThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData, client?: BushClient, immediatePatch?: boolean) {
- super(guild, data, client, immediatePatch);
- }
-}
-
-export interface BushBaseGuildTextChannel extends BaseGuildTextChannel {
- get members(): Collection<Snowflake, BushGuildMember>;
- get parent(): BushCategoryChannel | null;
-}
diff --git a/src/lib/extensions/discord.js/BushBaseGuildVoiceChannel.ts b/src/lib/extensions/discord.js/BushBaseGuildVoiceChannel.ts
deleted file mode 100644
index ba41cfe..0000000
--- a/src/lib/extensions/discord.js/BushBaseGuildVoiceChannel.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { BaseGuildVoiceChannel, Collection, Snowflake } from 'discord.js';
-import { BushCategoryChannel } from './BushCategoryChannel.js';
-import { BushGuild } from './BushGuild.js';
-import { BushGuildMember } from './BushGuildMember.js';
-
-/**
- * Represents a voice-based guild channel on Discord.
- */
-export declare class BushBaseGuildVoiceChannel extends BaseGuildVoiceChannel {
- public get members(): Collection<Snowflake, BushGuildMember>;
- public guild: BushGuild;
- public get parent(): BushCategoryChannel | null;
-}
diff --git a/src/lib/extensions/discord.js/BushButtonInteraction.ts b/src/lib/extensions/discord.js/BushButtonInteraction.ts
deleted file mode 100644
index 368d19d..0000000
--- a/src/lib/extensions/discord.js/BushButtonInteraction.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember, BushGuildTextBasedChannel, BushTextBasedChannel, BushUser } from '#lib';
-import type { APIInteractionGuildMember } from 'discord-api-types/v10';
-import { ButtonInteraction, type CacheType, type CacheTypeReducer } from 'discord.js';
-import type { RawMessageButtonInteractionData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a button interaction.
- */
-export class BushButtonInteraction<Cached extends CacheType = CacheType> extends ButtonInteraction<Cached> {
- public declare member: CacheTypeReducer<Cached, BushGuildMember, APIInteractionGuildMember>;
- public declare user: BushUser;
-
- public constructor(client: BushClient, data: RawMessageButtonInteractionData) {
- super(client, data);
- }
-}
-
-export interface BushButtonInteraction<Cached extends CacheType = CacheType> extends ButtonInteraction<Cached> {
- get channel(): CacheTypeReducer<
- Cached,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushTextBasedChannel | null
- >;
- get guild(): CacheTypeReducer<Cached, BushGuild, null>;
- inGuild(): this is BushButtonInteraction<'raw' | 'cached'>;
- inCachedGuild(): this is BushButtonInteraction<'cached'>;
- inRawGuild(): this is BushButtonInteraction<'raw'>;
-}
diff --git a/src/lib/extensions/discord.js/BushCategoryChannel.ts b/src/lib/extensions/discord.js/BushCategoryChannel.ts
deleted file mode 100644
index a2e1e1c..0000000
--- a/src/lib/extensions/discord.js/BushCategoryChannel.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import {
- BushDMChannel,
- BushGuildBasedChannel,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushVoiceBasedChannel,
- BushVoiceChannel,
- type BushCategoryChannelChildManager,
- type BushClient,
- type BushGuild
-} from '#lib';
-import { CategoryChannel } from 'discord.js';
-import { type RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a guild category channel on Discord.
- */
-export class BushCategoryChannel extends CategoryChannel {
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData, client?: BushClient, immediatePatch?: boolean) {
- super(guild, data, client, immediatePatch);
- }
-}
-
-export interface BushCategoryChannel extends CategoryChannel {
- get children(): BushCategoryChannelChildManager;
- isText(): this is BushTextChannel;
- isDM(): this is BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushGuildBasedChannel & BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushCategoryChannelChildManager.ts b/src/lib/extensions/discord.js/BushCategoryChannelChildManager.ts
deleted file mode 100644
index 2b0d56b..0000000
--- a/src/lib/extensions/discord.js/BushCategoryChannelChildManager.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import type {
- BushCategoryChannel,
- BushGuild,
- BushGuildChannelResolvable,
- BushMappedChannelCategoryTypes,
- BushNonCategoryGuildBasedChannel,
- BushTextChannel
-} from '#lib';
-import type {
- CategoryChannelChildManager,
- CategoryChannelType,
- CategoryCreateChannelOptions,
- DataManager,
- Snowflake
-} from 'discord.js';
-
-export declare class BushCategoryChannelChildManager
- extends DataManager<Snowflake, BushNonCategoryGuildBasedChannel, BushGuildChannelResolvable>
- implements CategoryChannelChildManager
-{
- private constructor(channel: BushCategoryChannel);
-
- /**
- * The category channel this manager belongs to
- */
- public channel: BushCategoryChannel;
-
- /**
- * The guild this manager belongs to
- */
- public readonly guild: BushGuild;
-
- /**
- * Creates a new channel within this category.
- * <info>You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel.</info>
- * @param name The name of the new channel
- * @param options Options for creating the new channel
- */
- public create<T extends CategoryChannelType>(
- name: string,
- options: CategoryCreateChannelOptions & { type: T }
- ): Promise<BushMappedChannelCategoryTypes[T]>;
- public create(name: string, options?: CategoryCreateChannelOptions): Promise<BushTextChannel>;
-}
diff --git a/src/lib/extensions/discord.js/BushChannel.ts b/src/lib/extensions/discord.js/BushChannel.ts
deleted file mode 100644
index e66135c..0000000
--- a/src/lib/extensions/discord.js/BushChannel.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import type {
- BushCategoryChannel,
- BushClient,
- BushDMChannel,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushVoiceBasedChannel,
- BushVoiceChannel
-} from '#lib';
-import { Channel, ChannelType, PartialGroupDMChannel, type Snowflake } from 'discord.js';
-import type { RawChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents any channel on Discord.
- */
-export declare class BushChannel extends Channel {
- public constructor(client: BushClient, data?: RawChannelData, immediatePatch?: boolean);
- public get createdAt(): Date | null;
- public get createdTimestamp(): number | null;
- public deleted: boolean;
- public id: Snowflake;
- public get partial(): false;
- public type: ChannelType;
- public delete(): Promise<this>;
- public fetch(force?: boolean): Promise<this>;
- public isText(): this is BushTextChannel;
- public isDM(): this is BushDMChannel;
- public isDMBased(): this is PartialGroupDMChannel | BushDMChannel;
- public isVoice(): this is BushVoiceChannel;
- public isCategory(): this is BushCategoryChannel;
- public isNews(): this is BushNewsChannel;
- public isThread(): this is BushThreadChannel;
- public isStage(): this is BushStageChannel;
- public isTextBased(): this is BushTextBasedChannel;
- public isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushChannelManager.ts b/src/lib/extensions/discord.js/BushChannelManager.ts
deleted file mode 100644
index ff93209..0000000
--- a/src/lib/extensions/discord.js/BushChannelManager.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { BushAnyChannel, BushChannelResolvable } from '#lib';
-import { CachedManager, ChannelManager, type Client, type FetchChannelOptions, type Snowflake } from 'discord.js';
-import type { RawChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * A manager of channels belonging to a client
- */
-export declare class BushChannelManager
- extends CachedManager<Snowflake, BushAnyChannel, BushChannelResolvable>
- implements ChannelManager
-{
- public constructor(client: Client, iterable: Iterable<RawChannelData>);
-
- /**
- * Obtains a channel from Discord, or the channel cache if it's already available.
- * @param id The channel's id
- * @param options Additional options for this fetch
- * @example
- * // Fetch a channel by its id
- * client.channels.fetch('222109930545610754')
- * .then(channel => console.log(channel.name))
- * .catch(console.error);
- */
- public fetch(id: Snowflake, options?: FetchChannelOptions): Promise<BushAnyChannel | null>;
-}
diff --git a/src/lib/extensions/discord.js/BushChatInputCommandInteraction.ts b/src/lib/extensions/discord.js/BushChatInputCommandInteraction.ts
deleted file mode 100644
index 2491a68..0000000
--- a/src/lib/extensions/discord.js/BushChatInputCommandInteraction.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import type {
- BushApplicationCommand,
- BushClient,
- BushGuild,
- BushGuildEmoji,
- BushGuildMember,
- BushGuildTextBasedChannel,
- BushNonThreadGuildBasedChannel,
- BushRole,
- BushTextBasedChannel,
- BushUser
-} from '#lib';
-import type { APIInteractionGuildMember } from 'discord-api-types/v10';
-import { ChatInputCommandInteraction, type CacheType, type CacheTypeReducer, type Invite, type Snowflake } from 'discord.js';
-import type { RawCommandInteractionData } from 'discord.js/typings/rawDataTypes';
-
-export type BushGuildResolvable =
- | BushGuild
- | BushNonThreadGuildBasedChannel
- | BushGuildMember
- | BushGuildEmoji
- | Invite
- | BushRole
- | Snowflake;
-
-/**
- * Represents a command interaction.
- */
-export class BushChatInputCommandInteraction<Cached extends CacheType = CacheType> extends ChatInputCommandInteraction<Cached> {
- public declare readonly client: BushClient;
- public declare member: CacheTypeReducer<Cached, BushGuildMember, APIInteractionGuildMember>;
- public declare user: BushUser;
-
- public constructor(client: BushClient, data: RawCommandInteractionData) {
- super(client, data);
- }
-}
-
-export interface BushChatInputCommandInteraction<Cached extends CacheType = CacheType> {
- get command(): BushApplicationCommand | BushApplicationCommand<{ guild: BushGuildResolvable }> | null;
- get channel(): CacheTypeReducer<
- Cached,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushTextBasedChannel | null
- >;
- get guild(): CacheTypeReducer<Cached, BushGuild, null>;
-}
diff --git a/src/lib/extensions/discord.js/BushClientEvents.ts b/src/lib/extensions/discord.js/BushClientEvents.ts
index e1a9954..22bae65 100644
--- a/src/lib/extensions/discord.js/BushClientEvents.ts
+++ b/src/lib/extensions/discord.js/BushClientEvents.ts
@@ -1,176 +1,29 @@
import type {
BanResponse,
- BushApplicationCommand,
- BushButtonInteraction,
- BushClient,
- BushDMChannel,
- BushGuild,
- BushGuildBan,
- BushGuildEmoji,
- BushGuildMember,
- BushGuildTextBasedChannel,
- BushMessage,
- BushMessageReaction,
- BushModalSubmitInteraction,
- BushNewsChannel,
- BushNonThreadGuildBasedChannel,
- BushPresence,
- BushRole,
- BushSelectMenuInteraction,
- BushStageInstance,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushThreadMember,
- BushUser,
- BushVoiceState,
- Guild,
- GuildSettings,
- PartialBushGuildMember,
- PartialBushMessage,
- PartialBushMessageReaction,
- PartialBushUser
+ CommandMessage,
+ Guild as GuildDB,
+ GuildSettings
} from '#lib';
import type { AkairoClientEvents } from 'discord-akairo';
import type {
+ ButtonInteraction,
Collection,
- GuildScheduledEvent,
- Interaction,
- Invite,
+ Guild,
+ GuildMember,
+ GuildTextBasedChannel,
+ Message,
+ ModalSubmitInteraction,
+ Role,
+ SelectMenuInteraction,
Snowflake,
- Sticker,
- Typing
+ User
} from 'discord.js';
export interface BushClientEvents extends AkairoClientEvents {
- applicationCommandCreate: [command: BushApplicationCommand];
- applicationCommandDelete: [command: BushApplicationCommand];
- applicationCommandUpdate: [
- oldCommand: BushApplicationCommand | null,
- newCommand: BushApplicationCommand
- ];
- channelCreate: [channel: BushNonThreadGuildBasedChannel];
- channelDelete: [channel: BushDMChannel | BushNonThreadGuildBasedChannel];
- channelPinsUpdate: [channel: BushTextBasedChannel, date: Date];
- channelUpdate: [
- oldChannel: BushDMChannel | BushNonThreadGuildBasedChannel,
- newChannel: BushDMChannel | BushNonThreadGuildBasedChannel
- ];
- debug: [message: string];
- warn: [message: string];
- emojiCreate: [emoji: BushGuildEmoji];
- emojiDelete: [emoji: BushGuildEmoji];
- emojiUpdate: [oldEmoji: BushGuildEmoji, newEmoji: BushGuildEmoji];
- error: [error: Error];
- guildBanAdd: [ban: BushGuildBan];
- guildBanRemove: [ban: BushGuildBan];
- guildCreate: [guild: BushGuild];
- guildDelete: [guild: BushGuild];
- guildUnavailable: [guild: BushGuild];
- guildIntegrationsUpdate: [guild: BushGuild];
- guildMemberAdd: [member: BushGuildMember];
- guildMemberAvailable: [member: BushGuildMember | PartialBushGuildMember];
- guildMemberRemove: [member: BushGuildMember | PartialBushGuildMember];
- guildMembersChunk: [
- members: Collection<Snowflake, BushGuildMember>,
- guild: BushGuild,
- data: {
- count: number;
- index: number;
- nonce: string | undefined;
- }
- ];
- guildMemberUpdate: [
- oldMember: BushGuildMember | PartialBushGuildMember,
- newMember: BushGuildMember
- ];
- guildUpdate: [oldGuild: BushGuild, newGuild: BushGuild];
- inviteCreate: [invite: Invite];
- inviteDelete: [invite: Invite];
- messageCreate: [message: BushMessage];
- messageDelete: [message: BushMessage | PartialBushMessage];
- messageReactionRemoveAll: [
- message: BushMessage | PartialBushMessage,
- reactions: Collection<string, BushMessageReaction>
- ];
- messageReactionRemoveEmoji: [
- reaction: BushMessageReaction | PartialBushMessageReaction
- ];
- messageDeleteBulk: [
- messages: Collection<Snowflake, BushMessage | PartialBushMessage>,
- channel: BushTextBasedChannel
- ];
- messageReactionAdd: [
- reaction: BushMessageReaction | PartialBushMessageReaction,
- user: BushUser | PartialBushUser
- ];
- messageReactionRemove: [
- reaction: BushMessageReaction | PartialBushMessageReaction,
- user: BushUser | PartialBushUser
- ];
- messageUpdate: [
- oldMessage: BushMessage | PartialBushMessage,
- newMessage: BushMessage | PartialBushMessage
- ];
- presenceUpdate: [oldPresence: BushPresence | null, newPresence: BushPresence];
- ready: [client: BushClient<true>];
- invalidated: [];
- roleCreate: [role: BushRole];
- roleDelete: [role: BushRole];
- roleUpdate: [oldRole: BushRole, newRole: BushRole];
- threadCreate: [thread: BushThreadChannel, newlyCreated: boolean];
- threadDelete: [thread: BushThreadChannel];
- threadListSync: [
- threads: Collection<Snowflake, BushThreadChannel>,
- guild: BushGuild
- ];
- threadMemberUpdate: [
- oldMember: BushThreadMember,
- newMember: BushThreadMember
- ];
- threadMembersUpdate: [
- oldMembers: Collection<Snowflake, BushThreadMember>,
- newMembers: Collection<Snowflake, BushThreadMember>,
- thread: BushThreadChannel
- ];
- threadUpdate: [oldThread: BushThreadChannel, newThread: BushThreadChannel];
- typingStart: [typing: Typing];
- userUpdate: [oldUser: BushUser | PartialBushUser, newUser: BushUser];
- voiceStateUpdate: [oldState: BushVoiceState, newState: BushVoiceState];
- webhookUpdate: [channel: BushTextChannel];
- interactionCreate: [interaction: Interaction];
- shardError: [error: Error, shardId: number];
- shardReady: [shardId: number, unavailableGuilds: Set<Snowflake> | undefined];
- shardReconnecting: [shardId: number];
- shardResume: [shardId: number, replayedEvents: number];
- stageInstanceCreate: [stageInstance: BushStageInstance];
- stageInstanceUpdate: [
- oldStageInstance: BushStageInstance | null,
- newStageInstance: BushStageInstance
- ];
- stageInstanceDelete: [stageInstance: BushStageInstance];
- stickerCreate: [sticker: Sticker];
- stickerDelete: [sticker: Sticker];
- stickerUpdate: [oldSticker: Sticker, newSticker: Sticker];
- guildScheduledEventCreate: [guildScheduledEvent: GuildScheduledEvent];
- guildScheduledEventUpdate: [
- oldGuildScheduledEvent: GuildScheduledEvent,
- newGuildScheduledEvent: GuildScheduledEvent
- ];
- guildScheduledEventDelete: [guildScheduledEvent: GuildScheduledEvent];
- guildScheduledEventUserAdd: [
- guildScheduledEvent: GuildScheduledEvent,
- user: BushUser
- ];
- guildScheduledEventUserRemove: [
- guildScheduledEvent: GuildScheduledEvent,
- user: BushUser
- ];
- /* Custom */
bushBan: [
- victim: BushGuildMember | BushUser,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember | User,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
duration: number,
@@ -178,29 +31,29 @@ export interface BushClientEvents extends AkairoClientEvents {
evidence?: string
];
bushBlock: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
duration: number,
dmSuccess: boolean,
- channel: BushGuildTextBasedChannel,
+ channel: GuildTextBasedChannel,
evidence?: string
];
bushKick: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
evidence?: string
];
bushMute: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
duration: number,
@@ -208,43 +61,43 @@ export interface BushClientEvents extends AkairoClientEvents {
evidence?: string
];
bushPunishRole: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
duration: number,
- role: BushRole,
+ role: Role,
evidence?: string
];
bushPunishRoleRemove: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
- role: BushRole,
+ role: Role,
evidence?: string
];
bushPurge: [
- moderator: BushUser,
- guild: BushGuild,
- channel: BushTextChannel | BushNewsChannel | BushThreadChannel,
- messages: Collection<Snowflake, BushMessage>
+ moderator: User,
+ guild: Guild,
+ channel: GuildTextBasedChannel,
+ messages: Collection<Snowflake, Message>
];
bushRemoveTimeout: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
evidence?: string
];
bushTimeout: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
duration: number,
@@ -252,35 +105,35 @@ export interface BushClientEvents extends AkairoClientEvents {
evidence?: string
];
bushUnban: [
- victim: BushUser,
- moderator: BushUser,
- guild: BushGuild,
+ victim: User,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
evidence?: string
];
bushUnblock: [
- victim: BushGuildMember | BushUser,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember | User,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
- channel: BushGuildTextBasedChannel,
+ channel: GuildTextBasedChannel,
evidence?: string
];
bushUnmute: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
evidence?: string
];
bushUpdateModlog: [
- moderator: BushGuildMember,
+ moderator: GuildMember,
modlogID: string,
key: 'evidence' | 'hidden',
oldModlog: string | boolean,
@@ -288,55 +141,55 @@ export interface BushClientEvents extends AkairoClientEvents {
];
bushUpdateSettings: [
setting: Setting,
- guild: BushGuild,
- oldValue: Guild[Setting],
- newValue: Guild[Setting],
- moderator?: BushGuildMember
+ guild: Guild,
+ oldValue: GuildDB[Setting],
+ newValue: GuildDB[Setting],
+ moderator?: GuildMember
];
bushWarn: [
- victim: BushGuildMember,
- moderator: BushUser,
- guild: BushGuild,
+ victim: GuildMember,
+ moderator: User,
+ guild: Guild,
reason: string | undefined,
caseID: string,
dmSuccess: boolean,
evidence?: string
];
bushLevelUpdate: [
- member: BushGuildMember,
+ member: GuildMember,
oldLevel: number,
newLevel: number,
currentXp: number,
- message: BushMessage & { guild: BushGuild }
+ message: CommandMessage
];
bushLockdown: [
- moderator: BushGuildMember,
+ moderator: GuildMember,
reason: string | undefined,
channelsSuccessMap: Collection<Snowflake, boolean>,
all?: boolean
];
bushUnlockdown: [
- moderator: BushGuildMember,
+ moderator: GuildMember,
reason: string | undefined,
channelsSuccessMap: Collection<Snowflake, boolean>,
all?: boolean
];
massBan: [
- moderator: BushGuildMember,
- guild: BushGuild,
+ moderator: GuildMember,
+ guild: Guild,
reason: string | undefined,
results: Collection<Snowflake, BanResponse>
];
massEvidence: [
- moderator: BushGuildMember,
- guild: BushGuild,
+ moderator: GuildMember,
+ guild: Guild,
evidence: string,
lines: string[]
];
/* components */
- button: [button: BushButtonInteraction];
- selectMenu: [selectMenu: BushSelectMenuInteraction];
- modal: [modal: BushModalSubmitInteraction];
+ button: [button: ButtonInteraction];
+ selectMenu: [selectMenu: SelectMenuInteraction];
+ modal: [modal: ModalSubmitInteraction];
}
type Setting =
diff --git a/src/lib/extensions/discord.js/BushClientUser.ts b/src/lib/extensions/discord.js/BushClientUser.ts
deleted file mode 100644
index cee9808..0000000
--- a/src/lib/extensions/discord.js/BushClientUser.ts
+++ /dev/null
@@ -1,98 +0,0 @@
-import type {
- ActivityOptions,
- Base64Resolvable,
- BufferResolvable,
- ClientPresence,
- ClientUser,
- ClientUserEditData,
- PresenceData,
- PresenceStatusData
-} from 'discord.js';
-import { BushUser } from './BushUser.js';
-
-/**
- * Represents the logged in client's Discord user.
- */
-export declare class BushClientUser extends BushUser implements ClientUser {
- /**
- * If the bot's {@link ClientApplication.owner Owner} has MFA enabled on their account
- */
- public mfaEnabled: boolean;
-
- /**
- * Represents the client user's presence
- */
- public readonly presence: ClientPresence;
-
- /**
- * Whether or not this account has been verified
- */
- public verified: boolean;
-
- /**
- * Edits the logged in client.
- * @param data The new data
- */
- public edit(data: ClientUserEditData): Promise<this>;
-
- /**
- * Sets the activity the client user is playing.
- * @param name Activity being played, or options for setting the activity
- * @param options Options for setting the activity
- * @example
- * // Set the client user's activity
- * client.user.setActivity('discord.js', { type: 'WATCHING' });
- */
- public setActivity(options?: ActivityOptions): ClientPresence;
- public setActivity(name: string, options?: ActivityOptions): ClientPresence;
-
- /**
- * Sets/removes the AFK flag for the client user.
- * @param afk Whether or not the user is AFK
- * @param shardId Shard Id(s) to have the AFK flag set on
- */
- public setAFK(afk: boolean, shardId?: number | number[]): ClientPresence;
-
- /**
- * Sets the avatar of the logged in client.
- * @param avatar The new avatar
- * @example
- * // Set avatar
- * client.user.setAvatar('./avatar.png')
- * .then(user => console.log(`New avatar set!`))
- * .catch(console.error);
- */
- public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>;
-
- /**
- * Sets the full presence of the client user.
- * @param data Data for the presence
- * @example
- * // Set the client user's presence
- * client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
- */
- public setPresence(data: PresenceData): ClientPresence;
-
- /**
- * Sets the status of the client user.
- * @param status Status to change to
- * @param shardId Shard id(s) to have the activity set on
- * @example
- * // Set the client user's status
- * client.user.setStatus('idle');
- */
- public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
-
- /**
- * Sets the username of the logged in client.
- * <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
- * every hour. Use this sparingly!</info>
- * @param username The new username
- * @example
- * // Set username
- * client.user.setUsername('discordjs')
- * .then(user => console.log(`My new username is ${user.username}`))
- * .catch(console.error);
- */
- public setUsername(username: string): Promise<this>;
-}
diff --git a/src/lib/extensions/discord.js/BushDMChannel.ts b/src/lib/extensions/discord.js/BushDMChannel.ts
deleted file mode 100644
index 87382ec..0000000
--- a/src/lib/extensions/discord.js/BushDMChannel.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import type {
- BushCategoryChannel,
- BushClient,
- BushMessageManager,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushUser,
- BushVoiceBasedChannel,
- BushVoiceChannel
-} from '#lib';
-import { DMChannel, PartialGroupDMChannel, type Partialize } from 'discord.js';
-import type { RawDMChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a direct message channel between two users.
- */
-export class BushDMChannel extends DMChannel {
- public declare readonly client: BushClient;
- public declare messages: BushMessageManager;
-
- public constructor(client: BushClient, data?: RawDMChannelData) {
- super(client, data);
- }
-}
-
-export interface BushDMChannel extends DMChannel {
- get recipient(): BushUser | null;
- isText(): this is BushTextChannel;
- isDM(): this is BushDMChannel;
- isDMBased(): this is PartialGroupDMChannel | BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
-
-export interface PartialBushDMChannel extends Partialize<BushDMChannel, null, null, 'lastMessageId'> {
- lastMessageId: undefined;
-}
diff --git a/src/lib/extensions/discord.js/BushEmoji.ts b/src/lib/extensions/discord.js/BushEmoji.ts
deleted file mode 100644
index 9e42e5d..0000000
--- a/src/lib/extensions/discord.js/BushEmoji.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { BushClient } from '#lib';
-import { Emoji } from 'discord.js';
-import type { RawEmojiData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents an emoji, see {@link GuildEmoji} and {@link ReactionEmoji}.
- */
-export class BushEmoji extends Emoji {
- public declare readonly client: BushClient;
-
- public constructor(client: BushClient, emoji: RawEmojiData) {
- super(client, emoji);
- }
-}
diff --git a/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts b/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts
deleted file mode 100644
index ba9db66..0000000
--- a/src/lib/extensions/discord.js/BushGuildApplicationCommandManager.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-/* eslint-disable @typescript-eslint/ban-types */
-import {
- BushApplicationCommandManager,
- type BushApplicationCommand,
- type BushApplicationCommandResolvable,
- type BushClient,
- type BushGuild
-} from '#lib';
-import type { ApplicationCommandData, BaseFetchOptions, Collection, Snowflake } from 'discord.js';
-import type { RawApplicationCommandData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * An extension for guild-specific application commands.
- */
-export declare class BushGuildApplicationCommandManager extends BushApplicationCommandManager<
- BushApplicationCommand,
- {},
- BushGuild
-> {
- public constructor(guild: BushGuild, iterable?: Iterable<RawApplicationCommandData>);
- public declare readonly client: BushClient;
-
- /**
- * The guild that this manager belongs to
- */
- public guild: BushGuild;
-
- /**
- * Creates an application command.
- * @param command The command
- * @param guildId The guild's id to create this command in,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Create a new command
- * client.application.commands.create({
- * name: 'test',
- * description: 'A test command',
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- public create(command: BushApplicationCommandResolvable): Promise<BushApplicationCommand>;
-
- /**
- * Deletes an application command.
- * @param command The command to delete
- * @param guildId The guild's id where the command is registered,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Delete a command
- * guild.commands.delete('123456789012345678')
- * .then(console.log)
- * .catch(console.error);
- */
- public delete(command: BushApplicationCommandResolvable): Promise<BushApplicationCommand | null>;
-
- /**
- * Edits an application command.
- * @param command The command to edit
- * @param data The data to update the command with
- * @param guildId The guild's id where the command registered,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Edit an existing command
- * client.application.commands.edit('123456789012345678', {
- * description: 'New description',
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- public edit(command: BushApplicationCommandResolvable, data: ApplicationCommandData): Promise<BushApplicationCommand>;
-
- /**
- * Obtains one or multiple application commands from Discord, or the cache if it's already available.
- * @param id The application command's id
- * @param options Additional options for this fetch
- * @example
- * // Fetch a single command
- * client.application.commands.fetch('123456789012345678')
- * .then(command => console.log(`Fetched command ${command.name}`))
- * .catch(console.error);
- * @example
- * // Fetch all commands
- * guild.commands.fetch()
- * .then(commands => console.log(`Fetched ${commands.size} commands`))
- * .catch(console.error);
- */
- public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<BushApplicationCommand>;
- public fetch(options: BaseFetchOptions): Promise<Collection<Snowflake, BushApplicationCommand>>;
- public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, BushApplicationCommand>>;
-
- /**
- * Sets all the commands for this application or guild.
- * @param commands The commands
- * @param guildId The guild's id to create the commands in,
- * ignored when using a {@link GuildApplicationCommandManager}
- * @example
- * // Set all commands to just this one
- * client.application.commands.set([
- * {
- * name: 'test',
- * description: 'A test command',
- * },
- * ])
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Remove all commands
- * guild.commands.set([])
- * .then(console.log)
- * .catch(console.error);
- */
- public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, BushApplicationCommand>>;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildBan.ts b/src/lib/extensions/discord.js/BushGuildBan.ts
deleted file mode 100644
index d56c531..0000000
--- a/src/lib/extensions/discord.js/BushGuildBan.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { BushClient, BushGuild, BushUser } from '#lib';
-import { GuildBan } from 'discord.js';
-import type { RawGuildBanData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a ban in a guild on Discord.
- */
-export declare class BushGuildBan extends GuildBan {
- public constructor(client: BushClient, data: RawGuildBanData, guild: BushGuild);
- public guild: BushGuild;
- public user: BushUser;
- public get partial(): boolean;
- public reason?: string | null;
- public fetch(force?: boolean): Promise<BushGuildBan>;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildChannel.ts b/src/lib/extensions/discord.js/BushGuildChannel.ts
deleted file mode 100644
index 62bf05a..0000000
--- a/src/lib/extensions/discord.js/BushGuildChannel.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import type {
- BushCategoryChannel,
- BushClient,
- BushDMChannel,
- BushGuild,
- BushGuildBasedChannel,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushVoiceBasedChannel,
- BushVoiceChannel
-} from '#lib';
-import { GuildChannel, PartialGroupDMChannel } from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a guild channel from any of the following:
- * - {@link BushTextChannel}
- * - {@link BushVoiceChannel}
- * - {@link BushCategoryChannel}
- * - {@link BushNewsChannel}
- * - {@link BushStoreChannel}
- * - {@link BushStageChannel}
- */
-export class BushGuildChannel extends GuildChannel {
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData, client?: BushClient, immediatePatch?: boolean) {
- super(guild, data, client, immediatePatch);
- }
-}
-
-export interface BushGuildChannel extends GuildChannel {
- isText(): this is BushTextChannel;
- isDMBased(): this is PartialGroupDMChannel | BushDMChannel;
- isDM(): this is BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushGuildBasedChannel & BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildChannelManager.ts b/src/lib/extensions/discord.js/BushGuildChannelManager.ts
deleted file mode 100644
index 4048b98..0000000
--- a/src/lib/extensions/discord.js/BushGuildChannelManager.ts
+++ /dev/null
@@ -1,183 +0,0 @@
-import type {
- BushFetchedThreads,
- BushGuild,
- BushGuildBasedChannel,
- BushGuildChannel,
- BushMappedGuildChannelTypes,
- BushNonThreadGuildBasedChannel,
- BushTextChannel
-} from '#lib';
-import {
- CachedManager,
- ChannelData,
- ChannelWebhookCreateOptions,
- SetChannelPositionOptions,
- Webhook,
- type BaseFetchOptions,
- type ChannelPosition,
- type Collection,
- type GuildChannelCreateOptions,
- type GuildChannelManager,
- type GuildChannelResolvable,
- type GuildChannelTypes,
- type Snowflake
-} from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for GuildChannels and stores their cache.
- */
-export declare class BushGuildChannelManager
- extends CachedManager<Snowflake, BushGuildBasedChannel, GuildChannelResolvable>
- implements GuildChannelManager
-{
- public constructor(guild: BushGuild, iterable?: Iterable<RawGuildChannelData>);
-
- /**
- * The number of channels in this managers cache excluding thread channels
- * that do not count towards a guild's maximum channels restriction.
- */
- public readonly channelCountWithoutThreads: number;
-
- /**
- * The guild this Manager belongs to
- */
- public guild: BushGuild;
-
- /**
- * Creates a new channel in the guild.
- * @param name The name of the new channel
- * @param options Options for creating the new channel
- * @example
- * // Create a new text channel
- * guild.channels.create('new-general', { reason: 'Needed a cool new channel' })
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Create a new channel with permission overwrites
- * guild.channels.create('new-voice', {
- * type: 'GuildVoice',
- * permissionOverwrites: [
- * {
- * id: message.author.id,
- * deny: [PermissionFlagsBits.ViewChannel],
- * },
- * ],
- * })
- */
- public create<T extends GuildChannelTypes>(
- name: string,
- options: GuildChannelCreateOptions & { type: T }
- ): Promise<BushMappedGuildChannelTypes[T]>;
- public create(name: string, options?: GuildChannelCreateOptions): Promise<BushTextChannel>;
-
- /**
- * Creates a webhook for the channel.
- * @param channel The channel to create the webhook for
- * @param name The name of the webhook
- * @param options Options for creating the webhook
- * @returns Returns the created Webhook
- * @example
- * // Create a webhook for the current channel
- * guild.channels.createWebhook('222197033908436994', 'Snek', {
- * avatar: 'https://i.imgur.com/mI8XcpG.jpg',
- * reason: 'Needed a cool new Webhook'
- * })
- * .then(console.log)
- * .catch(console.error)
- */
- public createWebhook(channel: GuildChannelResolvable, name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
-
- /**
- * Edits the channel.
- * @param channel The channel to edit
- * @param data The new data for the channel
- * @param reason Reason for editing this channel
- * @example
- * // Edit a channel
- * guild.channels.edit('222197033908436994', { name: 'new-channel' })
- * .then(console.log)
- * .catch(console.error);
- */
- public edit(channel: GuildChannelResolvable, data: ChannelData, reason?: string): Promise<BushGuildChannel>;
-
- /**
- * Obtains one or more guild channels from Discord, or the channel cache if they're already available.
- * @param id The channel's id
- * @param options Additional options for this fetch
- * @example
- * // Fetch all channels from the guild (excluding threads)
- * message.guild.channels.fetch()
- * .then(channels => console.log(`There are ${channels.size} channels.`))
- * .catch(console.error);
- * @example
- * // Fetch a single channel
- * message.guild.channels.fetch('222197033908436994')
- * .then(channel => console.log(`The channel name is: ${channel.name}`))
- * .catch(console.error);
- */
- public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<BushNonThreadGuildBasedChannel | null>;
- public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, BushNonThreadGuildBasedChannel>>;
-
- /**
- * Fetches all webhooks for the channel.
- * @param channel The channel to fetch webhooks for
- * @example
- * // Fetch webhooks
- * guild.channels.fetchWebhooks('769862166131245066')
- * .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
- * .catch(console.error);
- */
- public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>;
-
- /**
- * Sets a new position for the guild channel.
- * @param channel The channel to set the position for
- * @param position The new position for the guild channel
- * @param options Options for setting position
- * @example
- * // Set a new channel position
- * guild.channels.setPosition('222078374472843266', 2)
- * .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
- * .catch(console.error);
- */
- public setPosition(
- channel: GuildChannelResolvable,
- position: number,
- options?: SetChannelPositionOptions
- ): Promise<BushGuildChannel>;
-
- /**
- * Batch-updates the guild's channels' positions.
- * <info>Only one channel's parent can be changed at a time</info>
- * @param channelPositions Channel positions to update
- * @example
- * guild.channels.setPositions([{ channel: channelId, position: newChannelIndex }])
- * .then(guild => console.log(`Updated channel positions for ${guild}`))
- * .catch(console.error);
- */
- public setPositions(channelPositions: readonly ChannelPosition[]): Promise<BushGuild>;
-
- /**
- * Obtains all active thread channels in the guild from Discord
- * @param {} [cache=true] Whether to cache the fetched data
- * @example
- * // Fetch all threads from the guild
- * message.guild.channels.fetchActiveThreads()
- * .then(fetched => console.log(`There are ${fetched.threads.size} threads.`))
- * .catch(console.error);
- */
- public fetchActiveThreads(cache?: boolean): Promise<BushFetchedThreads>;
-
- /**
- * Deletes the channel.
- * @param channel The channel to delete
- * @param reason Reason for deleting this channel
- * @example
- * // Delete the channel
- * guild.channels.delete('858850993013260338', 'making room for new channels')
- * .then(console.log)
- * .catch(console.error);
- */
- public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildEmoji.ts b/src/lib/extensions/discord.js/BushGuildEmoji.ts
deleted file mode 100644
index 9b931bb..0000000
--- a/src/lib/extensions/discord.js/BushGuildEmoji.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { BushClient, BushGuild, BushGuildEmojiRoleManager, BushUser } from '#lib';
-import { GuildEmoji } from 'discord.js';
-import type { RawGuildEmojiData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a custom emoji.
- */
-export class BushGuildEmoji extends GuildEmoji {
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
- public declare author: BushUser | null;
-
- public constructor(client: BushClient, data: RawGuildEmojiData, guild: BushGuild) {
- super(client, data, guild);
- }
-}
-
-export interface BushGuildEmoji extends GuildEmoji {
- get roles(): BushGuildEmojiRoleManager;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts b/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts
deleted file mode 100644
index 8b069ae..0000000
--- a/src/lib/extensions/discord.js/BushGuildEmojiRoleManager.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import type { BushClient, BushGuild, BushGuildEmoji, BushRole, BushRoleResolvable } from '#lib';
-import { DataManager, GuildEmojiRoleManager, type Collection, type Snowflake } from 'discord.js';
-
-/**
- * Manages API methods for roles belonging to emojis and stores their cache.
- */
-export declare class BushGuildEmojiRoleManager
- extends DataManager<Snowflake, BushRole, BushRoleResolvable>
- implements GuildEmojiRoleManager
-{
- public constructor(emoji: BushGuildEmoji);
- public declare readonly client: BushClient;
-
- /**
- * The emoji belonging to this manager
- */
- public emoji: BushGuildEmoji;
-
- /**
- * The guild belonging to this manager
- */
- public guild: BushGuild;
-
- /**
- * Adds a role (or multiple roles) to the list of roles that can use this emoji.
- * @param roleOrRoles The role or roles to add
- */
- public add(
- roleOrRoles: BushRoleResolvable | readonly BushRoleResolvable[] | Collection<Snowflake, BushRole>
- ): Promise<BushGuildEmoji>;
-
- /**
- * Sets the role(s) that can use this emoji.
- * @param roles The roles or role ids to apply
- * @example
- * // Set the emoji's roles to a single role
- * guildEmoji.roles.set(['391156570408615936'])
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Remove all roles from an emoji
- * guildEmoji.roles.set([])
- * .then(console.log)
- * .catch(console.error);
- */
- public set(roles: readonly BushRoleResolvable[] | Collection<Snowflake, BushRole>): Promise<BushGuildEmoji>;
-
- /**
- * Removes a role (or multiple roles) from the list of roles that can use this emoji.
- * @param roleOrRoles The role or roles to remove
- */
- public remove(
- roleOrRoles: BushRoleResolvable | readonly BushRoleResolvable[] | Collection<Snowflake, BushRole>
- ): Promise<BushGuildEmoji>;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildManager.ts b/src/lib/extensions/discord.js/BushGuildManager.ts
deleted file mode 100644
index 41618e3..0000000
--- a/src/lib/extensions/discord.js/BushGuildManager.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import type { BushClient, BushGuild, BushGuildResolvable } from '#lib';
-import {
- CachedManager,
- GuildManager,
- type Collection,
- type FetchGuildOptions,
- type FetchGuildsOptions,
- type GuildCreateOptions,
- type OAuth2Guild,
- type Snowflake
-} from 'discord.js';
-import { type RawGuildData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for Guilds and stores their cache.
- */
-export declare class BushGuildManager extends CachedManager<Snowflake, BushGuild, BushGuildResolvable> implements GuildManager {
- public constructor(client: BushClient, iterable?: Iterable<RawGuildData>);
-
- /**
- * Creates a guild.
- * <warn>This is only available to bots in fewer than 10 guilds.</warn>
- * @param name The name of the guild
- * @param options Options for creating the guild
- * @returns The guild that was created
- */
- public create(name: string, options?: GuildCreateOptions): Promise<BushGuild>;
-
- /**
- * Obtains one or multiple guilds from Discord, or the guild cache if it's already available.
- * @param options The guild's id or options
- */
- public fetch(options: Snowflake | FetchGuildOptions): Promise<BushGuild>;
- public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
-}
diff --git a/src/lib/extensions/discord.js/BushGuildMemberManager.ts b/src/lib/extensions/discord.js/BushGuildMemberManager.ts
deleted file mode 100644
index b0368b5..0000000
--- a/src/lib/extensions/discord.js/BushGuildMemberManager.ts
+++ /dev/null
@@ -1,177 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember, BushGuildMemberResolvable, BushUser, BushUserResolvable } from '#lib';
-import {
- CachedManager,
- GuildMemberManager,
- type AddGuildMemberOptions,
- type BanOptions,
- type Collection,
- type FetchMemberOptions,
- type FetchMembersOptions,
- type GuildListMembersOptions,
- type GuildMemberEditData,
- type GuildPruneMembersOptions,
- type GuildSearchMembersOptions,
- type Snowflake
-} from 'discord.js';
-import type { RawGuildMemberData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for GuildMembers and stores their cache.
- */
-export declare class BushGuildMemberManager
- extends CachedManager<Snowflake, BushGuildMember, BushGuildMemberResolvable>
- implements GuildMemberManager
-{
- public constructor(guild: BushGuild, iterable?: Iterable<RawGuildMemberData>);
- public declare readonly client: BushClient;
-
- /**
- * The guild this manager belongs to
- */
- public guild: BushGuild;
-
- /**
- * Adds a user to the guild using OAuth2. Requires the `PermissionFlagsBits.CreateInstantInvite` permission.
- * @param user The user to add to the guild
- * @param options Options for adding the user to the guild
- */
- public add(
- user: BushUserResolvable,
- options: AddGuildMemberOptions & { fetchWhenExisting: false }
- ): Promise<BushGuildMember | null>;
- public add(user: BushUserResolvable, options: AddGuildMemberOptions): Promise<BushGuildMember>;
-
- /**
- * Bans a user from the guild.
- * @param user The user to ban
- * @param options Options for the ban
- * @returns Result object will be resolved as specifically as possible.
- * If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot
- * be resolved, the user id will be the result.
- * Internally calls the GuildBanManager#create method.
- * @example
- * // Ban a user by id (or with a user/guild member object)
- * guild.members.ban('84484653687267328')
- * .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
- * .catch(console.error);
- */
- public ban(user: BushUserResolvable, options?: BanOptions): Promise<BushGuildMember | BushUser | Snowflake>;
-
- /**
- * Edits a member of the guild.
- * <info>The user must be a member of the guild</info>
- * @param user The member to edit
- * @param data The data to edit the member with
- * @param reason Reason for editing this user
- */
- public edit(user: BushUserResolvable, data: GuildMemberEditData, reason?: string): Promise<void>;
-
- /**
- * Fetches member(s) from Discord, even if they're offline.
- * @param options If a UserResolvable, the user to fetch.
- * If undefined, fetches all members.
- * If a query, it limits the results to users with similar usernames.
- * @example
- * // Fetch all members from a guild
- * guild.members.fetch()
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Fetch a single member
- * guild.members.fetch('66564597481480192')
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Fetch a single member without checking cache
- * guild.members.fetch({ user, force: true })
- * .then(console.log)
- * .catch(console.error)
- * @example
- * // Fetch a single member without caching
- * guild.members.fetch({ user, cache: false })
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Fetch by an array of users including their presences
- * guild.members.fetch({ user: ['66564597481480192', '191615925336670208'], withPresences: true })
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Fetch by query
- * guild.members.fetch({ query: 'hydra', limit: 1 })
- * .then(console.log)
- * .catch(console.error);
- */
- public fetch(
- options: BushUserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: BushUserResolvable })
- ): Promise<BushGuildMember>;
- public fetch(options?: FetchMembersOptions): Promise<Collection<Snowflake, BushGuildMember>>;
-
- /**
- * Kicks a user from the guild.
- * <info>The user must be a member of the guild</info>
- * @param user The member to kick
- * @param reason Reason for kicking
- * @returns Result object will be resolved as specifically as possible.
- * If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot
- * be resolved, the user's id will be the result.
- * @example
- * // Kick a user by id (or with a user/guild member object)
- * guild.members.kick('84484653687267328')
- * .then(banInfo => console.log(`Kicked ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
- * .catch(console.error);
- */
- public kick(user: BushUserResolvable, reason?: string): Promise<BushGuildMember | BushUser | Snowflake>;
-
- /**
- * Lists up to 1000 members of the guild.
- * @param options Options for listing members
- */
- public list(options?: GuildListMembersOptions): Promise<Collection<Snowflake, BushGuildMember>>;
-
- /**
- * Prunes members from the guild based on how long they have been inactive.
- * @param options Options for pruning
- * @returns The number of members that were/will be kicked
- * @example
- * // See how many members will be pruned
- * guild.members.prune({ dry: true })
- * .then(pruned => console.log(`This will prune ${pruned} people!`))
- * .catch(console.error);
- * @example
- * // Actually prune the members
- * guild.members.prune({ days: 1, reason: 'too many people!' })
- * .then(pruned => console.log(`I just pruned ${pruned} people!`))
- * .catch(console.error);
- * @example
- * // Include members with a specified role
- * guild.members.prune({ days: 7, roles: ['657259391652855808'] })
- * .then(pruned => console.log(`I just pruned ${pruned} people!`))
- * .catch(console.error);
- */
- public prune(options: GuildPruneMembersOptions & { dry?: false; count: false }): Promise<null>;
- public prune(options?: GuildPruneMembersOptions): Promise<number>;
-
- /**
- * Searches for members in the guild based on a query.
- * @param options Options for searching members
- */
- public search(options: GuildSearchMembersOptions): Promise<Collection<Snowflake, BushGuildMember>>;
-
- /**
- * Unbans a user from the guild. Internally calls the {@link GuildBanManager.remove} method.
- * @param user The user to unban
- * @param reason Reason for unbanning user
- * @returns The user that was unbanned
- * @example
- * // Unban a user by id (or with a user/guild member object)
- * guild.members.unban('84484653687267328')
- * .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
- * .catch(console.error);
- */
- public unban(user: BushUserResolvable, reason?: string): Promise<BushUser | null>;
-}
-
-export interface BushGuildMemberManager extends CachedManager<Snowflake, BushGuildMember, BushGuildMemberResolvable> {
- get me(): BushGuildMember | null;
-}
diff --git a/src/lib/extensions/discord.js/BushMessage.ts b/src/lib/extensions/discord.js/BushMessage.ts
deleted file mode 100644
index 48e1792..0000000
--- a/src/lib/extensions/discord.js/BushMessage.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import type {
- BushClient,
- BushCommandUtil,
- BushGuild,
- BushGuildMember,
- BushGuildTextBasedChannel,
- BushMessageReaction,
- BushTextBasedChannel,
- BushThreadChannel,
- BushUser
-} from '#lib';
-import {
- Message,
- MessageActionRowComponent,
- type EmojiIdentifierResolvable,
- type If,
- type MessageEditOptions,
- type MessagePayload,
- type Partialize,
- type ReplyMessageOptions,
- type StartThreadOptions
-} from 'discord.js';
-import type { RawMessageData } from 'discord.js/typings/rawDataTypes';
-
-export type PartialBushMessage = Partialize<
- BushMessage,
- 'type' | 'system' | 'pinned' | 'tts',
- 'content' | 'cleanContent' | 'author'
->;
-
-/**
- * Represents a message on Discord.
- */
-export class BushMessage<Cached extends boolean = boolean> extends Message<Cached> {
- public declare readonly client: BushClient;
- public declare util: BushCommandUtil<BushMessage<true>>;
- public declare author: BushUser;
-
- public constructor(client: BushClient, data: RawMessageData) {
- super(client, data);
- }
-}
-
-export interface BushMessage<Cached extends boolean = boolean> extends Message<Cached> {
- get guild(): If<Cached, BushGuild>;
- get member(): BushGuildMember | null;
- get channel(): If<Cached, BushGuildTextBasedChannel, BushTextBasedChannel>;
- delete(): Promise<BushMessage>;
- edit(content: string | MessageEditOptions | MessagePayload): Promise<BushMessage>;
- equals(message: BushMessage, rawData: unknown): boolean;
- fetchReference(): Promise<BushMessage>;
- crosspost(): Promise<BushMessage>;
- fetch(force?: boolean): Promise<BushMessage>;
- pin(): Promise<BushMessage>;
- react(emoji: EmojiIdentifierResolvable): Promise<BushMessageReaction>;
- removeAttachments(): Promise<BushMessage>;
- reply(options: string | MessagePayload | ReplyMessageOptions): Promise<BushMessage>;
- resolveComponent(customId: string): MessageActionRowComponent | null;
- startThread(options: StartThreadOptions): Promise<BushThreadChannel>;
- suppressEmbeds(suppress?: boolean): Promise<BushMessage>;
- unpin(): Promise<BushMessage>;
- inGuild(): this is BushMessage<true> & this;
-}
diff --git a/src/lib/extensions/discord.js/BushMessageManager.ts b/src/lib/extensions/discord.js/BushMessageManager.ts
deleted file mode 100644
index edb7982..0000000
--- a/src/lib/extensions/discord.js/BushMessageManager.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-import { BushMessageResolvable, BushTextBasedChannel, type BushMessage } from '#lib';
-import {
- CachedManager,
- FetchMessageOptions,
- FetchMessagesOptions,
- MessageManager,
- type Collection,
- type EmojiIdentifierResolvable,
- type MessageEditOptions,
- type MessagePayload,
- type Snowflake
-} from 'discord.js';
-import type { RawMessageData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for Messages and holds their cache.
- */
-export declare class BushMessageManager
- extends CachedManager<Snowflake, BushMessage, BushMessageResolvable>
- implements MessageManager
-{
- public constructor(channel: BushTextBasedChannel, iterable?: Iterable<RawMessageData>);
-
- /**
- * The channel that the messages belong to
- */
- public channel: BushTextBasedChannel;
-
- /**
- * The cache of Messages
- */
- public get cache(): Collection<Snowflake, BushMessage>;
-
- /**
- * Publishes a message in an announcement channel to all channels following it, even if it's not cached.
- * @param message The message to publish
- */
- public crosspost(message: BushMessageResolvable): Promise<BushMessage>;
-
- /**
- * Deletes a message, even if it's not cached.
- * @param message The message to delete
- */
- public delete(message: BushMessageResolvable): Promise<void>;
-
- /**
- * Edits a message, even if it's not cached.
- * @param message The message to edit
- * @param options The options to edit the message
- */
- public edit(message: BushMessageResolvable, options: string | MessagePayload | MessageEditOptions): Promise<BushMessage>;
-
- /**
- * Gets a message, or messages, from this channel.
- * <info>The returned Collection does not contain reaction users of the messages if they were not cached.
- * Those need to be fetched separately in such a case.</info>
- * @param message The id of the message to fetch, or query parameters.
- * @param options Additional options for this fetch
- * @example
- * // Get message
- * channel.messages.fetch('99539446449315840')
- * .then(message => console.log(message.content))
- * .catch(console.error);
- * @example
- * // Get messages
- * channel.messages.fetch({ limit: 10 })
- * .then(messages => console.log(`Received ${messages.size} messages`))
- * .catch(console.error);
- * @example
- * // Get messages and filter by user id
- * channel.messages.fetch()
- * .then(messages => console.log(`${messages.filter(m => m.author.id === '84484653687267328').size} messages`))
- * .catch(console.error);
- */
- public fetch(options: BushMessageResolvable | FetchMessageOptions): Promise<BushMessage>;
- public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, BushMessage>>;
-
- /**
- * Fetches the pinned messages of this channel and returns a collection of them.
- * <info>The returned Collection does not contain any reaction data of the messages.
- * Those need to be fetched separately.</info>
- * @param {} [cache=true] Whether to cache the message(s)
- * @example
- * // Get pinned messages
- * channel.messages.fetchPinned()
- * .then(messages => console.log(`Received ${messages.size} messages`))
- * .catch(console.error);
- */
- public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, BushMessage>>;
-
- /**
- * Adds a reaction to a message, even if it's not cached.
- * @param message The message to react to
- * @param emoji The emoji to react with
- */
- public react(message: BushMessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
-
- /**
- * Pins a message to the channel's pinned messages, even if it's not cached.
- * @param message The message to pin
- */
- public pin(message: BushMessageResolvable): Promise<void>;
-
- /**
- * Unpins a message from the channel's pinned messages, even if it's not cached.
- * @param message The message to unpin
- */
- public unpin(message: BushMessageResolvable): Promise<void>;
-}
-
-export interface BushFetchMessageOptions extends FetchMessageOptions {
- message: BushMessageResolvable;
-}
diff --git a/src/lib/extensions/discord.js/BushMessageReaction.ts b/src/lib/extensions/discord.js/BushMessageReaction.ts
deleted file mode 100644
index 7fe110d..0000000
--- a/src/lib/extensions/discord.js/BushMessageReaction.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { BushClient, BushGuildEmoji, BushMessage, BushReactionEmoji } from '#lib';
-import { MessageReaction, type Partialize } from 'discord.js';
-import type { RawMessageReactionData } from 'discord.js/typings/rawDataTypes';
-
-export type PartialBushMessageReaction = Partialize<BushMessageReaction, 'count'>;
-
-/**
- * Represents a reaction to a message.
- */
-export class BushMessageReaction extends MessageReaction {
- public declare readonly client: BushClient;
-
- public constructor(client: BushClient, data: RawMessageReactionData, message: BushMessage) {
- super(client, data, message);
- }
-}
-
-export interface BushMessageReaction extends MessageReaction {
- get emoji(): BushGuildEmoji | BushReactionEmoji;
-}
diff --git a/src/lib/extensions/discord.js/BushModalSubmitInteraction.ts b/src/lib/extensions/discord.js/BushModalSubmitInteraction.ts
deleted file mode 100644
index 9bdc9e5..0000000
--- a/src/lib/extensions/discord.js/BushModalSubmitInteraction.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import type {
- BushClient,
- BushGuild,
- BushGuildCacheMessage,
- BushGuildMember,
- BushGuildTextBasedChannel,
- BushTextBasedChannel,
- BushUser
-} from '#lib';
-import type { APIInteractionGuildMember, APIModalSubmitInteraction } from 'discord-api-types/v10';
-import {
- InteractionDeferUpdateOptions,
- InteractionResponse,
- InteractionUpdateOptions,
- MessagePayload,
- ModalSubmitInteraction,
- type CacheType,
- type CacheTypeReducer
-} from 'discord.js';
-
-/**
- * Represents a button interaction.
- */
-export class BushModalSubmitInteraction<Cached extends CacheType = CacheType> extends ModalSubmitInteraction<Cached> {
- public declare member: CacheTypeReducer<Cached, BushGuildMember, APIInteractionGuildMember>;
- public declare user: BushUser;
-
- public constructor(client: BushClient, data: APIModalSubmitInteraction) {
- super(client, data);
- }
-}
-
-export interface BushModalSubmitInteraction<Cached extends CacheType = CacheType> extends ModalSubmitInteraction<Cached> {
- get channel(): CacheTypeReducer<
- Cached,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushTextBasedChannel | null
- >;
- get guild(): CacheTypeReducer<Cached, BushGuild, null>;
- inGuild(): this is BushModalSubmitInteraction<'raw' | 'cached'>;
- inCachedGuild(): this is BushModalSubmitInteraction<'cached'>;
- inRawGuild(): this is BushModalSubmitInteraction<'raw'>;
- isFromMessage(): this is BushModalMessageModalSubmitInteraction<Cached>;
-}
-
-export interface BushModalMessageModalSubmitInteraction<Cached extends CacheType = CacheType>
- extends ModalSubmitInteraction<Cached> {
- /**
- * The message associated with this interaction
- */
- message: BushGuildCacheMessage<Cached>;
-
- /**
- * Updates the original message of the component on which the interaction was received on.
- * @param options The options for the updated message
- * @example
- * // Remove the components from the message
- * interaction.update({
- * content: "A component interaction was received",
- * components: []
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<BushGuildCacheMessage<Cached>>;
- update(options: string | MessagePayload | InteractionUpdateOptions): Promise<InteractionResponse>;
-
- /**
- * Defers an update to the message to which the component was attached.
- * @param options Options for deferring the update to this interaction
- * @example
- * // Defer updating and reset the component's loading state
- * interaction.deferUpdate()
- * .then(console.log)
- * .catch(console.error);
- */
- deferUpdate(options: InteractionDeferUpdateOptions & { fetchReply: true }): Promise<BushGuildCacheMessage<Cached>>;
- deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse>;
-
- /**
- * Indicates whether this interaction is received from a guild.
- */
- inGuild(): this is BushModalMessageModalSubmitInteraction<'raw' | 'cached'>;
-
- /**
- * Indicates whether or not this interaction is both cached and received from a guild.
- */
- inCachedGuild(): this is BushModalMessageModalSubmitInteraction<'cached'>;
-
- /**
- * Indicates whether or not this interaction is received from an uncached guild.
- */
- inRawGuild(): this is BushModalMessageModalSubmitInteraction<'raw'>;
-}
diff --git a/src/lib/extensions/discord.js/BushNewsChannel.ts b/src/lib/extensions/discord.js/BushNewsChannel.ts
deleted file mode 100644
index e262188..0000000
--- a/src/lib/extensions/discord.js/BushNewsChannel.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { BushGuild, BushGuildMember, BushMessageManager, BushThreadManager } from '#lib';
-import { NewsChannel, type AllowedThreadTypeForNewsChannel, type Collection, type Snowflake } from 'discord.js';
-
-/**
- * Represents a guild news channel on Discord.
- */
-export class BushNewsChannel extends NewsChannel {
- public declare threads: BushThreadManager<AllowedThreadTypeForNewsChannel>;
- public declare guild: BushGuild;
- public declare messages: BushMessageManager;
-}
-
-export interface BushNewsChannel extends NewsChannel {
- get members(): Collection<Snowflake, BushGuildMember>;
-}
diff --git a/src/lib/extensions/discord.js/BushPresence.ts b/src/lib/extensions/discord.js/BushPresence.ts
deleted file mode 100644
index 40873ac..0000000
--- a/src/lib/extensions/discord.js/BushPresence.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember, BushUser } from '#lib';
-import { Presence } from 'discord.js';
-import type { RawPresenceData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a user's presence.
- */
-export class BushPresence extends Presence {
- public declare guild: BushGuild | null;
-
- public constructor(client: BushClient, data?: RawPresenceData) {
- super(client, data);
- }
-}
-
-export interface BushPresence extends Presence {
- get member(): BushGuildMember | null;
- get user(): BushUser | null;
-}
diff --git a/src/lib/extensions/discord.js/BushReactionEmoji.ts b/src/lib/extensions/discord.js/BushReactionEmoji.ts
deleted file mode 100644
index b2a7eb0..0000000
--- a/src/lib/extensions/discord.js/BushReactionEmoji.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import type { BushMessageReaction } from '#lib';
-import { ReactionEmoji } from 'discord.js';
-import type { RawReactionEmojiData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a limited emoji set used for both custom and unicode emojis. Custom emojis
- * will use this class opposed to the Emoji class when the client doesn't know enough
- * information about them.
- */
-export class BushReactionEmoji extends ReactionEmoji {
- public declare reaction: BushMessageReaction;
-
- public constructor(reaction: BushMessageReaction, emoji: RawReactionEmojiData) {
- super(reaction, emoji);
- }
-}
diff --git a/src/lib/extensions/discord.js/BushRole.ts b/src/lib/extensions/discord.js/BushRole.ts
deleted file mode 100644
index a9575bd..0000000
--- a/src/lib/extensions/discord.js/BushRole.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember } from '#lib';
-import { Role, type Collection, type Snowflake } from 'discord.js';
-import type { RawRoleData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a role on Discord.
- */
-export class BushRole extends Role {
- public declare guild: BushGuild;
-
- public constructor(client: BushClient, data: RawRoleData, guild: BushGuild) {
- super(client, data, guild);
- }
-}
-
-export interface BushRole extends Role {
- get members(): Collection<Snowflake, BushGuildMember>;
-}
diff --git a/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts b/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts
deleted file mode 100644
index 66a5ea9..0000000
--- a/src/lib/extensions/discord.js/BushSelectMenuInteraction.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember, BushGuildTextBasedChannel, BushTextBasedChannel, BushUser } from '#lib';
-import type { APIInteractionGuildMember } from 'discord-api-types/v10';
-import { SelectMenuInteraction, type CacheType, type CacheTypeReducer } from 'discord.js';
-import type { RawMessageSelectMenuInteractionData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a select menu interaction.
- */
-export class BushSelectMenuInteraction<Cached extends CacheType = CacheType> extends SelectMenuInteraction<Cached> {
- public declare member: CacheTypeReducer<Cached, BushGuildMember, APIInteractionGuildMember>;
- public declare user: BushUser;
-
- public constructor(client: BushClient, data: RawMessageSelectMenuInteractionData) {
- super(client, data);
- }
-}
-
-export interface BushSelectMenuInteraction<Cached extends CacheType = CacheType> extends SelectMenuInteraction<Cached> {
- get channel(): CacheTypeReducer<
- Cached,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushGuildTextBasedChannel | null,
- BushTextBasedChannel | null
- >;
- get guild(): CacheTypeReducer<Cached, BushGuild, null>;
- inGuild(): this is BushSelectMenuInteraction<'raw' | 'cached'>;
- inCachedGuild(): this is BushSelectMenuInteraction<'cached'>;
- inRawGuild(): this is BushSelectMenuInteraction<'raw'>;
-}
diff --git a/src/lib/extensions/discord.js/BushStageChannel.ts b/src/lib/extensions/discord.js/BushStageChannel.ts
deleted file mode 100644
index 983bd56..0000000
--- a/src/lib/extensions/discord.js/BushStageChannel.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { BushCategoryChannel, BushGuild, BushGuildMember, BushStageInstance } from '#lib';
-import { StageChannel, type Collection, type Snowflake } from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a guild stage channel on Discord.
- */
-export class BushStageChannel extends StageChannel {
- public declare guild: BushGuild;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData) {
- super(guild, data);
- }
-}
-
-export interface BushStageChannel extends StageChannel {
- get members(): Collection<Snowflake, BushGuildMember>;
- get parent(): BushCategoryChannel | null;
- get stageInstance(): BushStageInstance | null;
-}
diff --git a/src/lib/extensions/discord.js/BushStageInstance.ts b/src/lib/extensions/discord.js/BushStageInstance.ts
deleted file mode 100644
index 96453a7..0000000
--- a/src/lib/extensions/discord.js/BushStageInstance.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { BushClient, BushGuild, BushStageChannel } from '#lib';
-import { StageInstance } from 'discord.js';
-import type { RawStageInstanceData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a stage instance.
- */
-export class BushStageInstance extends StageInstance {
- public constructor(client: BushClient, data: RawStageInstanceData, channel: BushStageChannel) {
- super(client, data, channel);
- }
-}
-
-export interface BushStageInstance extends StageInstance {
- get channel(): BushStageChannel | null;
- get guild(): BushGuild | null;
-}
diff --git a/src/lib/extensions/discord.js/BushTextChannel.ts b/src/lib/extensions/discord.js/BushTextChannel.ts
deleted file mode 100644
index 575de20..0000000
--- a/src/lib/extensions/discord.js/BushTextChannel.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import type {
- BushCategoryChannel,
- BushDMChannel,
- BushGuild,
- BushGuildBasedChannel,
- BushMessageManager,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushThreadChannel,
- BushThreadManager,
- BushVoiceBasedChannel,
- BushVoiceChannel
-} from '#lib';
-import { PartialGroupDMChannel, TextChannel, type AllowedThreadTypeForTextChannel } from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a guild text channel on Discord.
- */
-export class BushTextChannel extends TextChannel {
- public declare guild: BushGuild;
- public declare messages: BushMessageManager;
- public declare threads: BushThreadManager<AllowedThreadTypeForTextChannel>;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData) {
- super(guild, data);
- }
-}
-
-export interface BushTextChannel extends TextChannel {
- isText(): this is BushTextChannel;
- isDM(): this is BushDMChannel;
- isDMBased(): this is PartialGroupDMChannel | BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushGuildBasedChannel & BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushThreadChannel.ts b/src/lib/extensions/discord.js/BushThreadChannel.ts
deleted file mode 100644
index 8b941f9..0000000
--- a/src/lib/extensions/discord.js/BushThreadChannel.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import type {
- BushCategoryChannel,
- BushClient,
- BushDMChannel,
- BushGuild,
- BushGuildBasedChannel,
- BushGuildMember,
- BushMessageManager,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadMemberManager,
- BushVoiceBasedChannel,
- BushVoiceChannel
-} from '#lib';
-import { PartialGroupDMChannel, ThreadChannel, type Collection, type Snowflake } from 'discord.js';
-import type { RawThreadChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a thread channel on Discord.
- */
-export class BushThreadChannel extends ThreadChannel {
- public declare guild: BushGuild;
- public declare messages: BushMessageManager;
- public declare members: BushThreadMemberManager;
- public declare readonly client: BushClient;
-
- public constructor(guild: BushGuild, data?: RawThreadChannelData, client?: BushClient, fromInteraction?: boolean) {
- super(guild, data, client, fromInteraction);
- }
-}
-
-export interface BushThreadChannel extends ThreadChannel {
- get guildMembers(): Collection<Snowflake, BushGuildMember>;
- get parent(): BushTextChannel | BushNewsChannel | null;
- isText(): this is BushTextChannel;
- isDM(): this is BushDMChannel;
- isDMBased(): this is PartialGroupDMChannel | BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushGuildBasedChannel & BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushThreadManager.ts b/src/lib/extensions/discord.js/BushThreadManager.ts
deleted file mode 100644
index 0748a4d..0000000
--- a/src/lib/extensions/discord.js/BushThreadManager.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import type { BushFetchedThreads, BushThreadChannel } from '#lib';
-import {
- CachedManager,
- NewsChannel,
- TextChannel,
- ThreadManager,
- type BaseFetchOptions,
- type FetchArchivedThreadOptions,
- type FetchThreadsOptions,
- type Snowflake,
- type ThreadChannelResolvable,
- type ThreadCreateOptions
-} from 'discord.js';
-import type { RawThreadChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for {@link BushThreadChannel} objects and stores their cache.
- */
-export declare class BushThreadManager<AllowedThreadType>
- extends CachedManager<Snowflake, BushThreadChannel, ThreadChannelResolvable>
- implements ThreadManager<AllowedThreadType>
-{
- public constructor(channel: TextChannel | NewsChannel, iterable?: Iterable<RawThreadChannelData>);
-
- /**
- * The channel this Manager belongs to
- */
- public channel: TextChannel | NewsChannel;
-
- /**
- * Creates a new thread in the channel.
- * @param options Options to create a new thread
- * @example
- * // Create a new public thread
- * channel.threads
- * .create({
- * name: 'food-talk',
- * autoArchiveDuration: 60,
- * reason: 'Needed a separate thread for food',
- * })
- * .then(threadChannel => console.log(threadChannel))
- * .catch(console.error);
- * @example
- * // Create a new private thread
- * channel.threads
- * .create({
- * name: 'mod-talk',
- * autoArchiveDuration: 60,
- * type: 'GuildPrivateThread',
- * reason: 'Needed a separate thread for moderation',
- * })
- * .then(threadChannel => console.log(threadChannel))
- * .catch(console.error);
- */
- public create(options: ThreadCreateOptions<AllowedThreadType>): Promise<BushThreadChannel>;
-
- /**
- * Obtains a thread from Discord, or the channel cache if it's already available.
- * @param options The options to fetch threads. If it is a
- * ThreadChannelResolvable then the specified thread will be fetched. Fetches all active threads if `undefined`
- * @param cacheOptions Additional options for this fetch. <warn>The `force` field gets ignored
- * if `options` is not a {@link ThreadChannelResolvable}</warn>
- * @example
- * // Fetch a thread by its id
- * channel.threads.fetch('831955138126104859')
- * .then(channel => console.log(channel.name))
- * .catch(console.error);
- */
- public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<BushThreadChannel | null>;
- public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise<BushFetchedThreads>;
-
- /**
- * Obtains a set of archived threads from Discord, requires `READ_MESSAGE_HISTORY` in the parent channel.
- * @param options The options to fetch archived threads
- * @param cache Whether to cache the new thread objects if they aren't already
- */
- public fetchArchived(options?: FetchArchivedThreadOptions, cache?: boolean): Promise<BushFetchedThreads>;
-
- /**
- * Obtains the accessible active threads from Discord, requires `READ_MESSAGE_HISTORY` in the parent channel.
- * @param cache Whether to cache the new thread objects if they aren't already
- */
- public fetchActive(cache?: boolean): Promise<BushFetchedThreads>;
-}
diff --git a/src/lib/extensions/discord.js/BushThreadMember.ts b/src/lib/extensions/discord.js/BushThreadMember.ts
deleted file mode 100644
index 90c9c9b..0000000
--- a/src/lib/extensions/discord.js/BushThreadMember.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { BushGuildMember, BushThreadChannel, BushUser } from '#lib';
-import { ThreadMember } from 'discord.js';
-import type { RawThreadMemberData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a Member for a Thread.
- */
-export class BushThreadMember extends ThreadMember {
- public declare thread: BushThreadChannel;
-
- public constructor(thread: BushThreadChannel, data?: RawThreadMemberData) {
- super(thread, data);
- }
-}
-
-export interface BushThreadMember extends ThreadMember {
- get guildMember(): BushGuildMember | null;
- get user(): BushUser | null;
-}
diff --git a/src/lib/extensions/discord.js/BushThreadMemberManager.ts b/src/lib/extensions/discord.js/BushThreadMemberManager.ts
deleted file mode 100644
index d183b30..0000000
--- a/src/lib/extensions/discord.js/BushThreadMemberManager.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import type { BushClient, BushThreadChannel, BushThreadMember, BushThreadMemberResolvable, BushUserResolvable } from '#lib';
-import {
- CachedManager,
- ThreadMemberManager,
- type BaseFetchOptions,
- type Collection,
- type Snowflake,
- type UserResolvable
-} from 'discord.js';
-import type { RawThreadMemberData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for GuildMembers and stores their cache.
- */
-export declare class BushThreadMemberManager
- extends CachedManager<Snowflake, BushThreadMember, BushThreadMemberResolvable>
- implements ThreadMemberManager
-{
- public constructor(thread: BushThreadChannel, iterable?: Iterable<RawThreadMemberData>);
- public declare readonly client: BushClient;
-
- /**
- * The thread this manager belongs to
- */
- public thread: BushThreadChannel;
-
- /**
- * Adds a member to the thread.
- * @param member The member to add
- * @param reason The reason for adding this member
- */
- public add(member: UserResolvable | '@me', reason?: string): Promise<Snowflake>;
-
- /**
- * Fetches member(s) for the thread from Discord, requires access to the `GatewayIntentBits.GuildMembers` gateway intent.
- * @param options Additional options for this fetch, when a `boolean` is provided
- * all members are fetched with `options.cache` set to the boolean value
- */
- public fetch(options?: BushThreadMemberFetchOptions): Promise<BushThreadMember>;
- public fetch(cache?: boolean): Promise<Collection<Snowflake, BushThreadMember>>;
-
- /**
- * Remove a user from the thread.
- * @param id The id of the member to remove
- * @param reason The reason for removing this member from the thread
- */
- public remove(id: Snowflake | '@me', reason?: string): Promise<Snowflake>;
-}
-
-export interface BushThreadMemberManager extends CachedManager<Snowflake, BushThreadMember, BushThreadMemberResolvable> {
- /**
- * The client user as a ThreadMember of this ThreadChannel
- */
- get me(): BushThreadMember | null;
-}
-
-export interface BushThreadMemberFetchOptions extends BaseFetchOptions {
- /**
- * The specific user to fetch from the thread
- */
- member?: BushUserResolvable;
-}
diff --git a/src/lib/extensions/discord.js/BushUser.ts b/src/lib/extensions/discord.js/BushUser.ts
deleted file mode 100644
index 27ef2b2..0000000
--- a/src/lib/extensions/discord.js/BushUser.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import type { BushClient, BushDMChannel } from '#lib';
-import { User, type Partialize } from 'discord.js';
-import type { RawUserData } from 'discord.js/typings/rawDataTypes';
-
-export type PartialBushUser = Partialize<BushUser, 'username' | 'tag' | 'discriminator' | 'isOwner' | 'isSuperUser'>;
-
-/**
- * Represents a user on Discord.
- */
-export class BushUser extends User {
- public declare readonly client: BushClient;
-
- public constructor(client: BushClient, data: RawUserData) {
- super(client, data);
- }
-
- /**
- * Indicates whether the user is an owner of the bot.
- */
- public isOwner(): boolean {
- return client.isOwner(this);
- }
-
- /**
- * Indicates whether the user is a superuser of the bot.
- */
- public isSuperUser(): boolean {
- return client.isSuperUser(this);
- }
-}
-
-export interface BushUser extends User {
- get dmChannel(): BushDMChannel | null;
-}
diff --git a/src/lib/extensions/discord.js/BushUserManager.ts b/src/lib/extensions/discord.js/BushUserManager.ts
deleted file mode 100644
index c26dbde..0000000
--- a/src/lib/extensions/discord.js/BushUserManager.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import type { BushClient, BushDMChannel, BushUser, BushUserResolvable } from '#lib';
-import {
- CachedManager,
- Message,
- MessageOptions,
- MessagePayload,
- UserFlagsBitField,
- UserManager,
- type BaseFetchOptions,
- type Snowflake
-} from 'discord.js';
-import type { RawUserData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Manages API methods for users and stores their cache.
- */
-export declare class BushUserManager extends CachedManager<Snowflake, BushUser, BushUserResolvable> implements UserManager {
- private constructor(client: BushClient, iterable?: Iterable<RawUserData>);
-
- /**
- * The DM between the client's user and a user
- * @param userId The user id
- * @private
- */
- public dmChannel(userId: Snowflake): BushDMChannel | null;
-
- /**
- * Creates a {@link BushDMChannel} between the client and a user.
- * @param user The UserResolvable to identify
- * @param options Additional options for this fetch
- */
- public createDM(user: BushUserResolvable, options?: BaseFetchOptions): Promise<BushDMChannel>;
-
- /**
- * Deletes a {@link BushDMChannel} (if one exists) between the client and a user. Resolves with the channel if successful.
- * @param user The UserResolvable to identify
- */
- public deleteDM(user: BushUserResolvable): Promise<BushDMChannel>;
-
- /**
- * Obtains a user from Discord, or the user cache if it's already available.
- * @param user The user to fetch
- * @param options Additional options for this fetch
- */
- public fetch(user: BushUserResolvable, options?: BaseFetchOptions): Promise<BushUser>;
-
- /**
- * Fetches a user's flags.
- * @param user The UserResolvable to identify
- * @param options Additional options for this fetch
- */
- public fetchFlags(user: BushUserResolvable, options?: BaseFetchOptions): Promise<UserFlagsBitField>;
-
- /**
- * Sends a message to a user.
- * @param user The UserResolvable to identify
- * @param options The options to provide
- */
- public send(user: BushUserResolvable, options: string | MessagePayload | MessageOptions): Promise<Message>;
-}
diff --git a/src/lib/extensions/discord.js/BushVoiceChannel.ts b/src/lib/extensions/discord.js/BushVoiceChannel.ts
deleted file mode 100644
index 6966727..0000000
--- a/src/lib/extensions/discord.js/BushVoiceChannel.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import type {
- BushCategoryChannel,
- BushClient,
- BushDMChannel,
- BushGuild,
- BushGuildBasedChannel,
- BushGuildMember,
- BushNewsChannel,
- BushStageChannel,
- BushTextBasedChannel,
- BushTextChannel,
- BushThreadChannel,
- BushVoiceBasedChannel
-} from '#lib';
-import { VoiceChannel, type Collection, type Snowflake } from 'discord.js';
-import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents a guild voice channel on Discord.
- */
-export class BushVoiceChannel extends VoiceChannel {
- public declare readonly client: BushClient;
-
- public constructor(guild: BushGuild, data?: RawGuildChannelData) {
- super(guild, data);
- }
-}
-
-export interface BushVoiceChannel extends VoiceChannel {
- get members(): Collection<Snowflake, BushGuildMember>;
- isText(): this is BushTextChannel;
- isDM(): this is BushDMChannel;
- isVoice(): this is BushVoiceChannel;
- isCategory(): this is BushCategoryChannel;
- isNews(): this is BushNewsChannel;
- isThread(): this is BushThreadChannel;
- isStage(): this is BushStageChannel;
- isTextBased(): this is BushGuildBasedChannel & BushTextBasedChannel;
- isVoiceBased(): this is BushVoiceBasedChannel;
-}
diff --git a/src/lib/extensions/discord.js/BushVoiceState.ts b/src/lib/extensions/discord.js/BushVoiceState.ts
deleted file mode 100644
index bbcdfa8..0000000
--- a/src/lib/extensions/discord.js/BushVoiceState.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { BushClient, BushGuild, BushGuildMember, BushVoiceBasedChannel } from '#lib';
-import { VoiceState } from 'discord.js';
-import type { RawVoiceStateData } from 'discord.js/typings/rawDataTypes';
-
-/**
- * Represents the voice state for a Guild Member.
- */
-export class BushVoiceState extends VoiceState {
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
-
- public constructor(guild: BushGuild, data: RawVoiceStateData) {
- super(guild, data);
- }
-}
-
-export interface BushVoiceState extends VoiceState {
- get channel(): BushVoiceBasedChannel | null;
- get getmember(): BushGuildMember | null;
-}
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/ExtendedGuild.ts
index a93e35f..b8b7b22 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/ExtendedGuild.ts
@@ -1,65 +1,146 @@
import {
AllowedMentions,
banResponse,
- BushGuildChannelManager,
- BushGuildMemberManager,
- BushMessage,
- BushVoiceChannel,
dmResponse,
permissionsResponse,
punishmentEntryRemove,
type BanResponse,
- type BushClient,
- type BushGuildMember,
- type BushGuildMemberResolvable,
- type BushNewsChannel,
- type BushTextChannel,
- type BushThreadChannel,
- type BushUser,
- type BushUserResolvable,
type GuildFeatures,
type GuildLogType,
type GuildModel
} from '#lib';
-import { APIMessage } from 'discord-api-types/v10';
import {
+ AttachmentBuilder,
+ AttachmentPayload,
Collection,
Guild,
+ JSONEncodable,
+ Message,
MessageType,
PermissionFlagsBits,
SnowflakeUtil,
ThreadChannel,
- Webhook,
- WebhookMessageOptions,
+ type APIMessage,
+ type GuildMember,
+ type GuildMemberResolvable,
+ type GuildTextBasedChannel,
type MessageOptions,
type MessagePayload,
- type Snowflake
+ type NewsChannel,
+ type Snowflake,
+ type TextChannel,
+ type User,
+ type UserResolvable,
+ type VoiceChannel,
+ type Webhook,
+ type WebhookMessageOptions
} from 'discord.js';
-import type { RawGuildData } from 'discord.js/typings/rawDataTypes';
import _ from 'lodash';
import { Moderation } from '../../common/util/Moderation.js';
import { Guild as GuildDB } from '../../models/instance/Guild.js';
import { ModLogType } from '../../models/instance/ModLog.js';
+declare module 'discord.js' {
+ export interface Guild {
+ /**
+ * Checks if the guild has a certain custom feature.
+ * @param feature The feature to check for
+ */
+ hasFeature(feature: GuildFeatures): Promise<boolean>;
+ /**
+ * Adds a custom feature to the guild.
+ * @param feature The feature to add
+ * @param moderator The moderator responsible for adding a feature
+ */
+ addFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildDB['enabledFeatures']>;
+ /**
+ * Removes a custom feature from the guild.
+ * @param feature The feature to remove
+ * @param moderator The moderator responsible for removing a feature
+ */
+ removeFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildDB['enabledFeatures']>;
+ /**
+ * Makes a custom feature the opposite of what it was before
+ * @param feature The feature to toggle
+ * @param moderator The moderator responsible for toggling a feature
+ */
+ toggleFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildDB['enabledFeatures']>;
+ /**
+ * Fetches a custom setting for the guild
+ * @param setting The setting to get
+ */
+ getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]>;
+ /**
+ * Sets a custom setting for the guild
+ * @param setting The setting to change
+ * @param value The value to change the setting to
+ * @param moderator The moderator to responsible for changing the setting
+ */
+ setSetting<K extends Exclude<keyof GuildModel, 'id'>>(
+ setting: K,
+ value: GuildModel[K],
+ moderator?: GuildMember
+ ): Promise<GuildModel>;
+ /**
+ * Get a the log channel configured for a certain log type.
+ * @param logType The type of log channel to get.
+ * @returns Either the log channel or undefined if not configured.
+ */
+ getLogChannel(logType: GuildLogType): Promise<TextChannel | undefined>;
+ /**
+ * Sends a message to the guild's specified logging channel
+ * @param logType The corresponding channel that the message will be sent to
+ * @param message The parameters for {@link BushTextChannel.send}
+ */
+ sendLogChannel(logType: GuildLogType, message: string | MessagePayload | MessageOptions): Promise<Message | null | undefined>;
+ /**
+ * Sends a formatted error message in a guild's error log channel
+ * @param title The title of the error embed
+ * @param message The description of the error embed
+ */
+ error(title: string, message: string): Promise<void>;
+ /**
+ * Bans a user, dms them, creates a mod log entry, and creates a punishment entry.
+ * @param options Options for banning the user.
+ * @returns A string status message of the ban.
+ */
+ bushBan(options: GuildBushBanOptions): Promise<BanResponse>;
+ /**
+ * {@link bushBan} with less resolving and checks
+ * @param options Options for banning the user.
+ * @returns A string status message of the ban.
+ * **Preconditions:**
+ * - {@link me} has the `BanMembers` permission
+ * **Warning:**
+ * - Doesn't emit bushBan Event
+ */
+ massBanOne(options: GuildMassBanOneOptions): Promise<BanResponse>;
+ /**
+ * Unbans a user, dms them, creates a mod log entry, and destroys the punishment entry.
+ * @param options Options for unbanning the user.
+ * @returns A status message of the unban.
+ */
+ bushUnban(options: GuildBushUnbanOptions): Promise<UnbanResponse>;
+ /**
+ * Denies send permissions in specified channels
+ * @param options The options for locking down the guild
+ */
+ lockdown(options: LockdownOptions): Promise<LockdownResponse>;
+ quote(rawQuote: APIMessage, channel: GuildTextBasedChannel): Promise<Message | null>;
+ }
+}
+
/**
* Represents a guild (or a server) on Discord.
* <info>It's recommended to see if a guild is available before performing operations or reading data from it. You can
- * check this with {@link BushGuild.available}.</info>
+ * check this with {@link ExtendedGuild.available}.</info>
*/
-export class BushGuild extends Guild {
- public declare readonly client: BushClient;
- public declare members: BushGuildMemberManager;
- public declare channels: BushGuildChannelManager;
-
- public constructor(client: BushClient, data: RawGuildData) {
- super(client, data);
- }
-
+export class ExtendedGuild extends Guild {
/**
* Checks if the guild has a certain custom feature.
* @param feature The feature to check for
*/
- public async hasFeature(feature: GuildFeatures): Promise<boolean> {
+ public override async hasFeature(feature: GuildFeatures): Promise<boolean> {
const features = await this.getSetting('enabledFeatures');
return features.includes(feature);
}
@@ -69,7 +150,7 @@ export class BushGuild extends Guild {
* @param feature The feature to add
* @param moderator The moderator responsible for adding a feature
*/
- public async addFeature(feature: GuildFeatures, moderator?: BushGuildMember): Promise<GuildModel['enabledFeatures']> {
+ public override async addFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildModel['enabledFeatures']> {
const features = await this.getSetting('enabledFeatures');
const newFeatures = util.addOrRemoveFromArray('add', features, feature);
return (await this.setSetting('enabledFeatures', newFeatures, moderator)).enabledFeatures;
@@ -80,7 +161,7 @@ export class BushGuild extends Guild {
* @param feature The feature to remove
* @param moderator The moderator responsible for removing a feature
*/
- public async removeFeature(feature: GuildFeatures, moderator?: BushGuildMember): Promise<GuildModel['enabledFeatures']> {
+ public override async removeFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildModel['enabledFeatures']> {
const features = await this.getSetting('enabledFeatures');
const newFeatures = util.addOrRemoveFromArray('remove', features, feature);
return (await this.setSetting('enabledFeatures', newFeatures, moderator)).enabledFeatures;
@@ -91,7 +172,7 @@ export class BushGuild extends Guild {
* @param feature The feature to toggle
* @param moderator The moderator responsible for toggling a feature
*/
- public async toggleFeature(feature: GuildFeatures, moderator?: BushGuildMember): Promise<GuildModel['enabledFeatures']> {
+ public override async toggleFeature(feature: GuildFeatures, moderator?: GuildMember): Promise<GuildModel['enabledFeatures']> {
return (await this.hasFeature(feature))
? await this.removeFeature(feature, moderator)
: await this.addFeature(feature, moderator);
@@ -101,7 +182,7 @@ export class BushGuild extends Guild {
* Fetches a custom setting for the guild
* @param setting The setting to get
*/
- public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
+ public override async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
return (
client.cache.guilds.get(this.id)?.[setting] ??
((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }))[setting]
@@ -114,10 +195,10 @@ export class BushGuild extends Guild {
* @param value The value to change the setting to
* @param moderator The moderator to responsible for changing the setting
*/
- public async setSetting<K extends Exclude<keyof GuildModel, 'id'>>(
+ public override async setSetting<K extends Exclude<keyof GuildModel, 'id'>>(
setting: K,
value: GuildDB[K],
- moderator?: BushGuildMember
+ moderator?: GuildMember
): Promise<GuildDB> {
const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id });
const oldValue = row[setting] as GuildDB[K];
@@ -132,12 +213,12 @@ export class BushGuild extends Guild {
* @param logType The type of log channel to get.
* @returns Either the log channel or undefined if not configured.
*/
- public async getLogChannel(logType: GuildLogType): Promise<BushTextChannel | undefined> {
+ public override async getLogChannel(logType: GuildLogType): Promise<TextChannel | undefined> {
const channelId = (await this.getSetting('logChannels'))[logType];
if (!channelId) return undefined;
return (
- (this.channels.cache.get(channelId) as BushTextChannel | undefined) ??
- ((await this.channels.fetch(channelId)) as BushTextChannel | null) ??
+ (this.channels.cache.get(channelId) as TextChannel | undefined) ??
+ ((await this.channels.fetch(channelId)) as TextChannel | null) ??
undefined
);
}
@@ -147,7 +228,10 @@ export class BushGuild extends Guild {
* @param logType The corresponding channel that the message will be sent to
* @param message The parameters for {@link BushTextChannel.send}
*/
- public async sendLogChannel(logType: GuildLogType, message: string | MessagePayload | MessageOptions) {
+ public override async sendLogChannel(
+ logType: GuildLogType,
+ message: string | MessagePayload | MessageOptions
+ ): Promise<Message | null | undefined> {
const logChannel = await this.getLogChannel(logType);
if (!logChannel || !logChannel.isTextBased()) return;
if (
@@ -165,7 +249,7 @@ export class BushGuild extends Guild {
* @param title The title of the error embed
* @param message The description of the error embed
*/
- public async error(title: string, message: string) {
+ public override async error(title: string, message: string): Promise<void> {
void client.console.info(_.camelCase(title), message.replace(/\*\*(.*?)\*\*/g, '<<$1>>'));
void this.sendLogChannel('error', { embeds: [{ title: title, description: message, color: util.colors.error }] });
}
@@ -175,7 +259,7 @@ export class BushGuild extends Guild {
* @param options Options for banning the user.
* @returns A string status message of the ban.
*/
- public async bushBan(options: GuildBushBanOptions): Promise<BanResponse> {
+ public override async bushBan(options: GuildBushBanOptions): Promise<BanResponse> {
// checks
if (!this.members.me!.permissions.has(PermissionFlagsBits.BanMembers)) return banResponse.MISSING_PERMISSIONS;
@@ -259,7 +343,7 @@ export class BushGuild extends Guild {
* **Warning:**
* - Doesn't emit bushBan Event
*/
- public async massBanOne(options: GuildMassBanOneOptions): Promise<BanResponse> {
+ public override async massBanOne(options: GuildMassBanOneOptions): Promise<BanResponse> {
if (this.bans.cache.has(options.user)) return banResponse.ALREADY_BANNED;
const ret = await (async () => {
@@ -318,7 +402,7 @@ export class BushGuild extends Guild {
* @param options Options for unbanning the user.
* @returns A status message of the unban.
*/
- public async bushUnban(options: GuildBushUnbanOptions): Promise<UnbanResponse> {
+ public override async bushUnban(options: GuildBushUnbanOptions): Promise<UnbanResponse> {
// checks
if (!this.members.me!.permissions.has(PermissionFlagsBits.BanMembers)) return unbanResponse.MISSING_PERMISSIONS;
@@ -391,7 +475,7 @@ export class BushGuild extends Guild {
* Denies send permissions in specified channels
* @param options The options for locking down the guild
*/
- public async lockdown(options: LockdownOptions): Promise<LockdownResponse> {
+ public override async lockdown(options: LockdownOptions): Promise<LockdownResponse> {
if (!options.all && !options.channel) return 'all not chosen and no channel specified';
const channelIds = options.all ? await this.getSetting('lockdownChannels') : [options.channel!.id];
@@ -466,11 +550,11 @@ export class BushGuild extends Guild {
return ret;
}
- public async quote(rawQuote: APIMessage, channel: BushTextChannel | BushNewsChannel | BushThreadChannel) {
+ public override async quote(rawQuote: APIMessage, channel: GuildTextBasedChannel): Promise<Message | null> {
if (!channel.isTextBased() || channel.isDMBased() || channel.guildId !== this.id || !this.members.me) return null;
if (!channel.permissionsFor(this.members.me).has('ManageWebhooks')) return null;
- const quote = new BushMessage(client, rawQuote);
+ const quote = new Message(client, rawQuote);
const target = channel instanceof ThreadChannel ? channel.parent : channel;
if (!target) return null;
@@ -482,7 +566,8 @@ export class BushGuild extends Guild {
let webhook = webhooks.find((w) => !!w.token) ?? null;
if (!webhook)
webhook = await target
- .createWebhook(`${client.user!.username} Quotes #${target.name}`, {
+ .createWebhook({
+ name: `${client.user!.username} Quotes #${target.name}`,
avatar: client.user!.displayAvatarURL({ size: 2048 }),
reason: 'Creating a webhook for quoting'
})
@@ -503,7 +588,10 @@ export class BushGuild extends Guild {
sendOptions.content = quote.content || undefined;
sendOptions.threadId = channel instanceof ThreadChannel ? channel.id : undefined;
sendOptions.embeds = quote.embeds.length ? quote.embeds : undefined;
- sendOptions.attachments = quote.attachments.size ? [...quote.attachments.values()] : undefined;
+ //@ts-expect-error: jank
+ sendOptions.attachments = quote.attachments.size
+ ? [...quote.attachments.values()].map((a) => AttachmentBuilder.from(a as JSONEncodable<AttachmentPayload>))
+ : undefined;
if (quote.stickers.size && !(quote.content || quote.embeds.length || quote.attachments.size))
sendOptions.content = '[[This message has a sticker but not content]]';
@@ -651,7 +739,7 @@ export interface GuildBushUnbanOptions {
/**
* The user to unban
*/
- user: BushUserResolvable | BushUser;
+ user: UserResolvable | User;
/**
* The reason for unbanning the user
@@ -661,7 +749,7 @@ export interface GuildBushUnbanOptions {
/**
* The moderator who unbanned the user
*/
- moderator?: BushUserResolvable;
+ moderator?: UserResolvable;
/**
* The evidence for the unban
@@ -698,7 +786,7 @@ export interface GuildBushBanOptions {
/**
* The user to ban
*/
- user: BushUserResolvable;
+ user: UserResolvable;
/**
* The reason to ban the user
@@ -708,7 +796,7 @@ export interface GuildBushBanOptions {
/**
* The moderator who banned the user
*/
- moderator?: BushUserResolvable;
+ moderator?: UserResolvable;
/**
* The duration of the ban
@@ -747,7 +835,7 @@ export interface LockdownOptions {
/**
* The moderator responsible for the lockdown
*/
- moderator: BushGuildMemberResolvable;
+ moderator: GuildMemberResolvable;
/**
* Whether to lock down all (specified) channels
@@ -762,7 +850,7 @@ export interface LockdownOptions {
/**
* A specific channel to lockdown
*/
- channel?: BushThreadChannel | BushNewsChannel | BushTextChannel | BushVoiceChannel;
+ channel?: ThreadChannel | NewsChannel | TextChannel | VoiceChannel;
/**
* Whether or not to unlock the channel(s) instead of locking them
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/ExtendedGuildMember.ts
index 20a1f60..28acc1a 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/ExtendedGuildMember.ts
@@ -1,44 +1,127 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
+import { BushClientEvents, Moderation, ModLogType, PunishmentTypeDM, Time } from '#lib';
import {
- BushClientEvents,
- Moderation,
- ModLogType,
- PunishmentTypeDM,
- Time,
- type BushClient,
- type BushGuild,
- type BushGuildTextBasedChannel,
- type BushGuildTextChannelResolvable,
- type BushRole,
- type BushThreadChannelResolvable,
- type BushUser
-} from '#lib';
-import { GuildMember, PermissionFlagsBits, type Partialize, type Role } from 'discord.js';
-import type { RawGuildMemberData } from 'discord.js/typings/rawDataTypes';
+ ChannelType,
+ GuildChannelResolvable,
+ GuildMember,
+ GuildTextBasedChannel,
+ PermissionFlagsBits,
+ type Role
+} from 'discord.js';
/* eslint-enable @typescript-eslint/no-unused-vars */
+declare module 'discord.js' {
+ export interface GuildMember {
+ /**
+ * Send a punishment dm to the user.
+ * @param punishment The punishment that the user has received.
+ * @param reason The reason for the user's punishment.
+ * @param duration The duration of the punishment.
+ * @param modlog The modlog case id so the user can make an appeal.
+ * @param sendFooter Whether or not to send the guild's punishment footer with the dm.
+ * @returns Whether or not the dm was sent successfully.
+ */
+ bushPunishDM(
+ punishment: PunishmentTypeDM,
+ reason?: string | null,
+ duration?: number,
+ modlog?: string,
+ sendFooter?: boolean
+ ): Promise<boolean>;
+ /**
+ * Warn the user, create a modlog entry, and send a dm to the user.
+ * @param options Options for warning the user.
+ * @returns An object with the result of the warning, and the case number of the warn.
+ * @emits {@link BushClientEvents.bushWarn}
+ */
+ bushWarn(options: BushPunishmentOptions): Promise<{ result: WarnResponse; caseNum: number | null }>;
+ /**
+ * Add a role to the user, if it is a punishment create a modlog entry, and create a punishment entry if it is temporary or a punishment.
+ * @param options Options for adding a role to the user.
+ * @returns A status message for adding the add.
+ * @emits {@link BushClientEvents.bushPunishRole}
+ */
+ bushAddRole(options: AddRoleOptions): Promise<AddRoleResponse>;
+ /**
+ * Remove a role from the user, if it is a punishment create a modlog entry, and destroy a punishment entry if it was temporary or a punishment.
+ * @param options Options for removing a role from the user.
+ * @returns A status message for removing the role.
+ * @emits {@link BushClientEvents.bushPunishRoleRemove}
+ */
+ bushRemoveRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse>;
+ /**
+ * Mute the user, create a modlog entry, creates a punishment entry, and dms the user.
+ * @param options Options for muting the user.
+ * @returns A status message for muting the user.
+ * @emits {@link BushClientEvents.bushMute}
+ */
+ bushMute(options: BushTimedPunishmentOptions): Promise<MuteResponse>;
+ /**
+ * Unmute the user, create a modlog entry, remove the punishment entry, and dm the user.
+ * @param options Options for unmuting the user.
+ * @returns A status message for unmuting the user.
+ * @emits {@link BushClientEvents.bushUnmute}
+ */
+ bushUnmute(options: BushPunishmentOptions): Promise<UnmuteResponse>;
+ /**
+ * Kick the user, create a modlog entry, and dm the user.
+ * @param options Options for kicking the user.
+ * @returns A status message for kicking the user.
+ * @emits {@link BushClientEvents.bushKick}
+ */
+ bushKick(options: BushPunishmentOptions): Promise<KickResponse>;
+ /**
+ * Ban the user, create a modlog entry, create a punishment entry, and dm the user.
+ * @param options Options for banning the user.
+ * @returns A status message for banning the user.
+ * @emits {@link BushClientEvents.bushBan}
+ */
+ bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>>;
+ /**
+ * Prevents a user from speaking in a channel.
+ * @param options Options for blocking the user.
+ */
+ bushBlock(options: BlockOptions): Promise<BlockResponse>;
+ /**
+ * Allows a user to speak in a channel.
+ * @param options Options for unblocking the user.
+ */
+ bushUnblock(options: UnblockOptions): Promise<UnblockResponse>;
+ /**
+ * Mutes a user using discord's timeout feature.
+ * @param options Options for timing out the user.
+ */
+ bushTimeout(options: BushTimeoutOptions): Promise<TimeoutResponse>;
+ /**
+ * Removes a timeout from a user.
+ * @param options Options for removing the timeout.
+ */
+ bushRemoveTimeout(options: BushPunishmentOptions): Promise<RemoveTimeoutResponse>;
+ /**
+ * Whether or not the user is an owner of the bot.
+ */
+ isOwner(): boolean;
+ /**
+ * Whether or not the user is a super user of the bot.
+ */
+ isSuperUser(): boolean;
+ }
+}
+
/**
* Represents a member of a guild on Discord.
*/
-export class BushGuildMember extends GuildMember {
- public declare readonly client: BushClient;
- public declare guild: BushGuild;
- public declare user: BushUser;
-
- public constructor(client: BushClient, data: RawGuildMemberData, guild: BushGuild) {
- super(client, data, guild);
- }
-
+export class ExtendedGuildMember extends GuildMember {
/**
* Send a punishment dm to the user.
- * @param modlog The modlog case id so the user can make an appeal.
* @param punishment The punishment that the user has received.
* @param reason The reason for the user's punishment.
* @param duration The duration of the punishment.
+ * @param modlog The modlog case id so the user can make an appeal.
* @param sendFooter Whether or not to send the guild's punishment footer with the dm.
* @returns Whether or not the dm was sent successfully.
*/
- public async bushPunishDM(
+ public override async bushPunishDM(
punishment: PunishmentTypeDM,
reason?: string | null,
duration?: number,
@@ -62,7 +145,7 @@ export class BushGuildMember extends GuildMember {
* @returns An object with the result of the warning, and the case number of the warn.
* @emits {@link BushClientEvents.bushWarn}
*/
- public async bushWarn(options: BushPunishmentOptions): Promise<{ result: WarnResponse; caseNum: number | null }> {
+ public override async bushWarn(options: BushPunishmentOptions): Promise<{ result: WarnResponse; caseNum: number | null }> {
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
@@ -105,7 +188,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for adding the add.
* @emits {@link BushClientEvents.bushPunishRole}
*/
- public async bushAddRole(options: AddRoleOptions): Promise<AddRoleResponse> {
+ public override async bushAddRole(options: AddRoleOptions): Promise<AddRoleResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return addRoleResponse.MISSING_PERMISSIONS;
const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
@@ -164,7 +247,7 @@ export class BushGuildMember extends GuildMember {
options.reason ?? undefined,
caseID!,
options.duration ?? 0,
- options.role as BushRole,
+ options.role,
options.evidence
);
return ret;
@@ -176,7 +259,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for removing the role.
* @emits {@link BushClientEvents.bushPunishRoleRemove}
*/
- public async bushRemoveRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> {
+ public override async bushRemoveRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return removeRoleResponse.MISSING_PERMISSIONS;
const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
@@ -235,7 +318,7 @@ export class BushGuildMember extends GuildMember {
this.guild,
options.reason ?? undefined,
caseID!,
- options.role as BushRole,
+ options.role,
options.evidence
);
return ret;
@@ -248,8 +331,8 @@ export class BushGuildMember extends GuildMember {
* @returns `true` if the role should be added/removed or a string for the reason why it shouldn't.
*/
#checkIfShouldAddRole(
- role: BushRole | Role,
- moderator?: BushGuildMember
+ role: Role | Role,
+ moderator?: GuildMember
): true | 'user hierarchy' | 'role managed' | 'client hierarchy' {
if (moderator && moderator.roles.highest.position <= role.position && this.guild.ownerId !== this.user.id) {
return shouldAddRoleResponse.USER_HIERARCHY;
@@ -267,7 +350,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for muting the user.
* @emits {@link BushClientEvents.bushMute}
*/
- public async bushMute(options: BushTimedPunishmentOptions): Promise<MuteResponse> {
+ public override async bushMute(options: BushTimedPunishmentOptions): Promise<MuteResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return muteResponse.MISSING_PERMISSIONS;
const muteRoleID = await this.guild.getSetting('muteRole');
@@ -353,7 +436,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for unmuting the user.
* @emits {@link BushClientEvents.bushUnmute}
*/
- public async bushUnmute(options: BushPunishmentOptions): Promise<UnmuteResponse> {
+ public override async bushUnmute(options: BushPunishmentOptions): Promise<UnmuteResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return unmuteResponse.MISSING_PERMISSIONS;
const muteRoleID = await this.guild.getSetting('muteRole');
@@ -436,7 +519,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for kicking the user.
* @emits {@link BushClientEvents.bushKick}
*/
- public async bushKick(options: BushPunishmentOptions): Promise<KickResponse> {
+ public override async bushKick(options: BushPunishmentOptions): Promise<KickResponse> {
// checks
if (!this.guild.members.me?.permissions.has(PermissionFlagsBits.KickMembers) || !this.kickable)
return kickResponse.MISSING_PERMISSIONS;
@@ -490,7 +573,7 @@ export class BushGuildMember extends GuildMember {
* @returns A status message for banning the user.
* @emits {@link BushClientEvents.bushBan}
*/
- public async bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>> {
+ public override async bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.BanMembers) || !this.bannable)
return banResponse.MISSING_PERMISSIONS;
@@ -570,7 +653,7 @@ export class BushGuildMember extends GuildMember {
* Prevents a user from speaking in a channel.
* @param options Options for blocking the user.
*/
- public async bushBlock(options: BlockOptions): Promise<BlockResponse> {
+ public override async bushBlock(options: BlockOptions): Promise<BlockResponse> {
const channel = this.guild.channels.resolve(options.channel);
if (!channel || (!channel.isTextBased() && !channel.isThread())) return blockResponse.INVALID_CHANNEL;
@@ -660,10 +743,10 @@ export class BushGuildMember extends GuildMember {
* Allows a user to speak in a channel.
* @param options Options for unblocking the user.
*/
- public async bushUnblock(options: UnblockOptions): Promise<UnblockResponse> {
+ public override async bushUnblock(options: UnblockOptions): Promise<UnblockResponse> {
const _channel = this.guild.channels.resolve(options.channel);
- if (!_channel || (!_channel.isText() && !_channel.isThread())) return unblockResponse.INVALID_CHANNEL;
- const channel = _channel as BushGuildTextBasedChannel;
+ if (!_channel || (_channel.type !== ChannelType.GuildText && !_channel.isThread())) return unblockResponse.INVALID_CHANNEL;
+ const channel = _channel as GuildTextBasedChannel;
// checks
if (!channel.permissionsFor(this.guild.members.me!)!.has(PermissionFlagsBits.ManageChannels))
@@ -747,7 +830,7 @@ export class BushGuildMember extends GuildMember {
* Mutes a user using discord's timeout feature.
* @param options Options for timing out the user.
*/
- public async bushTimeout(options: BushTimeoutOptions): Promise<TimeoutResponse> {
+ public override async bushTimeout(options: BushTimeoutOptions): Promise<TimeoutResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return timeoutResponse.MISSING_PERMISSIONS;
@@ -811,7 +894,7 @@ export class BushGuildMember extends GuildMember {
* Removes a timeout from a user.
* @param options Options for removing the timeout.
*/
- public async bushRemoveTimeout(options: BushPunishmentOptions): Promise<RemoveTimeoutResponse> {
+ public override async bushRemoveTimeout(options: BushPunishmentOptions): Promise<RemoveTimeoutResponse> {
// checks
if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ModerateMembers))
return removeTimeoutResponse.MISSING_PERMISSIONS;
@@ -869,14 +952,14 @@ export class BushGuildMember extends GuildMember {
/**
* Whether or not the user is an owner of the bot.
*/
- public isOwner(): boolean {
+ public override isOwner(): boolean {
return client.isOwner(this);
}
/**
* Whether or not the user is a super user of the bot.
*/
- public isSuperUser(): boolean {
+ public override isSuperUser(): boolean {
return client.isSuperUser(this);
}
}
@@ -893,7 +976,7 @@ export interface BushPunishmentOptions {
/**
* The moderator who punished the user.
*/
- moderator?: BushGuildMember;
+ moderator?: GuildMember;
/**
* Evidence for the punishment.
@@ -923,7 +1006,7 @@ export interface AddRoleOptions extends BushTimedPunishmentOptions {
/**
* The role to add to the user.
*/
- role: BushRole | Role;
+ role: Role;
/**
* Whether to create a modlog entry for this punishment.
@@ -938,7 +1021,7 @@ export interface RemoveRoleOptions extends BushTimedPunishmentOptions {
/**
* The role to remove from the user.
*/
- role: BushRole | Role;
+ role: Role;
/**
* Whether to create a modlog entry for this punishment.
@@ -963,7 +1046,7 @@ export interface BlockOptions extends BushTimedPunishmentOptions {
/**
* The channel to block the user from.
*/
- channel: BushGuildTextChannelResolvable | BushThreadChannelResolvable;
+ channel: GuildChannelResolvable;
}
/**
@@ -973,7 +1056,7 @@ export interface UnblockOptions extends BushPunishmentOptions {
/**
* The channel to unblock the user from.
*/
- channel: BushGuildTextChannelResolvable | BushThreadChannelResolvable;
+ channel: GuildChannelResolvable;
}
/**
@@ -1152,8 +1235,6 @@ export type TimeoutResponse = ValueOf<typeof timeoutResponse>;
*/
export type RemoveTimeoutResponse = ValueOf<typeof removeTimeoutResponse>;
-export type PartialBushGuildMember = Partialize<BushGuildMember, 'joinedAt' | 'joinedTimestamp' | 'pending'>;
-
/**
* @typedef {BushClientEvents} VSCodePleaseDontRemove
*/
diff --git a/src/lib/extensions/discord.js/ExtendedMessage.ts b/src/lib/extensions/discord.js/ExtendedMessage.ts
new file mode 100644
index 0000000..4431077
--- /dev/null
+++ b/src/lib/extensions/discord.js/ExtendedMessage.ts
@@ -0,0 +1,12 @@
+import { CommandUtil } from 'discord-akairo';
+import { Message, type Client } from 'discord.js';
+import { type RawMessageData } from 'discord.js/typings/rawDataTypes.js';
+
+export class ExtendedMessage<Cached extends boolean = boolean> extends Message<Cached> {
+ public declare util: CommandUtil<Message>;
+
+ public constructor(client_: Client, data: RawMessageData) {
+ super(client_, data);
+ this.util = new CommandUtil(client.commandHandler, this);
+ }
+}
diff --git a/src/lib/extensions/discord.js/ExtendedUser.ts b/src/lib/extensions/discord.js/ExtendedUser.ts
new file mode 100644
index 0000000..556ab85
--- /dev/null
+++ b/src/lib/extensions/discord.js/ExtendedUser.ts
@@ -0,0 +1,35 @@
+import { User, type Partialize } from 'discord.js';
+
+declare module 'discord.js' {
+ export interface User {
+ /**
+ * Indicates whether the user is an owner of the bot.
+ */
+ isOwner(): boolean;
+ /**
+ * Indicates whether the user is a superuser of the bot.
+ */
+ isSuperUser(): boolean;
+ }
+}
+
+export type PartialBushUser = Partialize<ExtendedUser, 'username' | 'tag' | 'discriminator' | 'isOwner' | 'isSuperUser'>;
+
+/**
+ * Represents a user on Discord.
+ */
+export class ExtendedUser extends User {
+ /**
+ * Indicates whether the user is an owner of the bot.
+ */
+ public override isOwner(): boolean {
+ return client.isOwner(this);
+ }
+
+ /**
+ * Indicates whether the user is a superuser of the bot.
+ */
+ public override isSuperUser(): boolean {
+ return client.isSuperUser(this);
+ }
+}
diff --git a/src/lib/extensions/discord.js/other.ts b/src/lib/extensions/discord.js/other.ts
deleted file mode 100644
index 0560ffc..0000000
--- a/src/lib/extensions/discord.js/other.ts
+++ /dev/null
@@ -1,188 +0,0 @@
-import type {
- BushApplicationCommand,
- BushCategoryChannel,
- BushDMChannel,
- BushGuild,
- BushGuildEmoji,
- BushGuildMember,
- BushMessage,
- BushNewsChannel,
- BushReactionEmoji,
- BushRole,
- BushStageChannel,
- BushTextChannel,
- BushThreadChannel,
- BushThreadMember,
- BushUser,
- BushVoiceChannel,
- PartialBushDMChannel
-} from '#lib';
-import { APIMessage } from 'discord-api-types/v10';
-import type {
- ApplicationCommandResolvable,
- CacheType,
- CacheTypeReducer,
- ChannelResolvable,
- ChannelType,
- Collection,
- EmojiIdentifierResolvable,
- EmojiResolvable,
- FetchedThreads,
- GuildChannelResolvable,
- GuildMemberResolvable,
- GuildTextChannelResolvable,
- MessageResolvable,
- PartialGroupDMChannel,
- RoleResolvable,
- Snowflake,
- ThreadChannelResolvable,
- ThreadMemberResolvable,
- UserResolvable
-} from 'discord.js';
-
-/**
- * Data that resolves to give a ThreadMember object.
- */
-export type BushThreadMemberResolvable = ThreadMemberResolvable | BushThreadMember | BushUserResolvable;
-
-/**
- * Data that resolves to give a User object.
- */
-export type BushUserResolvable = UserResolvable | BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember;
-
-/**
- * Data that resolves to give a GuildMember object.
- */
-export type BushGuildMemberResolvable = GuildMemberResolvable | BushGuildMember | BushUserResolvable;
-
-/**
- * Data that can be resolved to a Role object.
- */
-export type BushRoleResolvable = RoleResolvable | BushRole | Snowflake;
-
-/**
- * Data that can be resolved to a Message object.
- */
-export type BushMessageResolvable = MessageResolvable | BushMessage | Snowflake;
-
-/**
- * Data that can be resolved into a GuildEmoji object.
- */
-export type BushEmojiResolvable = EmojiResolvable | Snowflake | BushGuildEmoji | BushReactionEmoji;
-
-/**
- * Data that can be resolved to give an emoji identifier. This can be:
- * * The unicode representation of an emoji
- * * The `<a:name:id>`, `<:name:id>`, `a:name:id` or `name:id` emoji identifier string of an emoji
- * * An EmojiResolvable
- */
-export type BushEmojiIdentifierResolvable = EmojiIdentifierResolvable | string | BushEmojiResolvable;
-
-/**
- * Data that can be resolved to a Thread Channel object.
- */
-export type BushThreadChannelResolvable = ThreadChannelResolvable | BushThreadChannel | Snowflake;
-
-/**
- * Data that resolves to give an ApplicationCommand object.
- */
-export type BushApplicationCommandResolvable = ApplicationCommandResolvable | BushApplicationCommand | Snowflake;
-
-/**
- * Data that can be resolved to a GuildTextChannel object.
- */
-export type BushGuildTextChannelResolvable = GuildTextChannelResolvable | BushTextChannel | BushNewsChannel | Snowflake;
-
-/**
- * Data that can be resolved to give a Channel object.
- */
-export type BushChannelResolvable = ChannelResolvable | BushAnyChannel | Snowflake;
-
-/**
- * Data that can be resolved to give a Guild Channel object.
- */
-export type BushGuildChannelResolvable = GuildChannelResolvable | Snowflake | BushGuildBasedChannel;
-
-export type BushAnyChannel =
- | BushCategoryChannel
- | BushDMChannel
- | PartialBushDMChannel
- | PartialGroupDMChannel
- | BushNewsChannel
- | BushStageChannel
- | BushTextChannel
- | BushThreadChannel
- | BushVoiceChannel;
-
-/**
- * The channels that are text-based.
- */
-export type BushTextBasedChannel =
- | BushDMChannel
- | PartialBushDMChannel
- | BushNewsChannel
- | BushTextChannel
- | BushThreadChannel
- | BushVoiceChannel;
-
-/**
- * The types of channels that are text-based.
- */
-export type BushTextBasedChannelTypes = BushTextBasedChannel['type'];
-
-export type BushVoiceBasedChannel = Extract<BushAnyChannel, { bitrate: number }>;
-
-export type BushGuildBasedChannel = Extract<BushAnyChannel, { guild: BushGuild }>;
-
-export type BushNonCategoryGuildBasedChannel = Exclude<BushGuildBasedChannel, BushCategoryChannel>;
-
-export type BushNonThreadGuildBasedChannel = Exclude<BushGuildBasedChannel, BushThreadChannel>;
-
-export type BushGuildTextBasedChannel = Extract<BushGuildBasedChannel, BushTextBasedChannel>;
-
-/**
- * Data that can be resolved to a Text Channel object.
- */
-export type BushTextChannelResolvable = Snowflake | BushTextChannel;
-
-/**
- * Data that can be resolved to a GuildVoiceChannel object.
- */
-export type BushGuildVoiceChannelResolvable = BushVoiceBasedChannel | Snowflake;
-
-export interface BushMappedChannelCategoryTypes {
- [ChannelType.GuildNews]: BushNewsChannel;
- [ChannelType.GuildVoice]: BushVoiceChannel;
- [ChannelType.GuildText]: BushTextChannel;
- [ChannelType.GuildStageVoice]: BushStageChannel;
- [ChannelType.GuildForum]: never; // TODO: Fix when guild forums come out
-}
-
-export type BushMappedGuildChannelTypes = {
- [ChannelType.GuildCategory]: BushCategoryChannel;
-} & BushMappedChannelCategoryTypes;
-
-/**
- * The data returned from a thread fetch that returns multiple threads.
- */
-export interface BushFetchedThreads extends FetchedThreads {
- /**
- * The threads that were fetched, with any members returned
- */
- threads: Collection<Snowflake, BushThreadChannel>;
-
- /**
- * Whether there are potentially additional threads that require a subsequent call
- */
- hasMore?: boolean;
-}
-
-export type BushGuildCacheMessage<Cached extends CacheType> = CacheTypeReducer<
- Cached,
- BushMessage<true>,
- APIMessage,
- BushMessage | APIMessage,
- BushMessage | APIMessage
->;
-
-export { ApplicationCommandOptionType as SlashType } from 'discord.js';
diff --git a/src/lib/index.ts b/src/lib/index.ts
index 8a6b75d..221f360 100644
--- a/src/lib/index.ts
+++ b/src/lib/index.ts
@@ -12,61 +12,18 @@ export * from './extensions/discord-akairo/BushClient.js';
export * from './extensions/discord-akairo/BushClientUtil.js';
export * from './extensions/discord-akairo/BushCommand.js';
export * from './extensions/discord-akairo/BushCommandHandler.js';
-export * from './extensions/discord-akairo/BushCommandUtil.js';
export * from './extensions/discord-akairo/BushInhibitor.js';
export * from './extensions/discord-akairo/BushInhibitorHandler.js';
export * from './extensions/discord-akairo/BushListener.js';
export * from './extensions/discord-akairo/BushListenerHandler.js';
-export * from './extensions/discord-akairo/BushSlashMessage.js';
export * from './extensions/discord-akairo/BushTask.js';
export * from './extensions/discord-akairo/BushTaskHandler.js';
-export * from './extensions/discord.js/BushActivity.js';
-export * from './extensions/discord.js/BushApplicationCommand.js';
-export type { BushApplicationCommandManager } from './extensions/discord.js/BushApplicationCommandManager.js';
-export type { BushApplicationCommandPermissionsManager } from './extensions/discord.js/BushApplicationCommandPermissionsManager.js';
-export type { BushBaseGuildEmojiManager } from './extensions/discord.js/BushBaseGuildEmojiManager.js';
-export type { BushBaseGuildVoiceChannel } from './extensions/discord.js/BushBaseGuildVoiceChannel.js';
-export * from './extensions/discord.js/BushButtonInteraction.js';
-export * from './extensions/discord.js/BushCategoryChannel.js';
-export type { BushCategoryChannelChildManager } from './extensions/discord.js/BushCategoryChannelChildManager.js';
-export type { BushChannel } from './extensions/discord.js/BushChannel.js';
-export type { BushChannelManager } from './extensions/discord.js/BushChannelManager.js';
-export * from './extensions/discord.js/BushChatInputCommandInteraction.js';
+export * from './extensions/discord-akairo/SlashMessage.js';
export type { BushClientEvents } from './extensions/discord.js/BushClientEvents.js';
-export type { BushClientUser } from './extensions/discord.js/BushClientUser.js';
-export * from './extensions/discord.js/BushDMChannel.js';
-export * from './extensions/discord.js/BushEmoji.js';
-export * from './extensions/discord.js/BushGuild.js';
-export type { BushGuildApplicationCommandManager } from './extensions/discord.js/BushGuildApplicationCommandManager.js';
-export type { BushGuildBan } from './extensions/discord.js/BushGuildBan.js';
-export * from './extensions/discord.js/BushGuildChannel.js';
-export type { BushGuildChannelManager } from './extensions/discord.js/BushGuildChannelManager.js';
-export * from './extensions/discord.js/BushGuildEmoji.js';
-export type { BushGuildEmojiRoleManager } from './extensions/discord.js/BushGuildEmojiRoleManager.js';
-export type { BushGuildManager } from './extensions/discord.js/BushGuildManager.js';
-export * from './extensions/discord.js/BushGuildMember.js';
-export type { BushGuildMemberManager } from './extensions/discord.js/BushGuildMemberManager.js';
-export * from './extensions/discord.js/BushMessage.js';
-export type { BushMessageManager } from './extensions/discord.js/BushMessageManager.js';
-export * from './extensions/discord.js/BushMessageReaction.js';
-export * from './extensions/discord.js/BushModalSubmitInteraction.js';
-export * from './extensions/discord.js/BushNewsChannel.js';
-export * from './extensions/discord.js/BushPresence.js';
-export * from './extensions/discord.js/BushReactionEmoji.js';
-export * from './extensions/discord.js/BushRole.js';
-export * from './extensions/discord.js/BushSelectMenuInteraction.js';
-export * from './extensions/discord.js/BushStageChannel.js';
-export * from './extensions/discord.js/BushStageInstance.js';
-export * from './extensions/discord.js/BushTextChannel.js';
-export * from './extensions/discord.js/BushThreadChannel.js';
-export type { BushThreadManager } from './extensions/discord.js/BushThreadManager.js';
-export * from './extensions/discord.js/BushThreadMember.js';
-export type { BushThreadMemberManager } from './extensions/discord.js/BushThreadMemberManager.js';
-export * from './extensions/discord.js/BushUser.js';
-export type { BushUserManager } from './extensions/discord.js/BushUserManager.js';
-export * from './extensions/discord.js/BushVoiceChannel.js';
-export * from './extensions/discord.js/BushVoiceState.js';
-export * from './extensions/discord.js/other.js';
+export * from './extensions/discord.js/ExtendedGuild.js';
+export * from './extensions/discord.js/ExtendedGuildMember.js';
+export * from './extensions/discord.js/ExtendedMessage.js';
+export * from './extensions/discord.js/ExtendedUser.js';
export * from './models/BaseModel.js';
export * from './models/instance/ActivePunishment.js';
export * from './models/instance/Guild.js';
diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts
index 91c23d3..073b8e2 100644
--- a/src/lib/utils/BushLogger.ts
+++ b/src/lib/utils/BushLogger.ts
@@ -4,7 +4,7 @@ import { EmbedBuilder, Util, type Message, type PartialTextBasedChannelFields }
import repl, { REPLServer, REPL_MODE_STRICT } from 'repl';
import { WriteStream } from 'tty';
import { inspect } from 'util';
-import { type BushSendMessageType } from '../extensions/discord-akairo/BushClient.js';
+import { type SendMessageType } from '../extensions/discord-akairo/BushClient.js';
let REPL: REPLServer;
let replGone = false;
@@ -147,7 +147,7 @@ export class BushLogger {
* @param message The parameter to pass to {@link PartialTextBasedChannelFields.send}.
* @returns The message sent.
*/
- public static async channelLog(message: BushSendMessageType): Promise<Message | null> {
+ public static async channelLog(message: SendMessageType): Promise<Message | null> {
const channel = await util.getConfigChannel('log');
return await channel.send(message).catch(() => null);
}
@@ -157,7 +157,7 @@ export class BushLogger {
* @param message The parameter to pass to {@link PartialTextBasedChannelFields.send}.
* @returns The message sent.
*/
- public static async channelError(message: BushSendMessageType): Promise<Message | null> {
+ public static async channelError(message: SendMessageType): Promise<Message | null> {
const channel = await util.getConfigChannel('error');
if (!channel) {
void this.error(