aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/common/AutoMod.ts18
-rw-r--r--src/lib/common/ButtonPaginator.ts4
-rw-r--r--src/lib/common/ConfirmationPrompt.ts4
-rw-r--r--src/lib/common/DeleteButton.ts4
-rw-r--r--src/lib/common/util/Moderation.ts2
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts8
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts4
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts22
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts52
-rw-r--r--src/lib/extensions/discord.js/BushGuildMemberManager.ts8
-rw-r--r--src/lib/extensions/discord.js/BushThreadManager.ts12
-rw-r--r--src/lib/extensions/discord.js/BushThreadMemberManager.ts7
-rw-r--r--src/lib/extensions/discord.js/other.ts17
13 files changed, 89 insertions, 73 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index 5534728..b08fc40 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -166,18 +166,18 @@ export class AutoMod {
.setDescription(
`**User:** ${this.message.author} (${this.message.author.tag})\n**Sent From:** <#${this.message.channel.id}> [Jump to context](${this.message.url})`
)
- .addFields({ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` })
+ .addFields([{ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` }])
.setColor(color)
.setTimestamp()
],
components: [
- new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder({
style: ButtonStyle.Danger,
label: 'Ban User',
customId: `automod;ban;${this.message.author.id};everyone mention and scam phrase`
})
- )
+ ])
]
});
}
@@ -259,7 +259,7 @@ export class AutoMod {
color = util.colors.yellow;
void this.message.delete().catch((e) => deleteError.bind(this, e));
void this.message.member?.bushWarn({
- moderator: this.message.guild!.me!,
+ moderator: this.message.guild!.members.me!,
reason: `[AutoMod] ${highestOffence.reason}`
});
this.punished = true;
@@ -269,7 +269,7 @@ export class AutoMod {
color = util.colors.orange;
void this.message.delete().catch((e) => deleteError.bind(this, e));
void this.message.member?.bushMute({
- moderator: this.message.guild!.me!,
+ moderator: this.message.guild!.members.me!,
reason: `[AutoMod] ${highestOffence.reason}`,
duration: 900_000 // 15 minutes
});
@@ -280,7 +280,7 @@ export class AutoMod {
color = util.colors.red;
void this.message.delete().catch((e) => deleteError.bind(this, e));
void this.message.member?.bushMute({
- moderator: this.message.guild!.me!,
+ moderator: this.message.guild!.members.me!,
reason: `[AutoMod] ${highestOffence.reason}`,
duration: 0 // permanent
});
@@ -331,7 +331,7 @@ export class AutoMod {
this.message.channel.id
}> [Jump to context](${this.message.url})\n**Blacklisted Words:** ${offences.map((o) => `\`${o.match}\``).join(', ')}`
)
- .addFields({ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` })
+ .addFields([{ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` }])
.setColor(color)
.setTimestamp()
.setAuthor({ name: this.message.author.tag, url: this.message.author.displayAvatarURL() })
@@ -339,13 +339,13 @@ export class AutoMod {
components:
highestOffence.severity >= 2
? [
- new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder({
style: ButtonStyle.Danger,
label: 'Ban User',
customId: `automod;ban;${this.message.author.id};${highestOffence.reason}`
})
- )
+ ])
]
: undefined
});
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index 59dcb68..cc95601 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -171,7 +171,7 @@ export class ButtonPaginator {
* @returns The generated {@link ActionRow}
*/
protected getPaginationRow(disableAll = false) {
- return new ActionRowBuilder<ButtonBuilder>().addComponents(
+ return new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_beginning',
@@ -202,7 +202,7 @@ export class ButtonPaginator {
emoji: PaginateEmojis.END,
disabled: disableAll || this.curPage === this.numPages - 1
})
- );
+ ]);
}
/**
diff --git a/src/lib/common/ConfirmationPrompt.ts b/src/lib/common/ConfirmationPrompt.ts
index e86c236..c611fd3 100644
--- a/src/lib/common/ConfirmationPrompt.ts
+++ b/src/lib/common/ConfirmationPrompt.ts
@@ -29,10 +29,10 @@ export class ConfirmationPrompt {
*/
protected async send(): Promise<boolean> {
this.messageOptions.components = [
- new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder({ style: ButtonStyle.Success, customId: 'confirmationPrompt_confirm', label: 'Yes' }),
new ButtonBuilder({ style: ButtonStyle.Danger, customId: 'confirmationPrompt_cancel', label: 'No' })
- )
+ ])
];
const msg = await this.message.channel!.send(this.messageOptions);
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index 4874f78..03e2639 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -66,14 +66,14 @@ export class DeleteButton {
*/
protected updateComponents(edit = false, disable = false): void {
this.messageOptions.components = [
- new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate__stop',
emoji: PaginateEmojis.STOP,
disabled: disable
})
- )
+ ])
];
if (edit) {
this.messageOptions.reply = undefined;
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index f388121..9f93375 100644
--- a/src/lib/common/util/Moderation.ts
+++ b/src/lib/common/util/Moderation.ts
@@ -91,7 +91,7 @@ export class Moderation {
return `${util.emojis.error} You cannot ${type} **${victim.user.tag}** because they have higher or equal role hierarchy as you do.`;
}
if (
- victim.roles.highest.position >= victim.guild.me!.roles.highest.position &&
+ victim.roles.highest.position >= victim.guild.members.me!.roles.highest.position &&
!(type.startsWith('un') && moderator.id === victim.id)
) {
return `${util.emojis.error} You cannot ${type} **${victim.user.tag}** because they have higher or equal role hierarchy as I do.`;
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 563df3d..aea515a 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -823,7 +823,7 @@ export class BushClientUtil extends ClientUtil {
* @returns The missing permissions or null if none are missing.
*/
public clientGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]): PermissionsString[] | null {
- const missing = message.guild?.me?.permissions.missing(permissions) ?? [];
+ const missing = message.guild?.members.me?.permissions.missing(permissions) ?? [];
return missing.length ? missing : null;
}
@@ -845,11 +845,11 @@ export class BushClientUtil extends ClientUtil {
const sendPerm = message.channel!.isThread() ? 'SendMessages' : 'SendMessagesInThreads';
if (!message.inGuild()) return null;
- if (!message.guild.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
- ? message.guild!.me!.permissionsIn(message.channel!.id!).missing(permissions)
+ ? message.guild!.members.me!.permissionsIn(message.channel!.id!).missing(permissions)
: this.clientGuildPermCheck(message, permissions) ?? [])
);
@@ -995,7 +995,7 @@ export class BushClientUtil extends ClientUtil {
if (embed.author) embeds.at(0)?.setAuthor(embed.author);
if (embed.title) embeds.at(0)?.setTitle(embed.title);
if (embed.url) embeds.at(0)?.setURL(embed.url);
- if (embed.fields) embeds.at(-1)?.setFields(...embed.fields);
+ if (embed.fields) embeds.at(-1)?.setFields(embed.fields);
if (embed.thumbnail) embeds.at(-1)?.setThumbnail(embed.thumbnail.url);
if (embed.footer) embeds.at(-1)?.setFooter(embed.footer);
if (embed.image) embeds.at(-1)?.setImage(embed.image.url);
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index febe95a..958e451 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -46,7 +46,7 @@ import {
type SlashResolveType
} from 'discord-akairo';
import {
- type ApplicationCommandOptionChoice,
+ type ApplicationCommandOptionChoiceData,
type Collection,
type Invite,
type PermissionResolvable,
@@ -147,7 +147,7 @@ interface BaseBushArgumentOptions extends Omit<ArgumentOptions, 'type' | 'prompt
/**
* The choices of the option for the user to pick from
*/
- choices?: ApplicationCommandOptionChoice[];
+ choices?: ApplicationCommandOptionChoiceData[];
/**
* Whether the option is an autocomplete option
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index 8b1b5fa..80755bc 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -1,15 +1,15 @@
import {
AllowedMentions,
banResponse,
+ BushGuildChannelManager,
+ BushGuildMemberManager,
BushMessage,
dmResponse,
permissionsResponse,
punishmentEntryRemove,
type BanResponse,
type BushClient,
- type BushGuildChannelManager,
type BushGuildMember,
- type BushGuildMemberManager,
type BushGuildMemberResolvable,
type BushNewsChannel,
type BushTextChannel,
@@ -151,7 +151,7 @@ export class BushGuild extends Guild {
if (!logChannel || !logChannel.isTextBased()) return;
if (
!logChannel
- .permissionsFor(this.me!.id)
+ .permissionsFor(this.members.me!.id)
?.has([PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages, PermissionFlagsBits.EmbedLinks])
)
return;
@@ -176,7 +176,7 @@ export class BushGuild extends Guild {
*/
public async bushBan(options: GuildBushBanOptions): Promise<BanResponse> {
// checks
- if (!this.me!.permissions.has(PermissionFlagsBits.BanMembers)) return banResponse.MISSING_PERMISSIONS;
+ if (!this.members.me!.permissions.has(PermissionFlagsBits.BanMembers)) return banResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
@@ -319,7 +319,7 @@ export class BushGuild extends Guild {
*/
public async bushUnban(options: GuildBushUnbanOptions): Promise<UnbanResponse> {
// checks
- if (!this.me!.permissions.has(PermissionFlagsBits.BanMembers)) return unbanResponse.MISSING_PERMISSIONS;
+ if (!this.members.me!.permissions.has(PermissionFlagsBits.BanMembers)) return unbanResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
@@ -413,7 +413,7 @@ export class BushGuild extends Guild {
success.set(channel.id, false);
continue;
}
- if (!channel.permissionsFor(this.me!.id)?.has([PermissionFlagsBits.ManageChannels])) {
+ if (!channel.permissionsFor(this.members.me!.id)?.has([PermissionFlagsBits.ManageChannels])) {
errors.set(channel.id, new Error('client no permission'));
success.set(channel.id, false);
continue;
@@ -442,7 +442,7 @@ export class BushGuild extends Guild {
success.set(channel.id, false);
} else {
success.set(channel.id, true);
- await permissionOverwrites.edit(this.me!, permsForMe, { reason });
+ await permissionOverwrites.edit(this.members.me!, permsForMe, { reason });
await channel.send({
embeds: [
{
@@ -466,8 +466,8 @@ export class BushGuild extends Guild {
}
public async quote(rawQuote: APIMessage, channel: BushTextChannel | BushNewsChannel | BushThreadChannel) {
- if (!channel.isTextBased() || channel.isDMBased() || channel.guildId !== this.id || !this.me) return null;
- if (!channel.permissionsFor(this.me).has('ManageWebhooks')) return 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);
@@ -643,10 +643,6 @@ export class BushGuild extends Guild {
}
}
-export interface BushGuild extends Guild {
- get me(): BushGuildMember | null;
-}
-
/**
* Options for unbanning a user
*/
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index 5d7144b..5e9e150 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -65,7 +65,7 @@ export class BushGuildMember extends GuildMember {
public 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.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return { result: warnResponse.CANNOT_RESOLVE_USER, caseNum: null };
const ret = await (async (): Promise<{ result: WarnResponse; caseNum: number | null }> => {
@@ -107,12 +107,12 @@ export class BushGuildMember extends GuildMember {
*/
public async bushAddRole(options: AddRoleOptions): Promise<AddRoleResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return addRoleResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return addRoleResponse.MISSING_PERMISSIONS;
const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
if (ifShouldAddRole !== true) return ifShouldAddRole;
let caseID: string | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return addRoleResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -178,12 +178,12 @@ export class BushGuildMember extends GuildMember {
*/
public async bushRemoveRole(options: RemoveRoleOptions): Promise<RemoveRoleResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return removeRoleResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return removeRoleResponse.MISSING_PERMISSIONS;
const ifShouldAddRole = this.#checkIfShouldAddRole(options.role, options.moderator);
if (ifShouldAddRole !== true) return ifShouldAddRole;
let caseID: string | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return removeRoleResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -255,7 +255,7 @@ export class BushGuildMember extends GuildMember {
return shouldAddRoleResponse.USER_HIERARCHY;
} else if (role.managed) {
return shouldAddRoleResponse.ROLE_MANAGED;
- } else if (this.guild.me!.roles.highest.position <= role.position) {
+ } else if (this.guild.members.me!.roles.highest.position <= role.position) {
return shouldAddRoleResponse.CLIENT_HIERARCHY;
}
return true;
@@ -269,17 +269,17 @@ export class BushGuildMember extends GuildMember {
*/
public async bushMute(options: BushTimedPunishmentOptions): Promise<MuteResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return muteResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.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);
if (!muteRole) return muteResponse.MUTE_ROLE_INVALID;
- if (muteRole.position >= this.guild.me!.roles.highest.position || muteRole.managed)
+ if (muteRole.position >= this.guild.members.me!.roles.highest.position || muteRole.managed)
return muteResponse.MUTE_ROLE_NOT_MANAGEABLE;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return muteResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -355,17 +355,17 @@ export class BushGuildMember extends GuildMember {
*/
public async bushUnmute(options: BushPunishmentOptions): Promise<UnmuteResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ManageRoles)) return unmuteResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.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);
if (!muteRole) return unmuteResponse.MUTE_ROLE_INVALID;
- if (muteRole.position >= this.guild.me!.roles.highest.position || muteRole.managed)
+ if (muteRole.position >= this.guild.members.me!.roles.highest.position || muteRole.managed)
return unmuteResponse.MUTE_ROLE_NOT_MANAGEABLE;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return unmuteResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -438,12 +438,12 @@ export class BushGuildMember extends GuildMember {
*/
public async bushKick(options: BushPunishmentOptions): Promise<KickResponse> {
// checks
- if (!this.guild.me?.permissions.has(PermissionFlagsBits.KickMembers) || !this.kickable)
+ if (!this.guild.members.me?.permissions.has(PermissionFlagsBits.KickMembers) || !this.kickable)
return kickResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return kickResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
// add modlog entry
@@ -492,17 +492,18 @@ export class BushGuildMember extends GuildMember {
*/
public async bushBan(options: BushBanOptions): Promise<Exclude<BanResponse, typeof banResponse['ALREADY_BANNED']>> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.BanMembers) || !this.bannable) return banResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.BanMembers) || !this.bannable)
+ return banResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return banResponse.CANNOT_RESOLVE_USER;
// ignore result, they should still be banned even if their mute cannot be removed
await this.bushUnmute({
reason: 'User is about to be banned, a mute is no longer necessary.',
- moderator: this.guild.me!,
+ moderator: this.guild.members.me!,
silent: true
});
@@ -574,12 +575,12 @@ export class BushGuildMember extends GuildMember {
if (!channel || (!channel.isTextBased() && !channel.isThread())) return blockResponse.INVALID_CHANNEL;
// checks
- if (!channel.permissionsFor(this.guild.me!)!.has(PermissionFlagsBits.ManageChannels))
+ if (!channel.permissionsFor(this.guild.members.me!)!.has(PermissionFlagsBits.ManageChannels))
return blockResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return blockResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -665,12 +666,12 @@ export class BushGuildMember extends GuildMember {
const channel = _channel as BushGuildTextBasedChannel;
// checks
- if (!channel.permissionsFor(this.guild.me!)!.has(PermissionFlagsBits.ManageChannels))
+ if (!channel.permissionsFor(this.guild.members.me!)!.has(PermissionFlagsBits.ManageChannels))
return unblockResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return unblockResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -748,14 +749,14 @@ export class BushGuildMember extends GuildMember {
*/
public async bushTimeout(options: BushTimeoutOptions): Promise<TimeoutResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return timeoutResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return timeoutResponse.MISSING_PERMISSIONS;
const twentyEightDays = Time.Day * 28;
if (options.duration > twentyEightDays) return timeoutResponse.INVALID_DURATION;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return timeoutResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
@@ -812,11 +813,12 @@ export class BushGuildMember extends GuildMember {
*/
public async bushRemoveTimeout(options: BushPunishmentOptions): Promise<RemoveTimeoutResponse> {
// checks
- if (!this.guild.me!.permissions.has(PermissionFlagsBits.ModerateMembers)) return removeTimeoutResponse.MISSING_PERMISSIONS;
+ if (!this.guild.members.me!.permissions.has(PermissionFlagsBits.ModerateMembers))
+ return removeTimeoutResponse.MISSING_PERMISSIONS;
let caseID: string | undefined = undefined;
let dmSuccessEvent: boolean | undefined = undefined;
- const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.me);
+ const moderator = await util.resolveNonCachedUser(options.moderator ?? this.guild.members.me);
if (!moderator) return removeTimeoutResponse.CANNOT_RESOLVE_USER;
const ret = await (async () => {
diff --git a/src/lib/extensions/discord.js/BushGuildMemberManager.ts b/src/lib/extensions/discord.js/BushGuildMemberManager.ts
index 3f8dcd2..b0368b5 100644
--- a/src/lib/extensions/discord.js/BushGuildMemberManager.ts
+++ b/src/lib/extensions/discord.js/BushGuildMemberManager.ts
@@ -52,7 +52,7 @@ export declare class BushGuildMemberManager
* @example
* // Ban a user by id (or with a user/guild member object)
* guild.members.ban('84484653687267328')
- * .then(kickInfo => console.log(`Banned ${kickInfo.user?.tag ?? kickInfo.tag ?? kickInfo}`))
+ * .then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
* .catch(console.error);
*/
public ban(user: BushUserResolvable, options?: BanOptions): Promise<BushGuildMember | BushUser | Snowflake>;
@@ -169,5 +169,9 @@ export declare class BushGuildMemberManager
* .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
* .catch(console.error);
*/
- public unban(user: BushUserResolvable, reason?: string): Promise<BushUser>;
+ 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/BushThreadManager.ts b/src/lib/extensions/discord.js/BushThreadManager.ts
index b84b98d..0748a4d 100644
--- a/src/lib/extensions/discord.js/BushThreadManager.ts
+++ b/src/lib/extensions/discord.js/BushThreadManager.ts
@@ -1,10 +1,8 @@
-import type { BushThreadChannel } from '#lib';
+import type { BushFetchedThreads, BushThreadChannel } from '#lib';
import {
CachedManager,
- FetchedThreads,
NewsChannel,
TextChannel,
- ThreadChannel,
ThreadManager,
type BaseFetchOptions,
type FetchArchivedThreadOptions,
@@ -54,7 +52,7 @@ export declare class BushThreadManager<AllowedThreadType>
* .then(threadChannel => console.log(threadChannel))
* .catch(console.error);
*/
- public create(options: ThreadCreateOptions<AllowedThreadType>): Promise<ThreadChannel>;
+ public create(options: ThreadCreateOptions<AllowedThreadType>): Promise<BushThreadChannel>;
/**
* Obtains a thread from Discord, or the channel cache if it's already available.
@@ -69,18 +67,18 @@ export declare class BushThreadManager<AllowedThreadType>
* .catch(console.error);
*/
public fetch(options: ThreadChannelResolvable, cacheOptions?: BaseFetchOptions): Promise<BushThreadChannel | null>;
- public fetch(options?: FetchThreadsOptions, cacheOptions?: { cache?: boolean }): Promise<FetchedThreads>;
+ 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<FetchedThreads>;
+ 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<FetchedThreads>;
+ public fetchActive(cache?: boolean): Promise<BushFetchedThreads>;
}
diff --git a/src/lib/extensions/discord.js/BushThreadMemberManager.ts b/src/lib/extensions/discord.js/BushThreadMemberManager.ts
index 48e968f..d183b30 100644
--- a/src/lib/extensions/discord.js/BushThreadMemberManager.ts
+++ b/src/lib/extensions/discord.js/BushThreadMemberManager.ts
@@ -47,6 +47,13 @@ export declare class BushThreadMemberManager
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
diff --git a/src/lib/extensions/discord.js/other.ts b/src/lib/extensions/discord.js/other.ts
index 086ace0..aeba01c 100644
--- a/src/lib/extensions/discord.js/other.ts
+++ b/src/lib/extensions/discord.js/other.ts
@@ -27,10 +27,12 @@ import type {
Collection,
EmojiIdentifierResolvable,
EmojiResolvable,
+ FetchedThreads,
GuildChannelResolvable,
GuildMemberResolvable,
GuildTextChannelResolvable,
MessageResolvable,
+ PartialGroupDMChannel,
RoleResolvable,
Snowflake,
ThreadChannelResolvable,
@@ -105,6 +107,7 @@ export type BushAnyChannel =
| BushCategoryChannel
| BushDMChannel
| PartialBushDMChannel
+ | PartialGroupDMChannel
| BushNewsChannel
| BushStageChannel
| BushTextChannel
@@ -114,7 +117,13 @@ export type BushAnyChannel =
/**
* The channels that are text-based.
*/
-export type BushTextBasedChannel = PartialBushDMChannel | BushThreadChannel | BushDMChannel | BushNewsChannel | BushTextChannel;
+export type BushTextBasedChannel =
+ | BushDMChannel
+ | PartialBushDMChannel
+ | BushNewsChannel
+ | BushTextChannel
+ | BushThreadChannel
+ | BushVoiceChannel;
/**
* The types of channels that are text-based.
@@ -125,6 +134,8 @@ 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>;
@@ -154,7 +165,7 @@ export type BushMappedGuildChannelTypes = {
/**
* The data returned from a thread fetch that returns multiple threads.
*/
-export interface BushFetchedThreads {
+export interface BushFetchedThreads extends FetchedThreads {
/**
* The threads that were fetched, with any members returned
*/
@@ -166,8 +177,6 @@ export interface BushFetchedThreads {
hasMore?: boolean;
}
-export type BushNonCategoryGuildBasedChannel = Exclude<BushGuildBasedChannel, BushCategoryChannel>;
-
export type BushGuildCacheMessage<Cached extends CacheType> = CacheTypeReducer<
Cached,
BushMessage<true>,