diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/config/config.ts | 4 | ||||
-rw-r--r-- | src/commands/dev/eval.ts | 3 | ||||
-rw-r--r-- | src/commands/dev/say.ts | 12 | ||||
-rw-r--r-- | src/commands/dev/sh.ts | 13 | ||||
-rw-r--r-- | src/commands/info/help.ts | 2 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 4 | ||||
-rw-r--r-- | src/lib/common/util/Format.ts | 24 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 23 | ||||
-rw-r--r-- | src/lib/extensions/discord.js/ExtendedGuild.ts | 1 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 1 | ||||
-rw-r--r-- | src/lib/utils/BushLogger.ts | 12 | ||||
-rw-r--r-- | src/lib/utils/BushUtils.ts | 8 | ||||
-rw-r--r-- | src/listeners/commands/commandError.ts | 9 |
13 files changed, 56 insertions, 60 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index f2b4284..f6b8bfa 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -24,9 +24,9 @@ import { ButtonBuilder, ButtonStyle, EmbedBuilder, - Formatters, GuildMember, InteractionUpdateOptions, + italic, PermissionFlagsBits, Role, SelectMenuBuilder, @@ -371,7 +371,7 @@ export default class ConfigCommand extends BushCommand { new ButtonBuilder({ style: ButtonStyle.Primary, customId: 'command_settingsBack', label: 'Back' }) ); settingsEmbed.setDescription( - `${Formatters.italic(guildSettingsObj[setting].description)}\n\n**Type:** ${guildSettingsObj[setting].type}` + `${italic(guildSettingsObj[setting].description)}\n\n**Type:** ${guildSettingsObj[setting].type}` ); settingsEmbed.setFooter({ diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index a317e00..04db2eb 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -4,7 +4,6 @@ import { assertAll, BushCommand, BushInspectOptions, - clientSendAndPermCheck, CodeBlockLang, colors, emojis, @@ -175,7 +174,7 @@ export default class EvalCommand extends BushCommand { ], slash: true, ownerOnly: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 2246588..c7b3c40 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -1,12 +1,4 @@ -import { - AllowedMentions, - BushCommand, - clientSendAndPermCheck, - emojis, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BushCommand, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType } from 'discord.js'; export default class SayCommand extends BushCommand { @@ -29,7 +21,7 @@ export default class SayCommand extends BushCommand { } ], ownerOnly: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], slash: true }); diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts index 609129d..56a3b69 100644 --- a/src/commands/dev/sh.ts +++ b/src/commands/dev/sh.ts @@ -1,13 +1,4 @@ -import { - ArgType, - BushCommand, - clientSendAndPermCheck, - colors, - emojis, - formatError, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { ArgType, BushCommand, colors, emojis, formatError, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import chalk from 'chalk'; import { exec } from 'child_process'; @@ -44,7 +35,7 @@ export default class ShCommand extends BushCommand { } ], ownerOnly: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 492f25d..348c74f 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -86,7 +86,7 @@ export default class HelpCommand extends BushCommand { .setColor(colors.default) .setTimestamp() .setFooter({ text: `For more information about a command use ${prefix_}help <command>` }); - for (const [, category] of this.handler.categories) { + for (const [, category] of this.handler.categories.sort((a, b) => a.id.localeCompare(b.id))) { const categoryFilter = category.filter((command) => { if (command.pseudo) return false; if (command.hidden && !args.showHidden) return false; diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 7b67816..6def866 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -62,6 +62,7 @@ export default class UserInfoCommand extends BushCommand { : typeof args.user === 'object' ? args.user : await this.client.users.fetch(`${args.user}`).catch(() => undefined); + if (user === undefined) return message.util.reply(`${emojis.error} Invalid user.`); const member = message.guild ? await message.guild.members.fetch(user.id).catch(() => undefined) : undefined; await user.fetch(true); // gets banner info and accent color @@ -85,6 +86,9 @@ export default class UserInfoCommand extends BushCommand { // Flags if (user.client.config.owners.includes(user.id)) emojis.push(mappings.otherEmojis.Developer); if (superUsers.includes(user.id)) emojis.push(mappings.otherEmojis.Superuser); + + if (user.bot) emojis.push(mappings.otherEmojis.Bot); + const flags = user.flags?.toArray(); if (flags) { flags.forEach((f) => { diff --git a/src/lib/common/util/Format.ts b/src/lib/common/util/Format.ts index 8e7c302..5188c2b 100644 --- a/src/lib/common/util/Format.ts +++ b/src/lib/common/util/Format.ts @@ -1,5 +1,7 @@ import { type CodeBlockLang } from '#lib'; import { + bold as discordBold, + codeBlock as discordCodeBlock, escapeBold as discordEscapeBold, escapeCodeBlock as discordEscapeCodeBlock, escapeInlineCode as discordEscapeInlineCode, @@ -9,7 +11,11 @@ import { escapeSpoiler as discordEscapeSpoiler, escapeStrikethrough as discordEscapeStrikethrough, escapeUnderline as discordEscapeUnderline, - Formatters + inlineCode as discordInlineCode, + italic as discordItalic, + spoiler as discordSpoiler, + strikethrough as discordStrikethrough, + underscore as discordUnderscore } from 'discord.js'; /** @@ -26,8 +32,8 @@ export function codeBlock(content: string): string; export function codeBlock(language: CodeBlockLang, content: string): string; export function codeBlock(languageOrContent: string, content?: string): string { return typeof content === 'undefined' - ? Formatters.codeBlock(discordEscapeCodeBlock(`${languageOrContent}`)) - : Formatters.codeBlock(`${languageOrContent}`, discordEscapeCodeBlock(`${content}`)); + ? discordCodeBlock(discordEscapeCodeBlock(`${languageOrContent}`)) + : discordCodeBlock(`${languageOrContent}`, discordEscapeCodeBlock(`${content}`)); } /** @@ -35,7 +41,7 @@ export function codeBlock(languageOrContent: string, content?: string): string { * @param content The content to wrap. */ export function inlineCode(content: string): string { - return Formatters.inlineCode(discordEscapeInlineCode(`${content}`)); + return discordInlineCode(discordEscapeInlineCode(`${content}`)); } /** @@ -43,7 +49,7 @@ export function inlineCode(content: string): string { * @param content The content to wrap. */ export function italic(content: string): string { - return Formatters.italic(discordEscapeItalic(`${content}`)); + return discordItalic(discordEscapeItalic(`${content}`)); } /** @@ -51,7 +57,7 @@ export function italic(content: string): string { * @param content The content to wrap. */ export function bold(content: string): string { - return Formatters.bold(discordEscapeBold(`${content}`)); + return discordBold(discordEscapeBold(`${content}`)); } /** @@ -59,7 +65,7 @@ export function bold(content: string): string { * @param content The content to wrap. */ export function underscore(content: string): string { - return Formatters.underscore(discordEscapeUnderline(`${content}`)); + return discordUnderscore(discordEscapeUnderline(`${content}`)); } /** @@ -67,7 +73,7 @@ export function underscore(content: string): string { * @param content The content to wrap. */ export function strikethrough(content: string): string { - return Formatters.strikethrough(discordEscapeStrikethrough(`${content}`)); + return discordStrikethrough(discordEscapeStrikethrough(`${content}`)); } /** @@ -75,7 +81,7 @@ export function strikethrough(content: string): string { * @param content The content to wrap. */ export function spoiler(content: string): string { - return Formatters.spoiler(discordEscapeSpoiler(`${content}`)); + return discordSpoiler(discordEscapeSpoiler(`${content}`)); } /** diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 855c252..9ca02a2 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -15,6 +15,7 @@ import { patch, type PatchedElements } from '@notenoughupdates/events-intercept' import * as Sentry from '@sentry/node'; import { AkairoClient, + ArgumentTypeCaster, ContextMenuCommandHandler, version as akairoVersion, type ArgumentPromptData, @@ -406,17 +407,17 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re }; this.listenerHandler.setEmitters(emitters); this.commandHandler.resolver.addTypes({ - duration, - contentWithDuration, - permission, - snowflake, - discordEmoji, - roleWithDuration, - abbreviatedNumber, - durationSeconds, - globalUser, - messageLink, - tinyColor + duration: <ArgumentTypeCaster>duration, + contentWithDuration: <ArgumentTypeCaster>contentWithDuration, + permission: <ArgumentTypeCaster>permission, + snowflake: <ArgumentTypeCaster>snowflake, + discordEmoji: <ArgumentTypeCaster>discordEmoji, + roleWithDuration: <ArgumentTypeCaster>roleWithDuration, + abbreviatedNumber: <ArgumentTypeCaster>abbreviatedNumber, + durationSeconds: <ArgumentTypeCaster>durationSeconds, + globalUser: <ArgumentTypeCaster>globalUser, + messageLink: <ArgumentTypeCaster>messageLink, + tinyColor: <ArgumentTypeCaster>tinyColor }); this.sentry.setTag('process', process.pid.toString()); diff --git a/src/lib/extensions/discord.js/ExtendedGuild.ts b/src/lib/extensions/discord.js/ExtendedGuild.ts index e55851b..3dce7ca 100644 --- a/src/lib/extensions/discord.js/ExtendedGuild.ts +++ b/src/lib/extensions/discord.js/ExtendedGuild.ts @@ -739,6 +739,7 @@ export class ExtendedGuild extends Guild { // todo: use enum for this case 24 as MessageType: { const embed = quote.embeds[0]; + // eslint-disable-next-line deprecation/deprecation assert.equal(embed.data.type, 'auto_moderation_message'); const ruleName = embed.fields!.find((f) => f.name === 'rule_name')!.value; const channelId = embed.fields!.find((f) => f.name === 'channel_id')!.value; diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 0fd9113..abac4af 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -331,6 +331,7 @@ export const mappings = deepLock({ Admin: '<:admin:848963914628333598>', Superuser: '<:superUser:848947986326224926>', Developer: '<:developer:848954538111139871>', + Bot: '<:bot:1006929813203853427>', BushVerified: '<:verfied:853360152090771497>', BoostTier1: '<:boostitle:853363736679940127>', BoostTier2: '<:boostitle:853363752728789075>', diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 995dd82..21d10a0 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -1,6 +1,6 @@ import chalk from 'chalk'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Client, EmbedBuilder, escapeMarkdown, Formatters, PartialTextBasedChannelFields, type Message } from 'discord.js'; +import { bold, Client, EmbedBuilder, escapeMarkdown, PartialTextBasedChannelFields, type Message } from 'discord.js'; import { stripVTControlCharacters as stripColor } from 'node:util'; import repl, { REPLServer, REPL_MODE_STRICT } from 'repl'; import { WriteStream } from 'tty'; @@ -77,7 +77,7 @@ function parseFormatting( .split(/<<|>>/) .map((value, index) => { if (discordFormat) { - return index % 2 === 0 ? escapeMarkdown(value) : Formatters.bold(escapeMarkdown(value)); + return index % 2 === 0 ? escapeMarkdown(value) : bold(escapeMarkdown(value)); } else { return index % 2 === 0 || !color ? value : chalk[color](value); } @@ -106,11 +106,9 @@ function inspectContent(content: any, depth = 2, colors = true): string { function getTimeStamp(): string { const now = new Date(); const minute = pad(now.getMinutes()); - const hour = pad(now.getHours() % 12); - const meridiem = now.getHours() > 12 ? 'PM' : 'AM'; - const year = now.getFullYear().toString().slice(2).padStart(2, '0'); - const date = `${pad(now.getMonth() + 1)}/${pad(now.getDay())}/${year}`; - return `${date} ${hour}:${minute} ${meridiem}`; + const hour = pad(now.getHours()); + const date = `${pad(now.getMonth() + 1)}/${pad(now.getDay())}`; + return `${date} ${hour}:${minute}`; } /** diff --git a/src/lib/utils/BushUtils.ts b/src/lib/utils/BushUtils.ts index af173f9..de01ac0 100644 --- a/src/lib/utils/BushUtils.ts +++ b/src/lib/utils/BushUtils.ts @@ -466,9 +466,13 @@ export function clientSendAndPermCheck( permissions: bigint[] = [], checkChannel = false ): PermissionsString[] | null { + if (!message.inGuild() || !message.channel) return null; + const missing: PermissionsString[] = []; - const sendPerm = message.channel!.isThread() ? 'SendMessages' : 'SendMessagesInThreads'; - if (!message.inGuild()) return null; + const sendPerm = message.channel.isThread() ? 'SendMessages' : 'SendMessagesInThreads'; + + // todo: remove once forum channels are fixed + if (message.channel.parent === null && message.channel.isThread()) return null; if (!message.guild.members.me!.permissionsIn(message.channel!.id).has(sendPerm)) missing.push(sendPerm); diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 04ea517..f12881a 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -1,6 +1,7 @@ import { capitalize, colors, format, formatError, SlashMessage, type BushCommandHandlerEvents } from '#lib'; import { type AkairoMessage, type Command } from 'discord-akairo'; -import { ChannelType, Client, EmbedBuilder, escapeInlineCode, Formatters, GuildTextBasedChannel, type Message } from 'discord.js'; +import { ChannelType, Client, EmbedBuilder, escapeInlineCode, GuildTextBasedChannel, type Message } from 'discord.js'; +import { bold } from '../../lib/common/util/Format.js'; import { BushListener } from '../../lib/extensions/discord-akairo/BushListener.js'; export default class CommandErrorListener extends BushListener { @@ -163,11 +164,9 @@ export default class CommandErrorListener extends BushListener { if (options.type === 'command-dev' || options.type === 'command-log') embeds[0].setTitle(`${options.isSlash ? 'Slash ' : ''}CommandError #${format.input(`${options.errorNum}`)}`); else if (options.type === 'uncaughtException') - embeds[0].setTitle(`${options.context ? `[${Formatters.bold(options.context)}] An Error Occurred` : 'Uncaught Exception'}`); + embeds[0].setTitle(`${options.context ? `[${bold(options.context)}] An Error Occurred` : 'Uncaught Exception'}`); else if (options.type === 'unhandledRejection') - embeds[0].setTitle( - `${options.context ? `[${Formatters.bold(options.context)}] An Error Occurred` : 'Unhandled Promise Rejection'}` - ); + embeds[0].setTitle(`${options.context ? `[${bold(options.context)}] An Error Occurred` : 'Unhandled Promise Rejection'}`); return embeds; } |