diff options
Diffstat (limited to 'src')
101 files changed, 369 insertions, 352 deletions
diff --git a/src/arguments/permission.ts b/src/arguments/permission.ts index 4ae6327..cf4c42c 100644 --- a/src/arguments/permission.ts +++ b/src/arguments/permission.ts @@ -1,12 +1,12 @@ import { type BushArgumentTypeCaster } from '#lib'; -import { Permissions, type PermissionString } from 'discord.js'; +import { PermissionFlagsBits, type PermissionsString } from 'discord.js'; -export const permission: BushArgumentTypeCaster<PermissionString | null> = (_, phrase) => { +export const permission: BushArgumentTypeCaster<PermissionsString | null> = (_, phrase) => { if (!phrase) return null; phrase = phrase.toUpperCase().replace(/ /g, '_'); - if (!(phrase in Permissions.FLAGS)) { + if (!(phrase in PermissionFlagsBits)) { return null; } else { - return phrase as PermissionString; + return phrase as PermissionsString; } }; diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index 4f511cd..e12a131 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -1,5 +1,5 @@ import { BushCommand, ButtonPaginator, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; export default class ChannelPermissionsCommand extends BushCommand { public constructor() { @@ -47,8 +47,8 @@ export default class ChannelPermissionsCommand extends BushCommand { ] } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), - userPermissions: [Permissions.FLAGS.ADMINISTRATOR], + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + userPermissions: [PermissionFlagsBits.Administrator], channel: 'guild', slash: true }); @@ -63,7 +63,7 @@ export default class ChannelPermissionsCommand extends BushCommand { } ) { if (!message.inGuild()) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); - if (!message.member!.permissions.has(Permissions.FLAGS.ADMINISTRATOR) && !message.member!.user.isOwner()) + if (!message.member!.permissions.has(PermissionFlagsBits.Administrator) && !message.member!.user.isOwner()) return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 3b438d9..c056bbd 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; export default class RoleAllCommand extends BushCommand { public constructor() { @@ -30,8 +30,8 @@ export default class RoleAllCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), - userPermissions: [Permissions.FLAGS.ADMINISTRATOR], + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + userPermissions: [PermissionFlagsBits.Administrator], typing: true, slash: true }); @@ -39,7 +39,7 @@ export default class RoleAllCommand extends BushCommand { public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'boolean'> }) { if (!message.inGuild()) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); - if (!message.member!.permissions.has(Permissions.FLAGS.ADMINISTRATOR) && !message.member!.user.isOwner()) + if (!message.member!.permissions.has(PermissionFlagsBits.Administrator) && !message.member!.user.isOwner()) return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); diff --git a/src/commands/config/_customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts index 1c91f28..bd9bab5 100644 --- a/src/commands/config/_customAutomodPhrases.ts +++ b/src/commands/config/_customAutomodPhrases.ts @@ -1,5 +1,5 @@ // import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -// import { Permissions } from 'discord.js'; +// import { PermissionFlagsBits } from 'discord.js'; // export default class CustomAutomodPhrasesCommand extends BushCommand { // public constructor() { @@ -31,7 +31,7 @@ // slash: true, // channel: 'guild', // clientPermissions: (m) => util.clientSendAndPermCheck(m), -// userPermissions: [Permissions.FLAGS.MANAGE_GUILD] +// userPermissions: [PermissionFlagsBits.ManageGuild] // }); // } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index 0498b87..d210472 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions, User } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, User } from 'discord.js'; export default class BlacklistCommand extends BushCommand { public constructor() { @@ -42,7 +42,7 @@ export default class BlacklistCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD] + userPermissions: [PermissionFlagsBits.ManageGuild] }); } diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 42ff309..8f2472e 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -20,7 +20,7 @@ import { Formatters, GuildMember, InteractionUpdateOptions, - Permissions, + PermissionFlagsBits, Role, SelectMenuComponent, SelectMenuOption, @@ -126,7 +126,7 @@ export default class ConfigCommand extends BushCommand { }), channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD] + userPermissions: [PermissionFlagsBits.ManageGuild] }); } @@ -209,7 +209,7 @@ export default class ConfigCommand extends BushCommand { } ) { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); - if (!message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && !message.member?.user.isOwner()) + if (!message.member?.permissions.has(PermissionFlagsBits.ManageGuild) && !message.member?.user.isOwner()) return await message.util.reply(`${util.emojis.error} You must have the **Manage Server** permission to run this command.`); const setting = message.util.isSlash ? (_.camelCase(args.subcommandGroup)! as GuildSettings) : args.setting!; const action = message.util.isSlash ? args.subcommand! : args.action!; diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index d59ff55..a7ebfa2 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -1,7 +1,8 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, AutocompleteInteraction, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js'; import Fuse from 'fuse.js'; + assert(Fuse); export default class DisableCommand extends BushCommand { @@ -48,7 +49,7 @@ export default class DisableCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD] + userPermissions: [PermissionFlagsBits.ManageGuild] }); } diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 04c0425..2e7d623 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -10,7 +10,7 @@ import { ActionRow, ComponentType, Embed, - Permissions, + PermissionFlagsBits, SelectMenuComponent, SelectMenuOption, type Message, @@ -27,8 +27,8 @@ export default class FeaturesCommand extends BushCommand { examples: ['features'], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + userPermissions: [PermissionFlagsBits.ManageGuild] }); } diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index 4c9a20b..79f9258 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -1,6 +1,6 @@ import { BushCommand, guildLogsArr, type ArgType, type BushMessage, type BushSlashMessage, type GuildLogType } from '#lib'; import { ArgumentGeneratorReturn } from 'discord-akairo'; -import { ApplicationCommandOptionType, ChannelType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js'; export default class LogCommand extends BushCommand { public constructor() { @@ -38,7 +38,7 @@ export default class LogCommand extends BushCommand { ], channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD] + userPermissions: [PermissionFlagsBits.ManageGuild] }); } diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 28d2c76..617672f 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -32,7 +32,7 @@ import { Message, MessageAttachment, MessageCollector, - Permissions, + PermissionsBitField, ReactionCollector, SelectMenuComponent, Util @@ -268,4 +268,4 @@ export default class EvalCommand extends BushCommand { } } -/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuCommandInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|ActionRow|MessageAttachment|ButtonComponent|MessageCollector|SelectMenuComponent|ReactionCollector|Util|Canvas|Shared|Permissions} VSCodePleaseDontRemove */ +/** @typedef {ActivePunishment|Global|Guild|Level|ModLog|StickyRole|ButtonInteraction|Collection|Collector|CommandInteraction|ContextMenuCommandInteraction|DMChannel|Emoji|Interaction|InteractionCollector|Message|ActionRow|MessageAttachment|ButtonComponent|MessageCollector|SelectMenuComponent|ReactionCollector|Util|Canvas|Shared|PermissionsBitField} VSCodePleaseDontRemove */ diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 1d1a27b..0ea9179 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -1,5 +1,5 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, GuildMember, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, GuildMember, PermissionFlagsBits } from 'discord.js'; export default class AvatarCommand extends BushCommand { constructor() { @@ -21,14 +21,14 @@ export default class AvatarCommand extends BushCommand { slashType: ApplicationCommandOptionType.User } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], slash: true }); } override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'member'> | ArgType<'globalUser'> }) { - const params: { size: 2048; format: 'png'; dynamic: true } = { size: 2048, format: 'png', dynamic: true }; + const params: { size: 2048; extension: 'png'; dynamic: true } = { size: 2048, extension: 'png', dynamic: true }; const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${Math.ceil(Math.random() * 6) - 1}.png`; const member = (args.user ?? message.member) instanceof GuildMember ? args.user ?? message.member : undefined; diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index d899a95..d23f5b1 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,6 +1,6 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { Embed, Permissions, version as discordJSVersion } from 'discord.js'; +import { Embed, PermissionFlagsBits, version as discordJSVersion } from 'discord.js'; import * as os from 'os'; const { default: prettyBytes } = await import('pretty-bytes'); assert(prettyBytes); @@ -15,7 +15,7 @@ export default class BotInfoCommand extends BushCommand { usage: ['bot-info'], examples: ['bot-info'], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index 0e1be81..6aad1fe 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -9,8 +9,9 @@ import { type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Embed, Permissions, Role } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits, Role } from 'discord.js'; import tinycolor from 'tinycolor2'; + assert(tinycolor); const isValidTinyColor: BushArgumentTypeCaster<string | null> = (_message, phase) => { @@ -40,7 +41,7 @@ export default class ColorCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 03f6441..0aabb70 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -8,7 +8,7 @@ import { GuildMFALevel, GuildPremiumTier, GuildVerificationLevel, - Permissions, + PermissionFlagsBits, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, @@ -36,7 +36,7 @@ export default class GuildInfoCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } @@ -98,14 +98,14 @@ export default class GuildInfoCommand extends BushCommand { ); if (guild.premiumSubscriptionCount) guildAbout.push(`**Boosts:** Level ${guild.premiumTier} with ${guild.premiumSubscriptionCount ?? 0} boosts`); - if (guild.me?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && guild.vanityURLCode) { + if (guild.me?.permissions.has(PermissionFlagsBits.ManageGuild) && guild.vanityURLCode) { const vanityInfo: Vanity = await guild.fetchVanityData(); guildAbout.push(`**Vanity URL:** discord.gg/${vanityInfo.code}`, `**Vanity Uses:** ${vanityInfo.uses?.toLocaleString()}`); } - if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ size: 4096, format: 'png' })})`); - if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, format: 'png' })})`); - if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, format: 'png' })})`); + if (guild.icon) guildAbout.push(`**Icon:** [link](${guild.iconURL({ size: 4096, extension: 'png' })})`); + if (guild.banner) guildAbout.push(`**Banner:** [link](${guild.bannerURL({ size: 4096, extension: 'png' })})`); + if (guild.splash) guildAbout.push(`**Splash:** [link](${guild.splashURL({ size: 4096, extension: 'png' })})`); const EmojiTierMap = { [GuildPremiumTier.Tier3]: 500, @@ -173,7 +173,7 @@ export default class GuildInfoCommand extends BushCommand { .setColor(util.colors.default) .addField({ name: '» About', value: guildAbout.join('\n') }); if (guildStats.length) guildInfoEmbed.addField({ name: '» Stats', value: guildStats.join('\n') }); - const guildIcon = guild.iconURL({ size: 2048, format: 'png' }); + const guildIcon = guild.iconURL({ size: 2048, extension: 'png' }); if (guildIcon) { guildInfoEmbed.setThumbnail(guildIcon); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 67f99d1..e31153b 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -7,7 +7,7 @@ import { ButtonComponent, ButtonStyle, Embed, - Permissions + PermissionFlagsBits } from 'discord.js'; import Fuse from 'fuse.js'; import packageDotJSON from '../../../package.json' assert { type: 'json' }; @@ -47,7 +47,7 @@ export default class HelpCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index ed9ab0f..b40b814 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -1,5 +1,5 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; export default class IconCommand extends BushCommand { constructor() { @@ -9,7 +9,7 @@ export default class IconCommand extends BushCommand { description: "A command to get the server's icon", usage: ['icon'], examples: ['icon'], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], channel: 'guild', slash: true @@ -23,7 +23,7 @@ export default class IconCommand extends BushCommand { .setImage( message.guild!.iconURL({ size: 2048, - format: 'png' + extension: 'png' })! ) .setTitle(util.discord.escapeMarkdown(message.guild!.name)); diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 35e9748..c767361 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,5 +1,5 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Embed, Permissions, type Message } from 'discord.js'; +import { Embed, PermissionFlagsBits, type Message } from 'discord.js'; export default class PingCommand extends BushCommand { public constructor() { @@ -10,7 +10,7 @@ export default class PingCommand extends BushCommand { usage: ['ping'], examples: ['ping'], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 9ba2a2a..652881b 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,5 +1,5 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; export default class PronounsCommand extends BushCommand { public constructor() { @@ -20,7 +20,7 @@ export default class PronounsCommand extends BushCommand { slashType: ApplicationCommandOptionType.User } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], slash: true }); diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index 7efd3ce..3295960 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -2,7 +2,7 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } fr import { ApplicationCommandOptionType, Embed, - Permissions, + PermissionFlagsBits, SnowflakeUtil, type DeconstructedSnowflake, type Guild, @@ -29,7 +29,7 @@ export default class SnowflakeCommand extends BushCommand { slashType: ApplicationCommandOptionType.String } ], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], slash: true }); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 2f35770..66eabe1 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -7,7 +7,7 @@ import { type BushSlashMessage, type BushUser } from '#lib'; -import { ActivityType, ApplicationCommandOptionType, Embed, Permissions, UserFlags } from 'discord.js'; +import { ActivityType, ApplicationCommandOptionType, Embed, PermissionFlagsBits, UserFlags } from 'discord.js'; // TODO: Add bot information export default class UserInfoCommand extends BushCommand { @@ -31,7 +31,7 @@ export default class UserInfoCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } @@ -58,7 +58,7 @@ export default class UserInfoCommand extends BushCommand { const userEmbed: Embed = new Embed() .setTitle(util.discord.escapeMarkdown(user.tag)) - .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png' })) + .setThumbnail(user.displayAvatarURL({ size: 2048, extension: 'png' })) .setTimestamp(); // Flags @@ -78,15 +78,15 @@ export default class UserInfoCommand extends BushCommand { Number(user.discriminator) < 10 || client.consts.mappings.maybeNitroDiscrims.includes(user.discriminator) || user.displayAvatarURL()?.endsWith('.gif') || - user.flags?.has(UserFlags.FLAGS.PARTNER) || - user.flags?.has(UserFlags.FLAGS.STAFF) || + user.flags?.has(UserFlags.Partner) || + user.flags?.has(UserFlags.Staff) || member?.avatar // server avatar ) { emojis.push(client.consts.mappings.otherEmojis.Nitro); } if (guild?.ownerId == user.id) emojis.push(client.consts.mappings.otherEmojis.Owner); - else if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) emojis.push(client.consts.mappings.otherEmojis.Admin); + else if (member?.permissions.has(PermissionFlagsBits.Administrator)) emojis.push(client.consts.mappings.otherEmojis.Admin); if (member?.premiumSinceTimestamp) emojis.push(client.consts.mappings.otherEmojis.Booster); const createdAt = util.timestamp(user.createdAt), @@ -99,7 +99,7 @@ export default class UserInfoCommand extends BushCommand { // General Info const generalInfo = [`**Mention:** <@${user.id}>`, `**ID:** ${user.id}`, `**Created:** ${createdAt} (${createdAtDelta} ago)`]; if (user.accentColor !== null) generalInfo.push(`**Accent Color:** ${user.hexAccentColor}`); - if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ format: 'png', size: 4096 })})`); + if (user.banner) generalInfo.push(`**Banner:** [link](${user.bannerURL({ extension: 'png', size: 4096 })})`); const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`); @@ -173,7 +173,7 @@ export default class UserInfoCommand extends BushCommand { // Important Perms const perms = []; - if (member?.permissions.has(Permissions.FLAGS.ADMINISTRATOR) || guild?.ownerId == user.id) { + if (member?.permissions.has(PermissionFlagsBits.Administrator) || guild?.ownerId == user.id) { perms.push('`Administrator`'); } else if (member?.permissions.toArray().length) { member.permissions.toArray().forEach((permission) => { @@ -184,7 +184,7 @@ export default class UserInfoCommand extends BushCommand { } if (perms.length) userEmbed.addField({ name: '» Important Perms', value: perms.join(' ') }); - if (emojis) userEmbed.setDescription(`\u200B${emojis.join(' ')}`); // zero width space + if (emojis) userEmbed.setDescription(`\u200B${emojis.filter((e) => e).join(' ')}`); // zero width space return userEmbed; } } diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts index 3a00036..eb8b90c 100644 --- a/src/commands/leveling/leaderboard.ts +++ b/src/commands/leveling/leaderboard.ts @@ -1,5 +1,5 @@ import { BushCommand, ButtonPaginator, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; export default class LeaderboardCommand extends BushCommand { public constructor() { @@ -32,7 +32,7 @@ export default class LeaderboardCommand extends BushCommand { if (!(await message.guild.hasFeature('leveling'))) return await message.util.reply( `${util.emojis.error} This command can only be run in servers with the leveling feature enabled.${ - message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) + message.member?.permissions.has(PermissionFlagsBits.ManageGuild) ? ` You can toggle features using the \`${util.prefix(message)}features\` command.` : '' }` diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index 18648e8..271c3f6 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -12,7 +12,7 @@ import { import { SimplifyNumber } from '@notenoughupdates/simplify-number'; import assert from 'assert'; import canvas from 'canvas'; -import { ApplicationCommandOptionType, MessageAttachment, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, MessageAttachment, PermissionFlagsBits } from 'discord.js'; import got from 'got'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; @@ -51,7 +51,7 @@ export default class LevelCommand extends BushCommand { if (!(await message.guild.hasFeature('leveling'))) return await message.util.reply( `${util.emojis.error} This command can only be run in servers with the leveling feature enabled.${ - message.member?.permissions.has(Permissions.FLAGS.MANAGE_GUILD) + message.member?.permissions.has(PermissionFlagsBits.ManageGuild) ? ` You can toggle features using the \`${util.prefix(message)}features\` command.` : '' }` @@ -96,7 +96,7 @@ export default class LevelCommand extends BushCommand { ctx.fillRect(0, 0, levelCard.width, levelCard.height); // Draw avatar const AVATAR_SIZE = 128; - const avatarBuffer = await got.get(user.displayAvatarURL({ format: 'png', size: AVATAR_SIZE })).buffer(); + const avatarBuffer = await got.get(user.displayAvatarURL({ extension: 'png', size: AVATAR_SIZE })).buffer(); const avatarImage = new canvas.Image(); avatarImage.src = avatarBuffer; const imageTopCoord = levelCard.height / 2 - AVATAR_SIZE / 2; diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts index 115ace1..c15ebcb 100644 --- a/src/commands/leveling/levelRoles.ts +++ b/src/commands/leveling/levelRoles.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class LevelRolesCommand extends BushCommand { public constructor() { @@ -33,8 +33,8 @@ export default class LevelRolesCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), - userPermissions: [Permissions.FLAGS.MANAGE_GUILD, Permissions.FLAGS.MANAGE_ROLES] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + userPermissions: [PermissionFlagsBits.ManageGuild, PermissionFlagsBits.ManageRoles] }); } diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts index 29f36e0..1016280 100644 --- a/src/commands/leveling/setLevel.ts +++ b/src/commands/leveling/setLevel.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class SetLevelCommand extends BushCommand { public constructor() { @@ -30,7 +30,7 @@ export default class SetLevelCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.ADMINISTRATOR] + userPermissions: [PermissionFlagsBits.Administrator] }); } diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts index 721f28f..a86c58a 100644 --- a/src/commands/leveling/setXp.ts +++ b/src/commands/leveling/setXp.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, Level, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class SetXpCommand extends BushCommand { public constructor() { @@ -31,7 +31,7 @@ export default class SetXpCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: [Permissions.FLAGS.ADMINISTRATOR] + userPermissions: [PermissionFlagsBits.Administrator] }); } diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts index 5b1674c..cffc39f 100644 --- a/src/commands/moderation/_activePunishments.ts +++ b/src/commands/moderation/_activePunishments.ts @@ -38,7 +38,7 @@ // channel: 'guild', // hidden: true, // clientPermissions: (m) => util.clientSendAndPermCheck(m), -// userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) +// userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) // }); // } // diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 33f980d..209397c 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -8,7 +8,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, Permissions, type User } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type User } from 'discord.js'; export default class BanCommand extends BushCommand { public constructor() { @@ -62,8 +62,8 @@ export default class BanCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: [Permissions.FLAGS.BAN_MEMBERS], - userPermissions: [Permissions.FLAGS.BAN_MEMBERS] + clientPermissions: [PermissionFlagsBits.BanMembers], + userPermissions: [PermissionFlagsBits.BanMembers] }); } diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts index 0b6458d..20c6e86 100644 --- a/src/commands/moderation/block.ts +++ b/src/commands/moderation/block.ts @@ -11,7 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class BlockCommand extends BushCommand { public constructor() { @@ -53,8 +53,8 @@ export default class BlockCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index 84138f6..d951f3d 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -1,7 +1,7 @@ import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib'; import { ArgumentGeneratorReturn } from 'discord-akairo'; import { ArgumentTypeCasterReturn } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class EvidenceCommand extends BushCommand { public constructor() { @@ -32,7 +32,7 @@ export default class EvidenceCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts index 2c71119..a59380f 100644 --- a/src/commands/moderation/hideCase.ts +++ b/src/commands/moderation/hideCase.ts @@ -1,5 +1,5 @@ import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class HideCaseCommand extends BushCommand { public constructor() { @@ -21,7 +21,7 @@ export default class HideCaseCommand extends BushCommand { ], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]), channel: 'guild' }); } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 4fd6c10..6dfb09b 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -7,7 +7,7 @@ import { type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class KickCommand extends BushCommand { public constructor() { @@ -48,8 +48,8 @@ export default class KickCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.KICK_MEMBERS]), - userPermissions: [Permissions.FLAGS.KICK_MEMBERS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.KickMembers]), + userPermissions: [PermissionFlagsBits.KickMembers] }); } diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index ea7c08b..3e4f05b 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -11,7 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, ChannelType, Collection, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, Collection, PermissionFlagsBits } from 'discord.js'; export default class LockdownCommand extends BushCommand { public constructor() { @@ -58,8 +58,8 @@ export default class LockdownCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), - userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + userPermissions: [PermissionFlagsBits.ManageChannels] }); } @@ -71,7 +71,6 @@ export default class LockdownCommand extends BushCommand { all: ArgType<'boolean'>; } ) { - client.console.debug('lockdown command'); return await LockdownCommand.lockdownOrUnlockdown(message, args, 'lockdown'); } diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index d6ecc37..6b8ae2d 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,5 +1,5 @@ import { BushCommand, ButtonPaginator, ModLog, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions, User } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits, User } from 'discord.js'; export default class ModlogCommand extends BushCommand { public constructor() { @@ -31,7 +31,7 @@ export default class ModlogCommand extends BushCommand { ], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index ea935ce..c97ceb7 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -9,7 +9,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class MuteCommand extends BushCommand { public constructor() { @@ -51,8 +51,8 @@ export default class MuteCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index b48f997..c882b7f 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Collection, Permissions, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, Collection, PermissionFlagsBits, type Snowflake } from 'discord.js'; export default class PurgeCommand extends BushCommand { public constructor() { @@ -43,8 +43,8 @@ export default class PurgeCommand extends BushCommand { ], slash: true, clientPermissions: (m) => - util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true), - userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES], + util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.EmbedLinks], true), + userPermissions: [PermissionFlagsBits.ManageMessages], channel: 'guild' }); } diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index 61759ae..092b8ac 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Message, Permissions, type Emoji } from 'discord.js'; +import { ApplicationCommandOptionType, Message, PermissionFlagsBits, type Emoji } from 'discord.js'; export default class RemoveReactionEmojiCommand extends BushCommand { public constructor() { @@ -33,8 +33,8 @@ export default class RemoveReactionEmojiCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => - util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true), - userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS] // Can't undo the removal of 1000s of reactions + util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.EmbedLinks], true), + userPermissions: [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.ManageEmojisAndStickers] // Can't undo the removal of 1000s of reactions }); } diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 0d4d91b..b76795b 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -9,7 +9,7 @@ import { type OptionalArgType } from '#lib'; import { type ArgumentOptions, type Flag } from 'discord-akairo'; -import { ApplicationCommandOptionType, Permissions, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits, type Snowflake } from 'discord.js'; export default class RoleCommand extends BushCommand { public constructor() { @@ -61,7 +61,7 @@ export default class RoleCommand extends BushCommand { channel: 'guild', typing: true, clientPermissions: (m) => - util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES, Permissions.FLAGS.EMBED_LINKS], true), + util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles, PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } @@ -130,7 +130,7 @@ export default class RoleCommand extends BushCommand { if (!args.role) return await message.util.reply(`${util.emojis.error} You must specify a role.`); if (args.duration === null) args.duration = 0; if ( - !message.member!.permissions.has(Permissions.FLAGS.MANAGE_ROLES) && + !message.member!.permissions.has(PermissionFlagsBits.ManageRoles) && message.member!.id !== message.guild?.ownerId && !message.member!.user.isOwner() ) { diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 96c3881..fb446d1 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import { Argument } from 'discord-akairo'; -import { ApplicationCommandOptionType, ChannelType, Permissions, type TextChannel, type ThreadChannel } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits, type TextChannel, type ThreadChannel } from 'discord.js'; export default class SlowmodeCommand extends BushCommand { public constructor() { @@ -35,8 +35,8 @@ export default class SlowmodeCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => - util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS, Permissions.FLAGS.EMBED_LINKS], true), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels, PermissionFlagsBits.EmbedLinks], true), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts index 73b9d50..32fcf76 100644 --- a/src/commands/moderation/timeout.ts +++ b/src/commands/moderation/timeout.ts @@ -8,7 +8,7 @@ import { type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class TimeoutCommand extends BushCommand { public constructor() { @@ -49,8 +49,8 @@ export default class TimeoutCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]), - userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ModerateMembers]), + userPermissions: [PermissionFlagsBits.ModerateMembers] }); } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index b2bdd72..7bdb32e 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -7,7 +7,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class UnbanCommand extends BushCommand { public constructor() { @@ -39,8 +39,8 @@ export default class UnbanCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: [Permissions.FLAGS.BAN_MEMBERS], - userPermissions: [Permissions.FLAGS.BAN_MEMBERS] + clientPermissions: [PermissionFlagsBits.BanMembers], + userPermissions: [PermissionFlagsBits.BanMembers] }); } diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts index 1abf2be..7d36e15 100644 --- a/src/commands/moderation/unblock.ts +++ b/src/commands/moderation/unblock.ts @@ -11,7 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class UnblockCommand extends BushCommand { public constructor() { @@ -53,8 +53,8 @@ export default class UnblockCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts index ea36b67..4694518 100644 --- a/src/commands/moderation/unlockdown.ts +++ b/src/commands/moderation/unlockdown.ts @@ -1,6 +1,6 @@ import { LockdownCommand } from '#commands'; import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, ChannelType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js'; export default class UnlockdownCommand extends BushCommand { public constructor() { @@ -47,8 +47,8 @@ export default class UnlockdownCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), - userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), + userPermissions: [PermissionFlagsBits.ManageChannels] }); } diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 9974b8d..fb4bb55 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -9,7 +9,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class UnmuteCommand extends BushCommand { public constructor() { @@ -51,8 +51,8 @@ export default class UnmuteCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts index 6ebd777..6d3632d 100644 --- a/src/commands/moderation/untimeout.ts +++ b/src/commands/moderation/untimeout.ts @@ -9,7 +9,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class UntimeoutCommand extends BushCommand { public constructor() { @@ -51,8 +51,8 @@ export default class UntimeoutCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]), - userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ModerateMembers]), + userPermissions: [PermissionFlagsBits.ModerateMembers] }); } diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index af45782..27d04b3 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -9,7 +9,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; export default class WarnCommand extends BushCommand { public constructor() { @@ -51,7 +51,7 @@ export default class WarnCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) + userPermissions: (m) => util.userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) }); } diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts index 7f261d5..e568036 100644 --- a/src/commands/moulberry-bush/capePermissions.ts +++ b/src/commands/moulberry-bush/capePermissions.ts @@ -1,5 +1,5 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; import got from 'got'; export default class CapePermissionsCommand extends BushCommand { @@ -21,7 +21,7 @@ export default class CapePermissionsCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], channel: 'guild' }); diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts index 7965713..8c080e3 100644 --- a/src/commands/moulberry-bush/capes.ts +++ b/src/commands/moulberry-bush/capes.ts @@ -1,7 +1,7 @@ import { BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptionalArgType } from '#lib'; import assert from 'assert'; import { APIEmbed } from 'discord-api-types'; -import { ApplicationCommandOptionType, AutocompleteInteraction, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js'; import Fuse from 'fuse.js'; import got from 'got'; @@ -29,7 +29,7 @@ export default class CapesCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts index dbbb613..dd305c6 100644 --- a/src/commands/moulberry-bush/giveawayPing.ts +++ b/src/commands/moulberry-bush/giveawayPing.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, type BushMessage } from '#lib'; -import { Permissions } from 'discord.js'; +import { PermissionFlagsBits } from 'discord.js'; export default class GiveawayPingCommand extends BushCommand { public constructor() { @@ -9,13 +9,13 @@ export default class GiveawayPingCommand extends BushCommand { description: 'Pings the giveaway role.', usage: ['giveaway-ping'], examples: ['giveaway-ping'], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages], true), userPermissions: [ - Permissions.FLAGS.MANAGE_GUILD, - Permissions.FLAGS.MANAGE_MESSAGES, - Permissions.FLAGS.BAN_MEMBERS, - Permissions.FLAGS.KICK_MEMBERS, - Permissions.FLAGS.VIEW_CHANNEL + PermissionFlagsBits.ManageGuild, + PermissionFlagsBits.ManageMessages, + PermissionFlagsBits.BanMembers, + PermissionFlagsBits.KickMembers, + PermissionFlagsBits.ViewChannel ], channel: 'guild', ignoreCooldown: [], @@ -29,8 +29,8 @@ export default class GiveawayPingCommand extends BushCommand { } public override async exec(message: BushMessage) { - if (!message.member!.permissions.has(Permissions.FLAGS.MANAGE_GUILD) && !message.member!.user.isOwner()) - await message.util.reply(`${util.emojis.error} You are missing the **MANAGE_GUILD** permission.`); + if (!message.member!.permissions.has(PermissionFlagsBits.ManageGuild) && !message.member!.user.isOwner()) + await message.util.reply(`${util.emojis.error} You are missing the **ManageGuild** permission.`); await message.delete().catch(() => {}); diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts index 6aa5ca3..9a16545 100644 --- a/src/commands/moulberry-bush/moulHammer.ts +++ b/src/commands/moulberry-bush/moulHammer.ts @@ -1,5 +1,5 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; export default class MoulHammerCommand extends BushCommand { public constructor() { @@ -22,7 +22,7 @@ export default class MoulHammerCommand extends BushCommand { slash: true, slashGuilds: ['516977525906341928'], restrictedGuilds: ['516977525906341928'], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index a2a18ef..7b3e729 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; import moment from 'moment'; assert(moment); @@ -34,7 +34,7 @@ export default class ReportCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], channel: 'guild' }); diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index dfb65f3..5eb2b98 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, BushSlashMessage, type BushMessage, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, Embed, PermissionFlagsBits } from 'discord.js'; const rules = [ { @@ -85,7 +85,7 @@ export default class RuleCommand extends BushCommand { slash: true, slashGuilds: ['516977525906341928'], channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], restrictedGuilds: ['516977525906341928'] }); diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts index 435b99e..35240f9 100644 --- a/src/commands/moulberry-bush/serverStatus.ts +++ b/src/commands/moulberry-bush/serverStatus.ts @@ -1,6 +1,6 @@ import { BushCommand, type BushMessage } from '#lib'; import assert from 'assert'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; import got from 'got'; assert(got); @@ -13,7 +13,7 @@ export default class ServerStatusCommand extends BushCommand { description: "Gives the status of moulberry's server", usage: ['server-status'], examples: ['server-status', 'ss'], - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], slash: true }); diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 5a56978..52cad26 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -163,10 +163,9 @@ export default class ActivityCommand extends BushCommand { : activityTypeCaster(message, args.activity); let response: string; - const invite = await (<any>client).api - .channels(channel.id) - .invites.post({ - data: { + const invite: any = await client.rest + .post(`/channels/${channel.id}/invites`, { + body: { validate: null, max_age: 604800, max_uses: 0, @@ -175,6 +174,7 @@ export default class ActivityCommand extends BushCommand { temporary: false } }) + .catch((e: Error | DiscordAPIError) => { if ((e as DiscordAPIError)?.code === 50013) { response = `${util.emojis.error} I am missing permissions to make an invite in that channel.`; diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts index 2df70b7..ffc121c 100644 --- a/src/commands/utilities/price.ts +++ b/src/commands/utilities/price.ts @@ -1,6 +1,6 @@ import { BushCommand, type BushMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, AutocompleteInteraction, Embed, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction, Embed, PermissionFlagsBits } from 'discord.js'; import Fuse from 'fuse.js'; import got from 'got'; @@ -39,7 +39,7 @@ export default class PriceCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [], typing: true }); diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts index 369a1a5..509da67 100644 --- a/src/commands/utilities/reminders.ts +++ b/src/commands/utilities/reminders.ts @@ -1,7 +1,7 @@ import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; import { APIEmbed } from 'discord-api-types'; -import { Permissions } from 'discord.js'; +import { PermissionFlagsBits } from 'discord.js'; import { Op } from 'sequelize'; assert(Op); @@ -15,7 +15,7 @@ export default class RemindersCommand extends BushCommand { usage: ['reminder'], examples: ['reminders'], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS]), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks]), userPermissions: [] }); } diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index a963746..820fa89 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,7 +1,7 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; import { type ArgumentOptions, type ArgumentType, type ArgumentTypeCaster, type Flag } from 'discord-akairo'; -import { ApplicationCommandOptionType, Permissions } from 'discord.js'; +import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; import _ from 'lodash'; import { URL } from 'url'; @@ -39,8 +39,8 @@ export default class StealCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS]), - userPermissions: [Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.ManageEmojisAndStickers]), + userPermissions: [PermissionFlagsBits.ManageEmojisAndStickers] }); } diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts index fc50e31..ee57e2d 100644 --- a/src/commands/utilities/viewRaw.ts +++ b/src/commands/utilities/viewRaw.ts @@ -7,7 +7,7 @@ import { type BushTextChannel, type OptionalArgType } from '#lib'; -import { ApplicationCommandOptionType, ChannelType, Embed, Message, Permissions, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, Embed, Message, PermissionFlagsBits, type Snowflake } from 'discord.js'; export default class ViewRawCommand extends BushCommand { public constructor() { @@ -65,7 +65,7 @@ export default class ViewRawCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.EMBED_LINKS], true), + clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), userPermissions: [] }); } diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts index c57d581..8d94dab 100644 --- a/src/lib/common/AutoMod.ts +++ b/src/lib/common/AutoMod.ts @@ -6,7 +6,7 @@ import { ChannelType, Embed, GuildMember, - Permissions, + PermissionFlagsBits, type TextChannel } from 'discord.js'; @@ -120,7 +120,7 @@ export class AutoMod { if (!includes('@everyone') && !includes('@here')) return; // It would be bad if we deleted a message that actually pinged @everyone or @here if ( - this.message.member?.permissionsIn(this.message.channelId).has(Permissions.FLAGS.MENTION_EVERYONE) || + this.message.member?.permissionsIn(this.message.channelId).has(PermissionFlagsBits.MentionEveryone) || this.message.mentions.everyone ) return; @@ -291,7 +291,7 @@ export class AutoMod { * @param interaction The button interaction. */ public static async handleInteraction(interaction: BushButtonInteraction) { - if (!interaction.memberPermissions?.has(Permissions.FLAGS.BAN_MEMBERS)) + if (!interaction.memberPermissions?.has(PermissionFlagsBits.BanMembers)) return interaction.reply({ content: `${util.emojis.error} You are missing the **Ban Members** permission.`, ephemeral: true diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts index 62dbc90..0ba6fca 100644 --- a/src/lib/common/util/Moderation.ts +++ b/src/lib/common/util/Moderation.ts @@ -10,7 +10,7 @@ import { type BushUserResolvable, type ModLogType } from '#lib'; -import { Embed, Permissions, type Snowflake } from 'discord.js'; +import { Embed, PermissionFlagsBits, type Snowflake } from 'discord.js'; /** * A utility class with moderation-related methods. @@ -72,7 +72,7 @@ export class Moderation { } if ( checkModerator && - victim.permissions.has(Permissions.FLAGS.MANAGE_MESSAGES) && + victim.permissions.has(PermissionFlagsBits.ManageMessages) && !(type.startsWith('un') && moderator.id === victim.id) ) { if (await moderator.guild.hasFeature('modsCanPunishMods')) { diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 712d610..ce72ee2 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -25,8 +25,8 @@ import * as Sentry from '@sentry/node'; import { AkairoClient, ContextMenuCommandHandler, version as akairoVersion } from 'discord-akairo'; import { ActivityType, - Intents, Options, + Partials, Structures, version as discordJsVersion, type Awaitable, @@ -189,21 +189,18 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re public constructor(config: Config) { super({ ownerID: config.owners, - intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0), - partials: ['USER', 'CHANNEL', 'GUILD_MEMBER', 'MESSAGE', 'REACTION', 'GUILD_SCHEDULED_EVENT'], + intents: Object.keys(GatewayIntentBits) + .map((i) => (typeof i === 'string' ? GatewayIntentBits[i as keyof typeof GatewayIntentBits] : i)) + .reduce((acc, p) => acc | p, 0), + partials: Object.keys(Partials).map((p) => Partials[p as keyof typeof Partials]), presence: { - activities: [ - { - name: 'Beep Boop', - type: ActivityType.Watching - } - ], + activities: [{ name: 'Beep Boop', type: ActivityType.Watching }], status: 'online' }, - http: { api: 'https://canary.discord.com/api' }, allowedMentions: AllowedMentions.users(), // No everyone or role mentions by default makeCache: Options.cacheWithLimits({}), - failIfNotExists: false + failIfNotExists: false, + rest: { api: 'https://canary.discord.com/api' } }); patch(this); @@ -211,7 +208,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re this.config = config; this.util = new BushClientUtil(this); - /* handlers */ + /* =-=-= handlers =-=-= */ this.listenerHandler = new BushListenerHandler(this, { directory: path.join(__dirname, '..', '..', '..', 'listeners'), automateCategories: true @@ -238,12 +235,12 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re commandUtilLifetime: 300_000, // 5 minutes argumentDefaults: { prompt: { - start: 'Placeholder argument prompt. If you see this please tell my developers.', - retry: 'Placeholder failed argument prompt. If you see this please tell my developers.', + start: 'Placeholder argument prompt. **If you see this please tell my developers**.', + retry: 'Placeholder failed argument prompt. **If you see this please tell my developers**.', modifyStart: (_: Message, str: string): string => `${str}\n\n Type \`cancel\` to cancel the command`, modifyRetry: (_: Message, str: string): string => `${str.replace('{error}', this.util.emojis.error)}\n\n Type \`cancel\` to cancel the command`, - timeout: 'You took too long the command has been cancelled', + timeout: ':hourglass: You took too long the command has been cancelled.', ended: 'You exceeded the maximum amount of tries the command has been cancelled', cancel: 'The command has been cancelled', retries: 3, @@ -262,7 +259,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re automateCategories: true }); - /* databases */ + /* =-=-= databases =-=-= */ const sharedDBOptions: SequelizeOptions = { username: this.config.db.username, password: this.config.db.password, @@ -281,8 +278,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re database: 'bushbot-shared' }); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - /* global objects */ + /* =-=-= global objects =-=-= */ global.client = this; global.util = this.util; } @@ -351,7 +347,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re contextMenuCommandHandler: this.contextMenuCommandHandler, process, stdin: rl, - gateway: this.ws + gateway: this.ws, + rest: this.rest }); this.commandHandler.resolver.addTypes({ duration, @@ -515,3 +512,23 @@ export interface BushStats { */ commandsUsed: bigint; } + +// exported as const enum from discord-api-types +enum GatewayIntentBits { + Guilds = 1, + GuildMembers = 2, + GuildBans = 4, + GuildEmojisAndStickers = 8, + GuildIntegrations = 16, + GuildWebhooks = 32, + GuildInvites = 64, + GuildVoiceStates = 128, + GuildPresences = 256, + GuildMessages = 512, + GuildMessageReactions = 1024, + GuildMessageTyping = 2048, + DirectMessages = 4096, + DirectMessageReactions = 8192, + DirectMessageTyping = 16384, + GuildScheduledEvents = 65536 +} diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index e3c0803..7a4d5b0 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -20,12 +20,13 @@ import { humanizeDuration } from '@notenoughupdates/humanize-duration'; import { exec } from 'child_process'; import deepLock from 'deep-lock'; import { ClientUtil, Util as AkairoUtil } from 'discord-akairo'; -import type { APIMessage } from 'discord-api-types'; +import { APIMessage } from 'discord-api-types'; import { Constants as DiscordConstants, GuildMember, Message, - Permissions, + PermissionFlagsBits, + PermissionsBitField, ThreadMember, User, Util as DiscordUtil, @@ -404,8 +405,8 @@ export class BushClientUtil extends ClientUtil { * @returns The combined elements or `ifEmpty`. * * @example - * const permissions = oxford([Permissions.FLAGS.ADMINISTRATOR, Permissions.FLAGS.SEND_MESSAGES, Permissions.FLAGS.MANAGE_MESSAGES], 'and', 'none'); - * console.log(permissions); // ADMINISTRATOR, SEND_MESSAGES and MANAGE_MESSAGES + * const permissions = oxford([PermissionFlagsBits.Administrator, PermissionFlagsBits.SendMessages, PermissionFlagsBits.ManageMessages], 'and', 'none'); + * console.log(permissions); // Administrator, SendMessages and ManageMessages */ public oxford(array: string[], conjunction: string, ifEmpty?: string): string | undefined { const l = array.length; @@ -767,7 +768,7 @@ export class BushClientUtil extends ClientUtil { public userGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]) { const missing = message.member?.permissions.missing(permissions) ?? []; - return missing.length ? missing.map((p) => Permissions.FLAGS[p]) : null; + return missing.length ? missing.map((p) => PermissionFlagsBits[p]) : null; } /** @@ -779,7 +780,7 @@ export class BushClientUtil extends ClientUtil { public clientGuildPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[]) { const missing = message.guild?.me?.permissions.missing(permissions) ?? []; - return missing.length ? missing.map((p) => Permissions.FLAGS[p]) : null; + return missing.length ? missing.map((p) => PermissionFlagsBits[p]) : null; } /** @@ -792,7 +793,7 @@ export class BushClientUtil extends ClientUtil { */ public clientSendAndPermCheck(message: BushMessage | BushSlashMessage, permissions: bigint[] = [], checkChannel = false) { const missing = []; - const sendPerm = message.channel!.isThread() ? Permissions.FLAGS.SEND_MESSAGES : Permissions.FLAGS.SEND_MESSAGES_IN_THREADS; + const sendPerm = message.channel!.isThread() ? PermissionFlagsBits.SendMessages : PermissionFlagsBits.SendMessagesInThreads; if (!message.inGuild()) return null; if (!message.guild.me!.permissionsIn(message.channel.id).has(sendPerm)) missing.push(sendPerm); @@ -802,7 +803,7 @@ export class BushClientUtil extends ClientUtil { ? message .guild!.me!.permissionsIn(message.channel!.id!) .missing(permissions) - .map((p) => Permissions.FLAGS[p]) + .map((p) => PermissionFlagsBits[p]) : this.clientGuildPermCheck(message, permissions) ?? []) ); @@ -875,7 +876,7 @@ export class BushClientUtil extends ClientUtil { return `https://discord.com/api/oauth2/authorize?client_id=${Buffer.from( client.token!.split('.')[0], 'base64' - ).toString()}&permissions=${Permissions.ALL}&scope=bot%20applications.commands`; + ).toString()}&permissions=${PermissionsBitField.All}&scope=bot%20applications.commands`; } /** diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 0456b80..650b538 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -51,7 +51,7 @@ import { type Collection, type Invite, type PermissionResolvable, - type PermissionString, + type PermissionsString, type Snowflake } from 'discord.js'; @@ -106,7 +106,7 @@ export interface OverriddenBaseArgumentType extends BaseArgumentType { export interface BaseBushArgumentType extends OverriddenBaseArgumentType { duration: number | null; contentWithDuration: ParsedDuration; - permission: PermissionString | null; + permission: PermissionsString | null; snowflake: Snowflake | null; discordEmoji: DiscordEmojiInfo | null; roleWithDuration: RoleWithDuration | null; diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 6c06c5b..2c1903f 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -1,6 +1,6 @@ import { type BushClient, type BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { CommandHandler, type Category, type CommandHandlerEvents, type CommandHandlerOptions } from 'discord-akairo'; -import { type Collection, type PermissionString } from 'discord.js'; +import { type Collection, type PermissionsString } from 'discord.js'; export type BushCommandHandlerOptions = CommandHandlerOptions; @@ -18,7 +18,7 @@ export interface BushCommandHandlerEvents extends CommandHandlerEvents { load: [command: BushCommand, isReload: boolean]; messageBlocked: [message: BushMessage | BushSlashMessage, reason: string]; messageInvalid: [message: BushMessage]; - missingPermissions: [message: BushMessage, command: BushCommand, type: 'client' | 'user', missing: Array<PermissionString>]; + missingPermissions: [message: BushMessage, command: BushCommand, type: 'client' | 'user', missing: PermissionsString[]]; remove: [command: BushCommand]; slashBlocked: [message: BushSlashMessage, command: BushCommand, reason: string]; slashError: [error: Error, message: BushSlashMessage, command: BushCommand]; @@ -27,7 +27,7 @@ export interface BushCommandHandlerEvents extends CommandHandlerEvents { message: BushSlashMessage, command: BushCommand, type: 'client' | 'user', - missing: Array<PermissionString> + missing: PermissionsString[] ]; slashStarted: [message: BushSlashMessage, command: BushCommand, args: any]; } 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. diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index e7b69ae..df8212b 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -171,49 +171,47 @@ export class BushConstants { }, permissions: { - CREATE_INSTANT_INVITE: { name: 'Create Invite', important: false }, - KICK_MEMBERS: { name: 'Kick Members', important: true }, - BAN_MEMBERS: { name: 'Ban Members', important: true }, - ADMINISTRATOR: { name: 'Administrator', important: true }, - MANAGE_CHANNELS: { name: 'Manage Channels', important: true }, - MANAGE_GUILD: { name: 'Manage Server', important: true }, - ADD_REACTIONS: { name: 'Add Reactions', important: false }, - VIEW_AUDIT_LOG: { name: 'View Audit Log', important: true }, - PRIORITY_SPEAKER: { name: 'Priority Speaker', important: true }, - STREAM: { name: 'Video', important: false }, - VIEW_CHANNEL: { name: 'View Channel', important: false }, - SEND_MESSAGES: { name: 'Send Messages', important: false }, - SEND_TTS_MESSAGES: { name: 'Send Text-to-Speech Messages', important: true }, - MANAGE_MESSAGES: { name: 'Manage Messages', important: true }, - EMBED_LINKS: { name: 'Embed Links', important: false }, - ATTACH_FILES: { name: 'Attach Files', important: false }, - READ_MESSAGE_HISTORY: { name: 'Read Message History', important: false }, - MENTION_EVERYONE: { name: 'Mention @\u200Beveryone, @\u200Bhere, and All Roles', important: true }, // name has a zero-width space to prevent accidents - USE_EXTERNAL_EMOJIS: { name: 'Use External Emoji', important: false }, - VIEW_GUILD_INSIGHTS: { name: 'View Server Insights', important: true }, - CONNECT: { name: 'Connect', important: false }, - SPEAK: { name: 'Speak', important: false }, - MUTE_MEMBERS: { name: 'Mute Members', important: true }, - DEAFEN_MEMBERS: { name: 'Deafen Members', important: true }, - MOVE_MEMBERS: { name: 'Move Members', important: true }, - USE_VAD: { name: 'Use Voice Activity', important: false }, - CHANGE_NICKNAME: { name: 'Change Nickname', important: false }, - MANAGE_NICKNAMES: { name: 'Change Nicknames', important: true }, - MANAGE_ROLES: { name: 'Manage Roles', important: true }, - MANAGE_WEBHOOKS: { name: 'Manage Webhooks', important: true }, - MANAGE_EMOJIS_AND_STICKERS: { name: 'Manage Emojis and Stickers', important: true }, - USE_APPLICATION_COMMANDS: { name: 'Use Slash Commands', important: false }, - REQUEST_TO_SPEAK: { name: 'Request to Speak', important: false }, - MANAGE_THREADS: { name: 'Manage Threads', important: true }, - USE_PUBLIC_THREADS: { name: 'Use public Threads', important: false }, - CREATE_PUBLIC_THREADS: { name: 'Create Public Threads', important: false }, - USE_PRIVATE_THREADS: { name: 'Use Private Threads', important: false }, - CREATE_PRIVATE_THREADS: { name: 'Create Private Threads', important: false }, - USE_EXTERNAL_STICKERS: { name: 'Use External Stickers', important: false }, - SEND_MESSAGES_IN_THREADS: { name: 'Send Messages In Threads', important: false }, - START_EMBEDDED_ACTIVITIES: { name: 'Start Activities', important: false }, - MODERATE_MEMBERS: { name: 'Timeout Members', important: true }, - MANAGE_EVENTS: { name: 'Manage Events', important: true } + CreateInstantInvite: { name: 'Create Invite', important: false }, + KickMembers: { name: 'Kick Members', important: true }, + BanMembers: { name: 'Ban Members', important: true }, + Administrator: { name: 'Administrator', important: true }, + ManageChannels: { name: 'Manage Channels', important: true }, + ManageGuild: { name: 'Manage Server', important: true }, + AddReactions: { name: 'Add Reactions', important: false }, + ViewAuditLog: { name: 'View Audit Log', important: true }, + PrioritySpeaker: { name: 'Priority Speaker', important: true }, + Stream: { name: 'Video', important: false }, + ViewChannel: { name: 'View Channel', important: false }, + SendMessages: { name: 'Send Messages', important: false }, + SendTTSMessages: { name: 'Send Text-to-Speech Messages', important: true }, + ManageMessages: { name: 'Manage Messages', important: true }, + EmbedLinks: { name: 'Embed Links', important: false }, + AttachFiles: { name: 'Attach Files', important: false }, + ReadMessageHistory: { name: 'Read Message History', important: false }, + MentionEveryone: { name: 'Mention @\u200Beveryone, @\u200Bhere, and All Roles', important: true }, // name has a zero-width space to prevent accidents + UseExternalEmojis: { name: 'Use External Emoji', important: false }, + ViewGuildInsights: { name: 'View Server Insights', important: true }, + Connect: { name: 'Connect', important: false }, + Speak: { name: 'Speak', important: false }, + MuteMembers: { name: 'Mute Members', important: true }, + DeafenMembers: { name: 'Deafen Members', important: true }, + MoveMembers: { name: 'Move Members', important: true }, + UseVAD: { name: 'Use Voice Activity', important: false }, + ChangeNickname: { name: 'Change Nickname', important: false }, + ManageNicknames: { name: 'Change Nicknames', important: true }, + ManageRoles: { name: 'Manage Roles', important: true }, + ManageWebhooks: { name: 'Manage Webhooks', important: true }, + ManageEmojisAndStickers: { name: 'Manage Emojis and Stickers', important: true }, + UseApplicationCommands: { name: 'Use Slash Commands', important: false }, + RequestToSpeak: { name: 'Request to Speak', important: false }, + ManageEvents: { name: 'Manage Events', important: true }, + ManageThreads: { name: 'Manage Threads', important: true }, + CreatePublicThreads: { name: 'Create Public Threads', important: false }, + CreatePrivateThreads: { name: 'Create Private Threads', important: false }, + UseExternalStickers: { name: 'Use External Stickers', important: false }, + SendMessagesInThreads: { name: 'Send Messages In Threads', important: false }, + StartEmbeddedActivities: { name: 'Start Activities', important: false }, + ModerateMembers: { name: 'Timeout Members', important: true } }, // prettier-ignore @@ -294,20 +292,21 @@ export class BushConstants { }, userFlags: { - STAFF: '<:discordEmployee:848742947826434079>', - PARTNER: '<:partneredServerOwner:848743051593777152>', - HYPESQUAD: '<:hypeSquadEvents:848743108283072553>', - BUG_HUNTER_LEVEL_1: '<:bugHunter:848743239850393640>', - HYPESQUAD_ONLINE_HOUSE_1: '<:hypeSquadBravery:848742910563844127>', - HYPESQUAD_ONLINE_HOUSE_2: '<:hypeSquadBrilliance:848742840649646101>', - HYPESQUAD_ONLINE_HOUSE_3: '<:hypeSquadBalance:848742877537370133>', - PREMIUM_EARLY_SUPPORTER: '<:earlySupporter:848741030102171648>', - TEAM_PSEUDO_USER: 'TEAM_PSEUDO_USER', - BUG_HUNTER_LEVEL_2: '<:bugHunterGold:848743283080822794>', - VERIFIED_BOT: 'VERIFIED_BOT', - VERIFIED_DEVELOPER: '<:earlyVerifiedBotDeveloper:848741079875846174>', - CERTIFIED_MODERATOR: '<:discordCertifiedModerator:877224285901582366>', - BOT_HTTP_INTERACTIONS: 'BOT_HTTP_INTERACTIONS' + None: '', + Staff: '<:discordEmployee:848742947826434079>', + Partner: '<:partneredServerOwner:848743051593777152>', + Hypesquad: '<:hypeSquadEvents:848743108283072553>', + BugHunterLevel1: '<:bugHunter:848743239850393640>', + HypeSquadOnlineHouse1: '<:hypeSquadBravery:848742910563844127>', + HypeSquadOnlineHouse2: '<:hypeSquadBrilliance:848742840649646101>', + HypeSquadOnlineHouse3: '<:hypeSquadBalance:848742877537370133>', + PremiumEarlySupporter: '<:earlySupporter:848741030102171648>', + TeamPseudoUser: 'TEAM_PSEUDO_USER', + BugHunterLevel2: '<:bugHunterGold:848743283080822794>', + VerifiedBot: 'VERIFIED_BOT', + VerifiedDeveloper: '<:earlyVerifiedBotDeveloper:848741079875846174>', + CertifiedModerator: '<:discordCertifiedModerator:877224285901582366>', + BotHTTPInteractions: 'BOT_HTTP_INTERACTIONS' }, status: { diff --git a/src/listeners/client/rateLimit.ts b/src/listeners/client/rateLimit.ts deleted file mode 100644 index 26eaf18..0000000 --- a/src/listeners/client/rateLimit.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { BushListener, type BushClientEvents } from '#lib'; - -export default class RateLimitListener extends BushListener { - public constructor() { - super('rateLimit', { - emitter: 'client', - event: 'rateLimit', - category: 'client' - }); - } - - public override async exec(...[message]: BushClientEvents['rateLimit']): Promise<void> { - void client.console.superVerboseRaw('rateLimit', message); - } -} diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts index 4d9aa1b..e84d58c 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -1,4 +1,5 @@ import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { PermissionsString } from 'discord.js'; export default class CommandMissingPermissionsListener extends BushListener { public constructor() { @@ -18,7 +19,7 @@ export default class CommandMissingPermissionsListener extends BushListener { | BushCommandHandlerEvents['missingPermissions'] | BushCommandHandlerEvents['slashMissingPermissions'] ) { - const niceMissing = (missing.includes('ADMINISTRATOR') ? (['ADMINISTRATOR'] as const) : missing).map( + const niceMissing = (missing.includes('Administrator') ? (['Administrator'] as PermissionsString[]) : missing).map( (perm) => client.consts.mappings.permissions[perm]?.name ?? missing ); diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts index 4917402..419191a 100644 --- a/src/listeners/commands/commandStarted.ts +++ b/src/listeners/commands/commandStarted.ts @@ -21,8 +21,10 @@ export default class CommandStartedListener extends BushListener { 'message.id': message.id, 'message.type': message.util.isSlash ? 'slash' : 'normal', 'message.parsed.content': message.util.parsed!.content, - 'channel.id': message.channel.isDM() ? message.channel!.recipient.id : (<GuildTextBasedChannel>message.channel)?.id, - 'channel.name': message.channel.isDM() ? message.channel.recipient.tag : (<GuildTextBasedChannel>message.channel)?.name, + 'channel.id': message.channel.isDMBased() ? message.channel!.recipient.id : message.channel?.id, + 'channel.name': message.channel.isDMBased() + ? message.channel.recipient.tag + : (<GuildTextBasedChannel>message.channel)?.name, 'guild.id': message.guild?.id, 'guild.name': message.guild?.name, 'environment': client.config.environment diff --git a/src/listeners/member-custom/bushBan.ts b/src/listeners/member-custom/bushBan.ts index 77ebaaf..b58f661 100644 --- a/src/listeners/member-custom/bushBan.ts +++ b/src/listeners/member-custom/bushBan.ts @@ -19,7 +19,7 @@ export default class BushBanListener extends BushListener { .setColor(util.colors.RED) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${duration ? 'Temp Ban' : 'Perm Ban'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushBlock.ts b/src/listeners/member-custom/bushBlock.ts index d4f7c98..2d023c4 100644 --- a/src/listeners/member-custom/bushBlock.ts +++ b/src/listeners/member-custom/bushBlock.ts @@ -21,7 +21,7 @@ export default class BushBlockListener extends BushListener { .setColor(util.colors.PURPLE) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${duration ? 'Temp Block' : 'Perm Block'}` }) .addField({ name: '**Channel**', value: `<#${channel.id}>` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) diff --git a/src/listeners/member-custom/bushKick.ts b/src/listeners/member-custom/bushKick.ts index 822201d..50af0af 100644 --- a/src/listeners/member-custom/bushKick.ts +++ b/src/listeners/member-custom/bushKick.ts @@ -19,7 +19,7 @@ export default class BushKickListener extends BushListener { .setColor(util.colors.RED) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Kick'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushMute.ts b/src/listeners/member-custom/bushMute.ts index c6361b0..bfd1fc0 100644 --- a/src/listeners/member-custom/bushMute.ts +++ b/src/listeners/member-custom/bushMute.ts @@ -19,7 +19,7 @@ export default class BushMuteListener extends BushListener { .setColor(util.colors.ORANGE) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${duration ? 'Temp Mute' : 'Perm Mute'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushPunishRole.ts b/src/listeners/member-custom/bushPunishRole.ts index 7e87b65..112c4df 100644 --- a/src/listeners/member-custom/bushPunishRole.ts +++ b/src/listeners/member-custom/bushPunishRole.ts @@ -19,7 +19,7 @@ export default class BushPunishRoleListener extends BushListener { .setColor(util.colors.YELLOW) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${duration ? 'Temp Punishment Role' : 'Perm Punishment Role'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushPunishRoleRemove.ts b/src/listeners/member-custom/bushPunishRoleRemove.ts index e9d3d95..dadc841 100644 --- a/src/listeners/member-custom/bushPunishRoleRemove.ts +++ b/src/listeners/member-custom/bushPunishRoleRemove.ts @@ -19,7 +19,7 @@ export default class BushPunishRoleRemoveListener extends BushListener { .setColor(util.colors.GREEN) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Remove Punishment Role'}` }) .addField({ name: '**Role**', value: `${role}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) diff --git a/src/listeners/member-custom/bushPurge.ts b/src/listeners/member-custom/bushPurge.ts index 5c685cd..72286a0 100644 --- a/src/listeners/member-custom/bushPurge.ts +++ b/src/listeners/member-custom/bushPurge.ts @@ -27,7 +27,7 @@ export default class BushPurgeListener extends BushListener { .setColor(util.colors.DARK_PURPLE) .setTimestamp() .setFooter({ text: `${messages.size.toLocaleString()} Messages` }) - .setAuthor({ name: moderator.tag, iconURL: moderator.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: moderator.tag, iconURL: moderator.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Purge'}` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) .addField({ name: '**Channel**', value: `<#${channel.id}> (${channel.name})` }) diff --git a/src/listeners/member-custom/bushRemoveTimeout.ts b/src/listeners/member-custom/bushRemoveTimeout.ts index 947bec9..e3e2e09 100644 --- a/src/listeners/member-custom/bushRemoveTimeout.ts +++ b/src/listeners/member-custom/bushRemoveTimeout.ts @@ -19,7 +19,7 @@ export default class BushRemoveTimeoutListener extends BushListener { .setColor(util.colors.GREEN) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Remove Timeout'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushTimeout.ts b/src/listeners/member-custom/bushTimeout.ts index 8acc506..d7f8000 100644 --- a/src/listeners/member-custom/bushTimeout.ts +++ b/src/listeners/member-custom/bushTimeout.ts @@ -21,7 +21,7 @@ export default class BushTimeoutListener extends BushListener { .setColor(util.colors.ORANGE) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Timeout'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushUnban.ts b/src/listeners/member-custom/bushUnban.ts index d58ae21..bee8032 100644 --- a/src/listeners/member-custom/bushUnban.ts +++ b/src/listeners/member-custom/bushUnban.ts @@ -19,7 +19,7 @@ export default class BushUnbanListener extends BushListener { .setColor(util.colors.GREEN) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Unban'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushUnblock.ts b/src/listeners/member-custom/bushUnblock.ts index ead2a7d..dd076c6 100644 --- a/src/listeners/member-custom/bushUnblock.ts +++ b/src/listeners/member-custom/bushUnblock.ts @@ -19,7 +19,7 @@ export default class BushUnblockListener extends BushListener { .setColor(util.colors.GREEN) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Unblock'}` }) .addField({ name: '**Channel**', value: `<#${channel.id}>` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) diff --git a/src/listeners/member-custom/bushUnmute.ts b/src/listeners/member-custom/bushUnmute.ts index b88f450..573cbdc 100644 --- a/src/listeners/member-custom/bushUnmute.ts +++ b/src/listeners/member-custom/bushUnmute.ts @@ -19,7 +19,7 @@ export default class BushUnmuteListener extends BushListener { .setColor(util.colors.GREEN) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Unmute'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/member-custom/bushUpdateModlog.ts b/src/listeners/member-custom/bushUpdateModlog.ts index 199e32e..d9e43aa 100644 --- a/src/listeners/member-custom/bushUpdateModlog.ts +++ b/src/listeners/member-custom/bushUpdateModlog.ts @@ -19,7 +19,7 @@ export default class BushUpdateModlogListener extends BushListener { .setTimestamp() .setAuthor({ name: moderator.user.tag, - iconURL: moderator.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Update Modlog'}` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }) diff --git a/src/listeners/member-custom/bushUpdateSettings.ts b/src/listeners/member-custom/bushUpdateSettings.ts index 61fdfaa..dbf3c9c 100644 --- a/src/listeners/member-custom/bushUpdateSettings.ts +++ b/src/listeners/member-custom/bushUpdateSettings.ts @@ -19,7 +19,7 @@ export default class BushUpdateSettingsListener extends BushListener { if (moderator) logEmbed.setAuthor({ name: moderator.user.tag, - iconURL: moderator.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }); logEmbed.addField({ name: '**Action**', value: `${'Update Settings'}` }); if (moderator) logEmbed.addField({ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }); diff --git a/src/listeners/member-custom/bushWarn.ts b/src/listeners/member-custom/bushWarn.ts index 11eeb49..cbcf8db 100644 --- a/src/listeners/member-custom/bushWarn.ts +++ b/src/listeners/member-custom/bushWarn.ts @@ -19,7 +19,7 @@ export default class BushWarnListener extends BushListener { .setColor(util.colors.YELLOW) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ format: 'png', size: 4096 }) ?? undefined }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Warn'}` }) .addField({ name: '**User**', value: `${user} (${user.tag})` }) .addField({ name: '**Moderator**', value: `${moderator} (${moderator.tag})` }) diff --git a/src/listeners/message/autoThread.ts b/src/listeners/message/autoThread.ts index 45cd337..aa17035 100644 --- a/src/listeners/message/autoThread.ts +++ b/src/listeners/message/autoThread.ts @@ -1,5 +1,5 @@ import { BushListener, type BushClientEvents, type BushTextChannel } from '#lib'; -import { Embed, GuildTextBasedChannel, MessageType, Permissions } from 'discord.js'; +import { Embed, GuildTextBasedChannel, MessageType, PermissionFlagsBits } from 'discord.js'; export default class autoThreadListener extends BushListener { public constructor() { @@ -35,7 +35,7 @@ export default class autoThreadListener extends BushListener { // todo: make these configurable etc... if (message.guild.id !== '516977525906341928') return; // mb if (message.channel.id !== '714332750156660756') return; // neu-support-1 - if (!(message.channel as BushTextChannel).permissionsFor(message.guild.me!).has(Permissions.FLAGS.CREATE_PUBLIC_THREADS)) + if (!(message.channel as BushTextChannel).permissionsFor(message.guild.me!).has(PermissionFlagsBits.CreatePublicThreads)) return; const thread = await message .startThread({ diff --git a/src/listeners/rest/rateLimit.ts b/src/listeners/rest/rateLimit.ts new file mode 100644 index 0000000..600ef07 --- /dev/null +++ b/src/listeners/rest/rateLimit.ts @@ -0,0 +1,16 @@ +import { BushListener } from '#lib'; +import { RestEvents } from '@discordjs/rest'; + +export default class RateLimitedListener extends BushListener { + public constructor() { + super('rateLimited', { + emitter: 'rest', + event: 'rateLimited', + category: 'rest' + }); + } + + public override async exec(...[message]: RestEvents['rateLimited']): Promise<void> { + void client.console.superVerboseRaw('rateLimited', message); + } +} diff --git a/src/listeners/track-manual-punishments/modlogSyncBan.ts b/src/listeners/track-manual-punishments/modlogSyncBan.ts index b908231..6048235 100644 --- a/src/listeners/track-manual-punishments/modlogSyncBan.ts +++ b/src/listeners/track-manual-punishments/modlogSyncBan.ts @@ -1,6 +1,6 @@ import { BushListener, BushUser, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent } from 'discord-api-types'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncBanListener extends BushListener { public constructor() { @@ -14,7 +14,7 @@ export default class ModlogSyncBanListener extends BushListener { public override async exec(...[ban]: BushClientEvents['guildBanAdd']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.me) return; // bot was banned - if (!ban.guild.me.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { + if (!ban.guild.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return ban.guild.error( 'modlogSyncBan', `Could not sync the manual ban of ${ban.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -57,7 +57,7 @@ export default class ModlogSyncBanListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: ban.user.tag, - iconURL: ban.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: ban.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Manual Ban'}` }) .addField({ name: '**User**', value: `${ban.user} (${ban.user.tag})` }) diff --git a/src/listeners/track-manual-punishments/modlogSyncKick.ts b/src/listeners/track-manual-punishments/modlogSyncKick.ts index 6bf661c..814b624 100644 --- a/src/listeners/track-manual-punishments/modlogSyncKick.ts +++ b/src/listeners/track-manual-punishments/modlogSyncKick.ts @@ -1,6 +1,6 @@ import { BushListener, BushUser, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent } from 'discord-api-types'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncKickListener extends BushListener { public constructor() { @@ -14,7 +14,7 @@ export default class ModlogSyncKickListener extends BushListener { public override async exec(...[member]: BushClientEvents['guildMemberRemove']) { if (!(await member.guild.hasFeature('logManualPunishments'))) return; if (!member.guild.me) return; // bot was removed from guild - if (!member.guild.me.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { + if (!member.guild.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return member.guild.error( 'modlogSyncKick', `Could not sync the potential manual kick of ${member.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -57,7 +57,7 @@ export default class ModlogSyncKickListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: member.user.tag, - iconURL: member.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: member.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Manual Kick'}` }) .addField({ name: '**User**', value: `${member.user} (${member.user.tag})` }) diff --git a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts index fb48faa..1289f4c 100644 --- a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts +++ b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts @@ -1,6 +1,6 @@ import { BushListener, BushUser, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent } from 'discord-api-types'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncTimeoutListener extends BushListener { public constructor() { @@ -13,7 +13,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { public override async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('logManualPunishments'))) return; - if (!newMember.guild.me!.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { + if (!newMember.guild.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return newMember.guild.error( 'modlogSyncTimeout', `Could not sync the potential manual timeout of ${newMember.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -62,7 +62,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: newMember.user.tag, - iconURL: newMember.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: newMember.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${newTime ? 'Manual Timeout' : 'Manual Remove Timeout'}` }) .addField({ name: '**User**', value: `${newMember.user} (${newMember.user.tag})` }) diff --git a/src/listeners/track-manual-punishments/modlogSyncUnban.ts b/src/listeners/track-manual-punishments/modlogSyncUnban.ts index e297fce..a92c1e9 100644 --- a/src/listeners/track-manual-punishments/modlogSyncUnban.ts +++ b/src/listeners/track-manual-punishments/modlogSyncUnban.ts @@ -1,6 +1,6 @@ import { BushListener, BushUser, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent } from 'discord-api-types'; -import { Embed, Permissions } from 'discord.js'; +import { Embed, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncUnbanListener extends BushListener { public constructor() { @@ -13,7 +13,7 @@ export default class ModlogSyncUnbanListener extends BushListener { public override async exec(...[ban]: BushClientEvents['guildBanRemove']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; - if (!ban.guild.me!.permissions.has(Permissions.FLAGS.VIEW_AUDIT_LOG)) { + if (!ban.guild.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return ban.guild.error( 'modlogSyncBan', `Could not sync the manual unban of ${ban.user.tag} to the modlog because I do not have the "View Audit Log" permission.` @@ -56,7 +56,7 @@ export default class ModlogSyncUnbanListener extends BushListener { .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ name: ban.user.tag, - iconURL: ban.user.avatarURL({ format: 'png', size: 4096 }) ?? undefined + iconURL: ban.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) .addField({ name: '**Action**', value: `${'Manual Unban'}` }) .addField({ name: '**User**', value: `${ban.user} (${ban.user.tag})` }) |