diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/config/config.ts | 2 | ||||
-rw-r--r-- | src/commands/config/features.ts | 7 | ||||
-rw-r--r-- | src/commands/dev/test.ts | 12 | ||||
-rw-r--r-- | src/commands/fun/minesweeper.ts | 2 | ||||
-rw-r--r-- | src/commands/info/botInfo.ts | 2 | ||||
-rw-r--r-- | src/commands/info/guildInfo.ts | 46 | ||||
-rw-r--r-- | src/commands/info/help.ts | 76 | ||||
-rw-r--r-- | src/commands/info/pronouns.ts | 2 | ||||
-rw-r--r-- | src/commands/info/snowflake.ts | 16 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 9 | ||||
-rw-r--r-- | src/commands/leveling/level.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/slowmode.ts | 9 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 10 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 10 | ||||
-rw-r--r-- | src/commands/utilities/uuid.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/wolframAlpha.ts | 2 |
16 files changed, 136 insertions, 82 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 00c6a69..2ce4246 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -229,7 +229,7 @@ export default class SettingsCommand extends BushCommand { } const collector = msg.createMessageComponentCollector({ time: 300_000, - filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id + filter: (i) => i.guildId === msg.guildId && i.message?.id === msg.id }); collector.on('collect', async (interaction: MessageComponentInteraction) => { diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 8c9351d..d0f9c5c 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -1,6 +1,7 @@ import { BushCommand, - guildFeaturesArr, guildFeaturesObj, + guildFeaturesArr, + guildFeaturesObj, type BushMessage, type BushSlashMessage, type GuildFeatures @@ -36,7 +37,7 @@ export default class FeaturesCommand extends BushCommand { const collector = msg.createMessageComponentCollector({ componentType: 'SELECT_MENU', time: 300_000, - filter: (i) => i.guildId === msg.guildId && i.message.id === msg.id + filter: (i) => i.guildId === msg.guildId && i.message?.id === msg.id }); collector.on('collect', async (interaction: SelectMenuInteraction) => { @@ -78,7 +79,7 @@ export default class FeaturesCommand extends BushCommand { return new MessageActionRow().addComponents( new MessageSelectMenu({ customId: 'command_selectFeature', - disabled: disable, + disabled: disable, maxValues: 1, minValues: 2, options: guildFeatures.map((f) => ({ diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index d4109f4..5120a34 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -1,11 +1,11 @@ import { BushCommand, ButtonPaginator, type BushMessage } from '#lib'; import { - Constants as jsConstants, - MessageActionRow, - MessageButton, - MessageEmbed, - type ApplicationCommand, - type Collection + Constants as jsConstants, + MessageActionRow, + MessageButton, + MessageEmbed, + type ApplicationCommand, + type Collection } from 'discord.js'; export default class TestCommand extends BushCommand { diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts index 71c5055..9b511a3 100644 --- a/src/commands/fun/minesweeper.ts +++ b/src/commands/fun/minesweeper.ts @@ -1,5 +1,5 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import Minesweeper from 'discord.js-minesweeper'; +import Minesweeper from '@notenoughupdates/discord.js-minesweeper'; export default class MinesweeperCommand extends BushCommand { public constructor() { diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 04a1b14..833ed96 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,7 +1,7 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { MessageEmbed, version as discordJSVersion } from 'discord.js'; import * as os from 'os'; -const {default: prettyBytes} = await import('pretty-bytes') +const { default: prettyBytes } = await import('pretty-bytes'); export default class BotInfoCommand extends BushCommand { public constructor() { diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index ef1c232..47a8281 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -1,5 +1,13 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Constants, Guild, MessageEmbed, type BaseGuildVoiceChannel, type GuildPreview, type Snowflake, type Vanity } from 'discord.js'; +import { + Constants, + Guild, + MessageEmbed, + type BaseGuildVoiceChannel, + type GuildPreview, + type Snowflake, + type Vanity +} from 'discord.js'; export default class GuildInfoCommand extends BushCommand { public constructor() { @@ -66,17 +74,17 @@ export default class GuildInfoCommand extends BushCommand { await guild.fetch(); const channels = guild.channels.cache; - type ChannelType = 'GUILD_TEXT'|'GUILD_NEWS'|'GUILD_VOICE'|'GUILD_STAGE_VOICE'|'GUILD_STORE'|'GUILD_CATEGORY'|'THREAD' - const channelTypes = ([ - 'GUILD_TEXT', - 'GUILD_VOICE', - 'GUILD_STAGE_VOICE', - 'GUILD_STORE', - 'GUILD_CATEGORY', - 'THREAD', - ] as ChannelType[]).map( - (type)=>`${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}` - ) + type ChannelType = + | 'GUILD_TEXT' + | 'GUILD_NEWS' + | 'GUILD_VOICE' + | 'GUILD_STAGE_VOICE' + | 'GUILD_STORE' + | 'GUILD_CATEGORY' + | 'THREAD'; + const channelTypes = ( + ['GUILD_TEXT', 'GUILD_VOICE', 'GUILD_STAGE_VOICE', 'GUILD_STORE', 'GUILD_CATEGORY', 'THREAD'] as ChannelType[] + ).map((type) => `${otherEmojis[type]} ${channels.filter((channel) => channel.type.includes(type)).size.toLocaleString()}`); const guildRegions = [ ...new Set( @@ -105,8 +113,18 @@ export default class GuildInfoCommand extends BushCommand { 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' })})`); - enum EmojiTierMap { TIER_3 = 500, TIER_2 = 300, TIER_1 = 100, NONE = 50 } - enum StickerTierMap { TIER_3 = 60, TIER_2 = 30, TIER_1 = 15, NONE = 0 } + enum EmojiTierMap { + TIER_3 = 500, + TIER_2 = 300, + TIER_1 = 100, + NONE = 50 + } + enum StickerTierMap { + TIER_3 = 60, + TIER_2 = 30, + TIER_1 = 15, + NONE = 0 + } guildStats.push( `**Channels:** ${guild.channels.cache.size.toLocaleString()} / 500 (${channelTypes.join(', ')})`, diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index f956405..3bf8f5e 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -44,35 +44,7 @@ export default class HelpCommand extends BushCommand { args: { command: BushCommand | string; showHidden?: boolean } ) { const prefix = util.prefix(message); - const row = new MessageActionRow(); - - if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Invite Me', - url: `https://discord.com/api/oauth2/authorize?client_id=${ - client.user!.id - }&permissions=5368709119918&scope=bot%20applications.commands` - }) - ); - } - if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'Support Server', - url: client.config.supportGuild.invite - }) - ); - } - row.addComponents( - new MessageButton({ - style: 'LINK', - label: 'GitHub', - url: packageDotJSON.repository - }) - ); + const row = this.addLinks(message); const isOwner = client.isOwner(message.author); const isSuperUser = client.isSuperUser(message.author); @@ -91,17 +63,13 @@ export default class HelpCommand extends BushCommand { if (command.hidden && !args.showHidden) return false; if (command.channel == 'guild' && !message.guild && !args.showHidden) return false; if (command.ownerOnly && !isOwner) return false; - if (command.superUserOnly && !isSuperUser) { - return false; - } + if (command.superUserOnly && !isSuperUser) return false; return !(command.restrictedGuilds?.includes(message.guild?.id ?? '') === false && !args.showHidden); }); const categoryNice = category.id - .replace(/(\b\w)/gi, (lc): string => lc.toUpperCase()) - .replace(/'(S)/g, (letter): string => letter.toLowerCase()); - const categoryCommands = categoryFilter - .filter((cmd): boolean => cmd.aliases.length > 0) - .map((cmd): string => `\`${cmd.aliases[0]}\``); + .replace(/(\b\w)/gi, (lc) => lc.toUpperCase()) + .replace(/'(S)/g, (letter) => letter.toLowerCase()); + const categoryCommands = categoryFilter.filter((cmd) => cmd.aliases.length > 0).map((cmd) => `\`${cmd.aliases[0]}\``); if (categoryCommands.length > 0) { embed.addField(`${categoryNice}`, `${categoryCommands.join(' ')}`); } @@ -153,4 +121,38 @@ export default class HelpCommand extends BushCommand { return await message.util.reply({ embeds: [embed], components: [row] }); } + + private addLinks(message: BushMessage | BushSlashMessage) { + const row = new MessageActionRow(); + + if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Invite Me', + url: `https://discord.com/api/oauth2/authorize?client_id=${ + client.user!.id + }&permissions=5368709119918&scope=bot%20applications.commands` + }) + ); + } + if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) { + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'Support Server', + url: client.config.supportGuild.invite + }) + ); + } + row.addComponents( + new MessageButton({ + style: 'LINK', + label: 'GitHub', + url: packageDotJSON.repository + }) + ); + + return row; + } } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index a7df5aa..3cf27b6 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -39,7 +39,7 @@ export default class PronounsCommand extends BushCommand { const user = args.user ?? message.author; const author = user.id === message.author.id; - if (message.util.isSlashMessage(message)) await message.interaction.deferReply() + if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); const pronouns = await util.getPronounsOf(user); if (!pronouns) { diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index 3b1a073..deb5692 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -6,7 +6,8 @@ import { type CategoryChannel, type Channel, type DeconstructedSnowflake, - type DMChannel, type Guild, + type DMChannel, + type Guild, type NewsChannel, type Role, type Snowflake, @@ -60,7 +61,9 @@ export default class SnowflakeCommand extends BushCommand { if (['dm', 'group'].includes(channel.type)) { const _channel = channel as DMChannel; channelInfo.push(`**Recipient:** ${util.discord.escapeMarkdown(_channel.recipient.tag)} (${_channel.recipient.id})`); - snowflakeEmbed.setTitle(`:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\``); + snowflakeEmbed.setTitle( + `:snowflake: DM with ${util.discord.escapeMarkdown((channel as DMChannel).recipient.tag)} \`[Channel]\`` + ); } else if ( [ 'GUILD_CATEGORY', @@ -89,7 +92,9 @@ export default class SnowflakeCommand extends BushCommand { const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = [ `**Name:** ${util.discord.escapeMarkdown(guild.name)}`, - `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${guild.ownerId})`, + `**Owner:** ${util.discord.escapeMarkdown(client.users.cache.get(guild.ownerId)?.tag ?? '¯\\_(ツ)_/¯')} (${ + guild.ownerId + })`, `**Members:** ${guild.memberCount?.toLocaleString()}` ]; if (guild.icon) snowflakeEmbed.setThumbnail(guild.iconURL({ size: 2048, dynamic: true })!); @@ -110,7 +115,10 @@ export default class SnowflakeCommand extends BushCommand { // Emoji if (client.emojis.cache.has(snowflake)) { const emoji = client.emojis.cache.get(snowflake)!; - const emojiInfo = [`**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, `**Animated:** ${emoji.animated}`]; + const emojiInfo = [ + `**Name:** ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')}`, + `**Animated:** ${emoji.animated}` + ]; if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); snowflakeEmbed.addField('» Emoji Info', emojiInfo.join('\n')); snowflakeEmbed.setTitle(`:snowflake: ${util.discord.escapeMarkdown(emoji.name ?? '¯\\_(ツ)_/¯')} \`[Emoji]\``); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 49c23c9..601e044 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -53,9 +53,7 @@ export default class UserInfoCommand extends BushCommand { const userEmbed: MessageEmbed = new MessageEmbed() .setTitle(util.discord.escapeMarkdown(user.tag)) - .setThumbnail( - user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true }) - ) + .setThumbnail(user.displayAvatarURL({ size: 2048, format: 'png', dynamic: true })) .setTimestamp(); // Flags @@ -95,7 +93,7 @@ export default class UserInfoCommand extends BushCommand { 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({ dynamic: true, format: 'png', size: 4096 })})`); - const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); + const pronouns = await Promise.race([util.getPronounsOf(user), util.sleep(2)]); if (pronouns && typeof pronouns === 'string') generalInfo.push(`**Pronouns:** ${pronouns}`); userEmbed.addField('» General Info', generalInfo.join('\n')); @@ -137,7 +135,8 @@ export default class UserInfoCommand extends BushCommand { presenceInfo.push(`**${devices.length - 1 ? 'Devices' : 'Device'}:** ${util.oxford(devices, 'and', '')}`); if (activitiesNames.length) presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`); - if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); + if (customStatus && customStatus.length) + presenceInfo.push(`**Custom Status:** ${util.discord.escapeMarkdown(customStatus)}`); userEmbed.addField('» Presence', presenceInfo.join('\n')); enum statusEmojis { diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index ea77124..eb86155 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -15,7 +15,7 @@ import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; // idk why I need to do default twice, it is being weird -const { default: SimplifyNumber } = ((await import('simplify-number')).default as unknown as typeof import('simplify-number')); +const { default: SimplifyNumber } = (await import('simplify-number')).default as unknown as typeof import('simplify-number'); export default class LevelCommand extends BushCommand { public constructor() { @@ -92,9 +92,12 @@ export default class LevelCommand extends BushCommand { gray = '#23272A', highlight = user.hexAccentColor ?? '#5865F2'; // Load roboto font - canvas.registerFont(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), { - family: 'Roboto' - }); + canvas.registerFont( + join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), + { + family: 'Roboto' + } + ); // Create image canvas const levelCard = canvas.createCanvas(800, 200), ctx = levelCard.getContext('2d'); diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 5b77096..e05a409 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -1,4 +1,11 @@ -import { BushCommand, type BushMessage, type BushNewsChannel, type BushSlashMessage, type BushTextChannel, type BushThreadChannel } from '#lib'; +import { + BushCommand, + type BushMessage, + type BushNewsChannel, + type BushSlashMessage, + type BushTextChannel, + type BushThreadChannel +} from '#lib'; import { Argument } from 'discord-akairo'; import { TextChannel, ThreadChannel, type NewsChannel } from 'discord.js'; diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index e1bda63..c31ce21 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,4 +1,12 @@ -import { AllowedMentions, BushCommand, Moderation, type BushGuildMember, type BushMessage, type BushSlashMessage, type BushUser } from '#lib'; +import { + AllowedMentions, + BushCommand, + Moderation, + type BushGuildMember, + type BushMessage, + type BushSlashMessage, + type BushUser +} from '#lib'; export default class UnmuteCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 25b47ec..9b58cf6 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,4 +1,12 @@ -import { AllowedMentions, BushCommand, Moderation, type BushGuildMember, type BushMessage, type BushSlashMessage, type BushUser } from '#lib'; +import { + AllowedMentions, + BushCommand, + Moderation, + type BushGuildMember, + type BushMessage, + type BushSlashMessage, + type BushUser +} from '#lib'; export default class WarnCommand extends BushCommand { public constructor() { diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index 1be6079..556a4de 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -2,7 +2,7 @@ import { BushCommand, type BushMessage } from '#lib'; export default class UuidCommand extends BushCommand { public constructor() { - super('uuid', { + super('uuid', { aliases: ['uuid'], category: 'utilities', description: { diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts index 13512bb..f64fd4f 100644 --- a/src/commands/utilities/wolframAlpha.ts +++ b/src/commands/utilities/wolframAlpha.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { initializeClass as WolframAlphaAPI } from "@notenoughupdates/wolfram-alpha-api"; import { MessageEmbed, type MessageOptions } from 'discord.js'; -const { default: WolframAlphaAPI } = (await import("@notenoughupdates/wolfram-alpha-api")).default as unknown as typeof import("@notenoughupdates/wolfram-alpha-api") export default class WolframAlphaCommand extends BushCommand { public constructor() { |