diff options
Diffstat (limited to 'src/lib/extensions/discord.js')
13 files changed, 42 insertions, 47 deletions
diff --git a/src/lib/extensions/discord.js/BushChannel.ts b/src/lib/extensions/discord.js/BushChannel.ts index 50ec723..8779342 100644 --- a/src/lib/extensions/discord.js/BushChannel.ts +++ b/src/lib/extensions/discord.js/BushChannel.ts @@ -12,7 +12,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { Channel, ChannelType, type Snowflake } from 'discord.js'; +import { Channel, ChannelType, PartialGroupDMChannel, type Snowflake } from 'discord.js'; import type { RawChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -20,8 +20,8 @@ import type { RawChannelData } from 'discord.js/typings/rawDataTypes'; */ export declare class BushChannel extends Channel { public constructor(client: BushClient, data?: RawChannelData, immediatePatch?: boolean); - public readonly createdAt: Date; - public readonly createdTimestamp: number; + public readonly createdAt: Date | null; + public readonly createdTimestamp: number | null; public deleted: boolean; public id: Snowflake; public readonly partial: false; @@ -30,6 +30,7 @@ export declare class BushChannel extends Channel { 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; diff --git a/src/lib/extensions/discord.js/BushClientEvents.ts b/src/lib/extensions/discord.js/BushClientEvents.ts index 02f0017..fe60964 100644 --- a/src/lib/extensions/discord.js/BushClientEvents.ts +++ b/src/lib/extensions/discord.js/BushClientEvents.ts @@ -28,17 +28,7 @@ import type { PartialBushUser } from '#lib'; import type { AkairoClientEvents } from 'discord-akairo'; -import type { - Collection, - GuildScheduledEvent, - Interaction, - InvalidRequestWarningData, - Invite, - RateLimitData, - Snowflake, - Sticker, - Typing -} from 'discord.js'; +import type { Collection, GuildScheduledEvent, Interaction, Invite, Snowflake, Sticker, Typing } from 'discord.js'; export interface BushClientEvents extends AkairoClientEvents { applicationCommandCreate: [command: BushApplicationCommand]; @@ -88,8 +78,6 @@ export interface BushClientEvents extends AkairoClientEvents { messageReactionRemove: [reaction: BushMessageReaction | PartialBushMessageReaction, user: BushUser | PartialBushUser]; messageUpdate: [oldMessage: BushMessage | PartialBushMessage, newMessage: BushMessage | PartialBushMessage]; presenceUpdate: [oldPresence: BushPresence | null, newPresence: BushPresence]; - rateLimit: [rateLimitData: RateLimitData]; - invalidRequestWarning: [invalidRequestWarningData: InvalidRequestWarningData]; ready: [client: BushClient<true>]; invalidated: []; roleCreate: [role: BushRole]; diff --git a/src/lib/extensions/discord.js/BushDMChannel.ts b/src/lib/extensions/discord.js/BushDMChannel.ts index 363c620..d73ad70 100644 --- a/src/lib/extensions/discord.js/BushDMChannel.ts +++ b/src/lib/extensions/discord.js/BushDMChannel.ts @@ -13,7 +13,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { DMChannel, type Partialize } from 'discord.js'; +import { DMChannel, PartialGroupDMChannel, type Partialize } from 'discord.js'; import type { RawDMChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -32,6 +32,7 @@ export class BushDMChannel extends DMChannel { export interface BushDMChannel extends DMChannel { 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; diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts index b546dab..83e024d 100644 --- a/src/lib/extensions/discord.js/BushGuild.ts +++ b/src/lib/extensions/discord.js/BushGuild.ts @@ -18,7 +18,7 @@ import { type GuildLogType, type GuildModel } from '#lib'; -import { Collection, Guild, Permissions, Snowflake, type MessageOptions, type MessagePayload } from 'discord.js'; +import { Collection, Guild, PermissionFlagsBits, Snowflake, type MessageOptions, type MessagePayload } from 'discord.js'; import type { RawGuildData } from 'discord.js/typings/rawDataTypes'; import _ from 'lodash'; import { Moderation } from '../../common/util/Moderation.js'; @@ -138,7 +138,7 @@ export class BushGuild extends Guild { if ( !logChannel .permissionsFor(this.me!.id) - ?.has([Permissions.FLAGS.VIEW_CHANNEL, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.EMBED_LINKS]) + ?.has([PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.EmbedLinks]) ) return; @@ -162,7 +162,7 @@ export class BushGuild extends Guild { */ public async bushBan(options: GuildBushBanOptions): Promise<BanResponse> { // checks - if (!this.me!.permissions.has(Permissions.FLAGS.BAN_MEMBERS)) return banResponse.MISSING_PERMISSIONS; + if (!this.me!.permissions.has(PermissionFlagsBits.BanMembers)) return banResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; let dmSuccessEvent: boolean | undefined = undefined; @@ -241,7 +241,7 @@ export class BushGuild extends Guild { */ public async bushUnban(options: GuildBushUnbanOptions): Promise<UnbanResponse> { // checks - if (!this.me!.permissions.has(Permissions.FLAGS.BAN_MEMBERS)) return unbanResponse.MISSING_PERMISSIONS; + if (!this.me!.permissions.has(PermissionFlagsBits.BanMembers)) return unbanResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; let dmSuccessEvent: boolean | undefined = undefined; @@ -335,11 +335,11 @@ export class BushGuild extends Guild { success.set(channel.id, false); continue; } - if (!channel.permissionsFor(this.me!.id)?.has([Permissions.FLAGS.MANAGE_CHANNELS])) { + if (!channel.permissionsFor(this.me!.id)?.has([PermissionFlagsBits.ManageChannels])) { errors.set(channel.id, new Error('client no permission')); success.set(channel.id, false); continue; - } else if (!channel.permissionsFor(moderator)?.has([Permissions.FLAGS.MANAGE_CHANNELS])) { + } else if (!channel.permissionsFor(moderator)?.has([PermissionFlagsBits.ManageChannels])) { errors.set(channel.id, new Error('moderator no permission')); success.set(channel.id, false); continue; @@ -351,10 +351,10 @@ export class BushGuild extends Guild { const permissionOverwrites = channel.isThread() ? channel.parent!.permissionOverwrites : channel.permissionOverwrites; const perms = { - [channel.isThread() ? 'SEND_MESSAGES_IN_THREADS' : 'FLAGS.SEND_MESSAGES']: options.unlock ? null : false + [channel.isThread() ? 'SendMessagesInThreads' : 'SendMessages']: options.unlock ? null : false }; const permsForMe = { - [channel.isThread() ? 'SEND_MESSAGES_IN_THREADS' : 'FLAGS.SEND_MESSAGES']: options.unlock ? null : true + [channel.isThread() ? 'SendMessagesInThreads' : 'SendMessages']: options.unlock ? null : true }; // so I can send messages in the channel const changePermSuccess = await permissionOverwrites.edit(this.id, perms, { reason }).catch((e) => e); diff --git a/src/lib/extensions/discord.js/BushGuildChannel.ts b/src/lib/extensions/discord.js/BushGuildChannel.ts index 053507e..dd523e5 100644 --- a/src/lib/extensions/discord.js/BushGuildChannel.ts +++ b/src/lib/extensions/discord.js/BushGuildChannel.ts @@ -14,7 +14,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { GuildChannel } from 'discord.js'; +import { GuildChannel, PartialGroupDMChannel } from 'discord.js'; import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -37,6 +37,7 @@ export class BushGuildChannel extends GuildChannel { 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; diff --git a/src/lib/extensions/discord.js/BushGuildChannelManager.ts b/src/lib/extensions/discord.js/BushGuildChannelManager.ts index dd3885b..029f7d3 100644 --- a/src/lib/extensions/discord.js/BushGuildChannelManager.ts +++ b/src/lib/extensions/discord.js/BushGuildChannelManager.ts @@ -55,7 +55,7 @@ export declare class BushGuildChannelManager * permissionOverwrites: [ * { * id: message.author.id, - * deny: [Permissions.FLAGS.VIEW_CHANNEL], + * deny: [PermissionFlagsBits.ViewChannel], * }, * ], * }) diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts index 10d8a4c..ab6cd65 100644 --- a/src/lib/extensions/discord.js/BushGuildMember.ts +++ b/src/lib/extensions/discord.js/BushGuildMember.ts @@ -11,7 +11,7 @@ import { type BushThreadChannelResolvable, type BushUser } from '#lib'; -import { GuildMember, Permissions, type Partialize, type Role } from 'discord.js'; +import { GuildMember, PermissionFlagsBits, type Partialize, type Role } from 'discord.js'; import type { RawGuildMemberData } from 'discord.js/typings/rawDataTypes'; /* eslint-enable @typescript-eslint/no-unused-vars */ @@ -90,7 +90,7 @@ export class BushGuildMember extends GuildMember { */ public async bushAddRole(options: AddRoleOptions): Promise<AddRoleResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return addRoleResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return addRoleResponse.MISSING_PERMISSIONS; const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator); if (ifShouldAddRole !== true) return ifShouldAddRole; @@ -161,7 +161,7 @@ export class BushGuildMember extends GuildMember { */ public async bushRemoveRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return removeRoleResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return removeRoleResponse.MISSING_PERMISSIONS; const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator); if (ifShouldAddRole !== true) return ifShouldAddRole; @@ -252,7 +252,7 @@ export class BushGuildMember extends GuildMember { */ public async bushMute(options: BushTimedPunishmentOptions): Promise<MuteResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return muteResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return muteResponse.MISSING_PERMISSIONS; const muteRoleID = await this.guild.getSetting('muteRole'); if (!muteRoleID) return muteResponse.NO_MUTE_ROLE; const muteRole = this.guild.roles.cache.get(muteRoleID); @@ -338,7 +338,7 @@ export class BushGuildMember extends GuildMember { */ public async bushUnmute(options: BushPunishmentOptions): Promise<UnmuteResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return unmuteResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return unmuteResponse.MISSING_PERMISSIONS; const muteRoleID = await this.guild.getSetting('muteRole'); if (!muteRoleID) return unmuteResponse.NO_MUTE_ROLE; const muteRole = this.guild.roles.cache.get(muteRoleID); @@ -421,7 +421,7 @@ export class BushGuildMember extends GuildMember { */ public async bushKick(options: BushPunishmentOptions): Promise<KickResponse> { // checks - if (!this.guild.me?.permissions.has(Permissions.FLAGS.KICK_MEMBERS) || !this.kickable) + if (!this.guild.me?.permissions.has(PermissionFlagsBits.KickMembers) || !this.kickable) return kickResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; @@ -474,7 +474,7 @@ export class BushGuildMember extends GuildMember { */ public async bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.BAN_MEMBERS) || !this.bannable) return banResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.BanMembers) || !this.bannable) return banResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; let dmSuccessEvent: boolean | undefined = undefined; @@ -554,7 +554,8 @@ export class BushGuildMember extends GuildMember { if (!channel || (!channel.isTextBased() && !channel.isThread())) return blockResponse.INVALID_CHANNEL; // checks - if (!channel.permissionsFor(this.guild.me!)!.has(Permissions.FLAGS.MANAGE_CHANNELS)) return blockResponse.MISSING_PERMISSIONS; + if (!channel.permissionsFor(this.guild.me!)!.has(PermissionFlagsBits.ManageChannels)) + return blockResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; let dmSuccessEvent: boolean | undefined = undefined; @@ -564,7 +565,7 @@ export class BushGuildMember extends GuildMember { const ret = await (async () => { // change channel permissions const channelToUse = channel.isThread() ? channel.parent! : channel; - const perm = channel.isThread() ? { SEND_MESSAGES_IN_THREADS: false } : { SEND_MESSAGES: false }; + const perm = channel.isThread() ? { SendMessagesInThreads: false } : { SendMessages: false }; const blockSuccess = await channelToUse.permissionOverwrites .edit(this, perm, { reason: `[Block] ${moderator.tag} | ${options.reason ?? 'No reason provided.'}` }) .catch(() => false); @@ -643,7 +644,7 @@ export class BushGuildMember extends GuildMember { const channel = _channel as BushGuildTextBasedChannel; // checks - if (!channel.permissionsFor(this.guild.me!)!.has(Permissions.FLAGS.MANAGE_CHANNELS)) + if (!channel.permissionsFor(this.guild.me!)!.has(PermissionFlagsBits.ManageChannels)) return unblockResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; @@ -654,7 +655,7 @@ export class BushGuildMember extends GuildMember { const ret = await (async () => { // change channel permissions const channelToUse = channel.isThread() ? channel.parent! : channel; - const perm = channel.isThread() ? { SEND_MESSAGES_IN_THREADS: null } : { SEND_MESSAGES: null }; + const perm = channel.isThread() ? { SendMessagesInThreads: null } : { SendMessages: null }; const blockSuccess = await channelToUse.permissionOverwrites .edit(this, perm, { reason: `[Unblock] ${moderator.tag} | ${options.reason ?? 'No reason provided.'}` }) .catch(() => false); @@ -720,7 +721,7 @@ export class BushGuildMember extends GuildMember { */ public async bushTimeout(options: BushTimeoutOptions): Promise<TimeoutResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS)) return timeoutResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return timeoutResponse.MISSING_PERMISSIONS; const twentyEightDays = client.consts.timeUnits.days.value * 28; if (options.duration > twentyEightDays) return timeoutResponse.INVALID_DURATION; @@ -784,7 +785,7 @@ export class BushGuildMember extends GuildMember { */ public async bushRemoveTimeout(options: BushPunishmentOptions): Promise<RemoveTimeoutResponse> { // checks - if (!this.guild.me!.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS)) return removeTimeoutResponse.MISSING_PERMISSIONS; + if (!this.guild.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return removeTimeoutResponse.MISSING_PERMISSIONS; let caseID: string | undefined = undefined; let dmSuccessEvent: boolean | undefined = undefined; diff --git a/src/lib/extensions/discord.js/BushGuildMemberManager.ts b/src/lib/extensions/discord.js/BushGuildMemberManager.ts index bb130fc..3f8dcd2 100644 --- a/src/lib/extensions/discord.js/BushGuildMemberManager.ts +++ b/src/lib/extensions/discord.js/BushGuildMemberManager.ts @@ -31,7 +31,7 @@ export declare class BushGuildMemberManager public guild: BushGuild; /** - * Adds a user to the guild using OAuth2. Requires the `CREATE_INSTANT_INVITE` permission. + * 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 */ diff --git a/src/lib/extensions/discord.js/BushStoreChannel.ts b/src/lib/extensions/discord.js/BushStoreChannel.ts index dbc53e8..eadc8af 100644 --- a/src/lib/extensions/discord.js/BushStoreChannel.ts +++ b/src/lib/extensions/discord.js/BushStoreChannel.ts @@ -14,7 +14,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { StoreChannel, type Collection, type Snowflake } from 'discord.js'; +import { PartialGroupDMChannel, StoreChannel, type Collection, type Snowflake } from 'discord.js'; import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -34,6 +34,7 @@ export class BushStoreChannel extends StoreChannel { export interface BushStoreChannel extends StoreChannel { 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; diff --git a/src/lib/extensions/discord.js/BushTextChannel.ts b/src/lib/extensions/discord.js/BushTextChannel.ts index 15be7bd..ad54b76 100644 --- a/src/lib/extensions/discord.js/BushTextChannel.ts +++ b/src/lib/extensions/discord.js/BushTextChannel.ts @@ -14,7 +14,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { TextChannel, type AllowedThreadTypeForTextChannel } from 'discord.js'; +import { PartialGroupDMChannel, TextChannel, type AllowedThreadTypeForTextChannel } from 'discord.js'; import type { RawGuildChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -33,6 +33,7 @@ export class BushTextChannel extends TextChannel { 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; diff --git a/src/lib/extensions/discord.js/BushThreadChannel.ts b/src/lib/extensions/discord.js/BushThreadChannel.ts index a342dd7..691fabf 100644 --- a/src/lib/extensions/discord.js/BushThreadChannel.ts +++ b/src/lib/extensions/discord.js/BushThreadChannel.ts @@ -16,7 +16,7 @@ import type { BushVoiceBasedChannel, BushVoiceChannel } from '#lib'; -import { ThreadChannel, type Collection, type Snowflake } from 'discord.js'; +import { PartialGroupDMChannel, ThreadChannel, type Collection, type Snowflake } from 'discord.js'; import type { RawThreadChannelData } from 'discord.js/typings/rawDataTypes'; /** @@ -38,6 +38,7 @@ export class BushThreadChannel extends ThreadChannel { export interface BushThreadChannel extends ThreadChannel { 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; diff --git a/src/lib/extensions/discord.js/BushThreadMemberManager.ts b/src/lib/extensions/discord.js/BushThreadMemberManager.ts index d597673..48e968f 100644 --- a/src/lib/extensions/discord.js/BushThreadMemberManager.ts +++ b/src/lib/extensions/discord.js/BushThreadMemberManager.ts @@ -32,7 +32,7 @@ export declare class BushThreadMemberManager public add(member: UserResolvable | '@me', reason?: string): Promise<Snowflake>; /** - * Fetches member(s) for the thread from Discord, requires access to the `GUILD_MEMBERS` gateway intent. + * 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 */ diff --git a/src/lib/extensions/discord.js/BushUserManager.ts b/src/lib/extensions/discord.js/BushUserManager.ts index ae28f1d..c26dbde 100644 --- a/src/lib/extensions/discord.js/BushUserManager.ts +++ b/src/lib/extensions/discord.js/BushUserManager.ts @@ -4,7 +4,7 @@ import { Message, MessageOptions, MessagePayload, - UserFlags, + UserFlagsBitField, UserManager, type BaseFetchOptions, type Snowflake @@ -49,7 +49,7 @@ export declare class BushUserManager extends CachedManager<Snowflake, BushUser, * @param user The UserResolvable to identify * @param options Additional options for this fetch */ - public fetchFlags(user: BushUserResolvable, options?: BaseFetchOptions): Promise<UserFlags>; + public fetchFlags(user: BushUserResolvable, options?: BaseFetchOptions): Promise<UserFlagsBitField>; /** * Sends a message to a user. |