From 6164e6c1a57e59202c2fd836b5eec96a04376a99 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 12 Jul 2025 01:06:14 +0700 Subject: [PATCH] chore: format --- bots/discord/src/commands/admin/eval.ts | 6 +++--- bots/discord/src/commands/admin/exception-test.ts | 2 +- bots/discord/src/commands/admin/reload.ts | 2 +- bots/discord/src/commands/admin/slash-commands.ts | 2 +- bots/discord/src/commands/admin/stop.ts | 2 +- bots/discord/src/commands/fun/coinflip.ts | 2 +- bots/discord/src/commands/fun/reply.ts | 2 +- bots/discord/src/commands/moderation/cure.ts | 2 +- bots/discord/src/commands/moderation/purge.ts | 2 +- bots/discord/src/commands/moderation/slowmode.ts | 2 +- bots/discord/src/commands/moderation/unmute.ts | 2 +- bots/discord/src/commands/support/train/chat.ts | 2 +- .../src/commands/support/train/context-menu.ts | 2 +- bots/discord/src/events/api/disconnect.ts | 2 +- .../discord/guildMemberAdd/applyRolePresets.ts | 2 +- .../events/discord/interactionCreate/chatCommand.ts | 2 +- .../discord/interactionCreate/contextMenuCommand.ts | 2 +- .../discord/interactionCreate/correctResponse.ts | 8 ++++---- .../events/discord/interactionCreate/trainMessage.ts | 2 +- .../discord/messageReactionAdd/correctResponse.ts | 12 ++++++------ .../src/events/discord/ready/removeExpiredPresets.ts | 4 ++-- bots/discord/src/index.ts | 2 +- bots/discord/src/utils/discord/embeds.ts | 2 +- bots/discord/src/utils/discord/messageScan.ts | 2 +- bots/discord/src/utils/discord/moderation.ts | 2 +- bots/discord/src/utils/discord/rolePresets.ts | 2 +- 26 files changed, 37 insertions(+), 37 deletions(-) diff --git a/bots/discord/src/commands/admin/eval.ts b/bots/discord/src/commands/admin/eval.ts index 4d080be..cbb6c12 100644 --- a/bots/discord/src/commands/admin/eval.ts +++ b/bots/discord/src/commands/admin/eval.ts @@ -1,11 +1,11 @@ -import { AdminCommand } from '$/classes/Command' -import { createSuccessEmbed } from '$/utils/discord/embeds' -import { parseDuration } from '$/utils/duration' import { ApplicationCommandOptionType, MessageFlags } from 'discord.js' import { unlinkSync, writeFileSync } from 'fs' import { join } from 'path' import { inspect } from 'util' import { createContext, runInContext } from 'vm' +import { AdminCommand } from '$/classes/Command' +import { createSuccessEmbed } from '$/utils/discord/embeds' +import { parseDuration } from '$/utils/duration' export default new AdminCommand({ name: 'eval', diff --git a/bots/discord/src/commands/admin/exception-test.ts b/bots/discord/src/commands/admin/exception-test.ts index 284df55..3af8567 100644 --- a/bots/discord/src/commands/admin/exception-test.ts +++ b/bots/discord/src/commands/admin/exception-test.ts @@ -1,6 +1,6 @@ +import { ApplicationCommandOptionType } from 'discord.js' import { AdminCommand } from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' -import { ApplicationCommandOptionType } from 'discord.js' export default new AdminCommand({ name: 'exception-test', diff --git a/bots/discord/src/commands/admin/reload.ts b/bots/discord/src/commands/admin/reload.ts index 01270cd..0d0a7ec 100644 --- a/bots/discord/src/commands/admin/reload.ts +++ b/bots/discord/src/commands/admin/reload.ts @@ -1,5 +1,5 @@ -import { AdminCommand } from '$/classes/Command' import { type CommandInteraction, MessageFlags } from 'discord.js' +import { AdminCommand } from '$/classes/Command' export default new AdminCommand({ name: 'reload', diff --git a/bots/discord/src/commands/admin/slash-commands.ts b/bots/discord/src/commands/admin/slash-commands.ts index 7c03c9f..ce6b464 100644 --- a/bots/discord/src/commands/admin/slash-commands.ts +++ b/bots/discord/src/commands/admin/slash-commands.ts @@ -1,7 +1,7 @@ +import { ApplicationCommandOptionType, Routes } from 'discord.js' import { AdminCommand } from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' import { createSuccessEmbed } from '$/utils/discord/embeds' -import { ApplicationCommandOptionType, Routes } from 'discord.js' const SubcommandOptions = { where: { diff --git a/bots/discord/src/commands/admin/stop.ts b/bots/discord/src/commands/admin/stop.ts index f67dcd2..ab48917 100644 --- a/bots/discord/src/commands/admin/stop.ts +++ b/bots/discord/src/commands/admin/stop.ts @@ -1,5 +1,5 @@ -import { AdminCommand } from '$/classes/Command' import { MessageFlags } from 'discord.js' +import { AdminCommand } from '$/classes/Command' export default new AdminCommand({ name: 'stop', diff --git a/bots/discord/src/commands/fun/coinflip.ts b/bots/discord/src/commands/fun/coinflip.ts index 5438621..5d563d3 100644 --- a/bots/discord/src/commands/fun/coinflip.ts +++ b/bots/discord/src/commands/fun/coinflip.ts @@ -1,6 +1,6 @@ +import { EmbedBuilder, MessageFlags } from 'discord.js' import Command from '$/classes/Command' import { applyCommonEmbedStyles } from '$/utils/discord/embeds' -import { EmbedBuilder, MessageFlags } from 'discord.js' export default new Command({ name: 'coinflip', diff --git a/bots/discord/src/commands/fun/reply.ts b/bots/discord/src/commands/fun/reply.ts index 1acf341..698fb58 100644 --- a/bots/discord/src/commands/fun/reply.ts +++ b/bots/discord/src/commands/fun/reply.ts @@ -1,5 +1,5 @@ -import CommandError, { CommandErrorType } from '$/classes/CommandError' import { ApplicationCommandOptionType, Message, MessageFlags } from 'discord.js' +import CommandError, { CommandErrorType } from '$/classes/CommandError' import { ModerationCommand } from '../../classes/Command' export default new ModerationCommand({ diff --git a/bots/discord/src/commands/moderation/cure.ts b/bots/discord/src/commands/moderation/cure.ts index 5534be6..e3b0e93 100644 --- a/bots/discord/src/commands/moderation/cure.ts +++ b/bots/discord/src/commands/moderation/cure.ts @@ -1,7 +1,7 @@ +import { MessageFlags } from 'discord.js' import { ModerationCommand } from '$/classes/Command' import { createSuccessEmbed } from '$/utils/discord/embeds' import { cureNickname } from '$/utils/discord/moderation' -import { MessageFlags } from 'discord.js' export default new ModerationCommand({ name: 'cure', diff --git a/bots/discord/src/commands/moderation/purge.ts b/bots/discord/src/commands/moderation/purge.ts index 7cd14c1..8b71be0 100644 --- a/bots/discord/src/commands/moderation/purge.ts +++ b/bots/discord/src/commands/moderation/purge.ts @@ -1,7 +1,7 @@ +import { EmbedBuilder } from 'discord.js' import { ModerationCommand } from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' import { applyCommonEmbedStyles } from '$/utils/discord/embeds' -import { EmbedBuilder } from 'discord.js' export default new ModerationCommand({ name: 'purge', diff --git a/bots/discord/src/commands/moderation/slowmode.ts b/bots/discord/src/commands/moderation/slowmode.ts index 31fc8cc..3b5cc9a 100644 --- a/bots/discord/src/commands/moderation/slowmode.ts +++ b/bots/discord/src/commands/moderation/slowmode.ts @@ -1,8 +1,8 @@ +import { ChannelType } from 'discord.js' import { ModerationCommand } from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' import { createSuccessEmbed } from '$/utils/discord/embeds' import { durationToString, parseDuration } from '$/utils/duration' -import { ChannelType } from 'discord.js' export default new ModerationCommand({ name: 'slowmode', diff --git a/bots/discord/src/commands/moderation/unmute.ts b/bots/discord/src/commands/moderation/unmute.ts index d45db30..8c0c30e 100644 --- a/bots/discord/src/commands/moderation/unmute.ts +++ b/bots/discord/src/commands/moderation/unmute.ts @@ -1,10 +1,10 @@ +import { and, eq } from 'drizzle-orm' import { ModerationCommand } from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' import { appliedPresets } from '$/database/schemas' import { createModerationActionEmbed } from '$/utils/discord/embeds' import { sendModerationReplyAndLogs } from '$/utils/discord/moderation' import { removeRolePreset } from '$/utils/discord/rolePresets' -import { and, eq } from 'drizzle-orm' export default new ModerationCommand({ name: 'unmute', diff --git a/bots/discord/src/commands/support/train/chat.ts b/bots/discord/src/commands/support/train/chat.ts index 0aef886..6b34c59 100644 --- a/bots/discord/src/commands/support/train/chat.ts +++ b/bots/discord/src/commands/support/train/chat.ts @@ -1,7 +1,7 @@ +import { type FetchMessageOptions, MessageFlags, type MessageResolvable } from 'discord.js' import Command from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' import { createSuccessEmbed } from '$/utils/discord/embeds' -import { type FetchMessageOptions, MessageFlags, type MessageResolvable } from 'discord.js' import { config } from '../../../context' import type { ConfigMessageScanResponseLabelConfig } from 'config.schema' diff --git a/bots/discord/src/commands/support/train/context-menu.ts b/bots/discord/src/commands/support/train/context-menu.ts index 3e5256f..0eaf2a5 100644 --- a/bots/discord/src/commands/support/train/context-menu.ts +++ b/bots/discord/src/commands/support/train/context-menu.ts @@ -1,6 +1,6 @@ +import { type APIStringSelectComponent, ComponentType, MessageFlags } from 'discord.js' import Command from '$/classes/Command' import CommandError, { CommandErrorType } from '$/classes/CommandError' -import { type APIStringSelectComponent, ComponentType, MessageFlags } from 'discord.js' import { config } from '../../../context' import type { ConfigMessageScanResponseLabelConfig } from 'config.schema' diff --git a/bots/discord/src/events/api/disconnect.ts b/bots/discord/src/events/api/disconnect.ts index 178980d..b964580 100644 --- a/bots/discord/src/events/api/disconnect.ts +++ b/bots/discord/src/events/api/disconnect.ts @@ -1,5 +1,5 @@ -import { on, withContext } from '$utils/api/events' import { DisconnectReason, HumanizedDisconnectReason } from '@revanced/bot-shared' +import { on, withContext } from '$utils/api/events' withContext(on, 'disconnect', ({ api, config, logger }, reason, msg) => { if (reason === DisconnectReason.PlannedDisconnect && api.intentionallyDisconnecting) return diff --git a/bots/discord/src/events/discord/guildMemberAdd/applyRolePresets.ts b/bots/discord/src/events/discord/guildMemberAdd/applyRolePresets.ts index 686350d..9777d06 100644 --- a/bots/discord/src/events/discord/guildMemberAdd/applyRolePresets.ts +++ b/bots/discord/src/events/discord/guildMemberAdd/applyRolePresets.ts @@ -1,7 +1,7 @@ +import { and, eq, gt } from 'drizzle-orm' import { appliedPresets } from '$/database/schemas' import { on, withContext } from '$/utils/discord/events' import { applyRolesUsingPreset } from '$/utils/discord/rolePresets' -import { and, eq, gt } from 'drizzle-orm' withContext(on, 'guildMemberAdd', async ({ database }, member) => { const applieds = await database.query.appliedPresets.findMany({ diff --git a/bots/discord/src/events/discord/interactionCreate/chatCommand.ts b/bots/discord/src/events/discord/interactionCreate/chatCommand.ts index 89da0f5..91874fa 100644 --- a/bots/discord/src/events/discord/interactionCreate/chatCommand.ts +++ b/bots/discord/src/events/discord/interactionCreate/chatCommand.ts @@ -1,7 +1,7 @@ +import { MessageFlags } from 'discord.js' import CommandError from '$/classes/CommandError' import { createStackTraceEmbed } from '$utils/discord/embeds' import { on, withContext } from '$utils/discord/events' -import { MessageFlags } from 'discord.js' withContext(on, 'interactionCreate', async (context, interaction) => { if (!interaction.isChatInputCommand()) return diff --git a/bots/discord/src/events/discord/interactionCreate/contextMenuCommand.ts b/bots/discord/src/events/discord/interactionCreate/contextMenuCommand.ts index 359e16b..237175a 100644 --- a/bots/discord/src/events/discord/interactionCreate/contextMenuCommand.ts +++ b/bots/discord/src/events/discord/interactionCreate/contextMenuCommand.ts @@ -1,7 +1,7 @@ +import { MessageFlags } from 'discord.js' import CommandError from '$/classes/CommandError' import { createStackTraceEmbed } from '$utils/discord/embeds' import { on, withContext } from '$utils/discord/events' -import { MessageFlags } from 'discord.js' withContext(on, 'interactionCreate', async (context, interaction) => { if (!interaction.isContextMenuCommand()) return diff --git a/bots/discord/src/events/discord/interactionCreate/correctResponse.ts b/bots/discord/src/events/discord/interactionCreate/correctResponse.ts index 53eac71..e898e33 100644 --- a/bots/discord/src/events/discord/interactionCreate/correctResponse.ts +++ b/bots/discord/src/events/discord/interactionCreate/correctResponse.ts @@ -1,7 +1,3 @@ -import { responses } from '$/database/schemas' -import { handleUserResponseCorrection } from '$/utils/discord/messageScan' -import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds' -import { on, withContext } from '$utils/discord/events' import { type ButtonInteraction, MessageFlags, @@ -9,6 +5,10 @@ import { type TextBasedChannel, } from 'discord.js' import { eq } from 'drizzle-orm' +import { responses } from '$/database/schemas' +import { handleUserResponseCorrection } from '$/utils/discord/messageScan' +import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds' +import { on, withContext } from '$utils/discord/events' // No permission check required as it is already done when the user reacts to a bot response withContext(on, 'interactionCreate', async (context, interaction) => { diff --git a/bots/discord/src/events/discord/interactionCreate/trainMessage.ts b/bots/discord/src/events/discord/interactionCreate/trainMessage.ts index 19f45dd..5876c92 100644 --- a/bots/discord/src/events/discord/interactionCreate/trainMessage.ts +++ b/bots/discord/src/events/discord/interactionCreate/trainMessage.ts @@ -1,6 +1,6 @@ +import { MessageFlags, type TextBasedChannel } from 'discord.js' import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds' import { on, withContext } from '$utils/discord/events' -import { MessageFlags, type TextBasedChannel } from 'discord.js' withContext(on, 'interactionCreate', async (context, interaction) => { const { diff --git a/bots/discord/src/events/discord/messageReactionAdd/correctResponse.ts b/bots/discord/src/events/discord/messageReactionAdd/correctResponse.ts index f8ca312..23a4196 100644 --- a/bots/discord/src/events/discord/messageReactionAdd/correctResponse.ts +++ b/bots/discord/src/events/discord/messageReactionAdd/correctResponse.ts @@ -1,9 +1,3 @@ -import { MessageScanLabeledResponseReactions as Reactions } from '$/constants' -import { responses } from '$/database/schemas' -import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$/utils/discord/embeds' -import { on, withContext } from '$/utils/discord/events' -import { handleUserResponseCorrection } from '$/utils/discord/messageScan' -import { isAdmin } from '$/utils/discord/permissions' import { ActionRowBuilder, ButtonBuilder, @@ -12,6 +6,12 @@ import { StringSelectMenuOptionBuilder, } from 'discord.js' import { eq } from 'drizzle-orm' +import { MessageScanLabeledResponseReactions as Reactions } from '$/constants' +import { responses } from '$/database/schemas' +import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$/utils/discord/embeds' +import { on, withContext } from '$/utils/discord/events' +import { handleUserResponseCorrection } from '$/utils/discord/messageScan' +import { isAdmin } from '$/utils/discord/permissions' import type { ConfigMessageScanResponseLabelConfig } from '$/../config.schema' const PossibleReactions = Object.values(Reactions) as string[] diff --git a/bots/discord/src/events/discord/ready/removeExpiredPresets.ts b/bots/discord/src/events/discord/ready/removeExpiredPresets.ts index 6b0dc5f..be4c8cf 100644 --- a/bots/discord/src/events/discord/ready/removeExpiredPresets.ts +++ b/bots/discord/src/events/discord/ready/removeExpiredPresets.ts @@ -1,9 +1,9 @@ +import { type Client, DiscordAPIError } from 'discord.js' +import { and, eq, lt } from 'drizzle-orm' import { database, logger } from '$/context' import { appliedPresets } from '$/database/schemas' import { on, withContext } from '$/utils/discord/events' import { removeRolePreset } from '$/utils/discord/rolePresets' -import { type Client, DiscordAPIError } from 'discord.js' -import { and, eq, lt } from 'drizzle-orm' export default withContext(on, 'ready', async ({ config }, client) => { if (config.rolePresets) { diff --git a/bots/discord/src/index.ts b/bots/discord/src/index.ts index 2aaf35c..942dfe1 100644 --- a/bots/discord/src/index.ts +++ b/bots/discord/src/index.ts @@ -1,5 +1,5 @@ -import { api, discord, logger } from '$/context' import { getMissingEnvironmentVariables } from '@revanced/bot-shared' +import { api, discord, logger } from '$/context' import './events/register' diff --git a/bots/discord/src/utils/discord/embeds.ts b/bots/discord/src/utils/discord/embeds.ts index 453a3a8..c7e003b 100644 --- a/bots/discord/src/utils/discord/embeds.ts +++ b/bots/discord/src/utils/discord/embeds.ts @@ -1,5 +1,5 @@ -import { DefaultEmbedColor, ReVancedLogoURL } from '$/constants' import { type APIEmbed, EmbedBuilder, type EmbedField, type JSONEncodable, type User } from 'discord.js' +import { DefaultEmbedColor, ReVancedLogoURL } from '$/constants' import type { ConfigMessageScanResponseMessage } from '../../../config.schema' export const createErrorEmbed = (title: string | null, description?: string) => diff --git a/bots/discord/src/utils/discord/messageScan.ts b/bots/discord/src/utils/discord/messageScan.ts index 67636ce..beeff68 100644 --- a/bots/discord/src/utils/discord/messageScan.ts +++ b/bots/discord/src/utils/discord/messageScan.ts @@ -1,6 +1,6 @@ -import { type Response, responses } from '$/database/schemas' import { ButtonStyle, ComponentType } from 'discord.js' import { eq } from 'drizzle-orm' +import { type Response, responses } from '$/database/schemas' import { createMessageScanResponseEmbed } from './embeds' import type { Config, ConfigMessageScanResponse, ConfigMessageScanResponseLabelConfig } from 'config.schema' import type { APIActionRowComponent, APIButtonComponent, Message, PartialUser, User } from 'discord.js' diff --git a/bots/discord/src/utils/discord/moderation.ts b/bots/discord/src/utils/discord/moderation.ts index 055335e..3b538ec 100644 --- a/bots/discord/src/utils/discord/moderation.ts +++ b/bots/discord/src/utils/discord/moderation.ts @@ -1,5 +1,5 @@ -import { config, logger } from '$/context' import decancer from 'decancer' +import { config, logger } from '$/context' import { applyReferenceToModerationActionEmbed, createModerationActionEmbed } from './embeds' import type { CommandInteraction, EmbedBuilder, Guild, GuildMember, Message, User } from 'discord.js' diff --git a/bots/discord/src/utils/discord/rolePresets.ts b/bots/discord/src/utils/discord/rolePresets.ts index 514b38f..4c2658d 100644 --- a/bots/discord/src/utils/discord/rolePresets.ts +++ b/bots/discord/src/utils/discord/rolePresets.ts @@ -1,6 +1,6 @@ +import { and, eq } from 'drizzle-orm' import { config, database } from '$/context' import { appliedPresets } from '$/database/schemas' -import { and, eq } from 'drizzle-orm' import type { GuildMember } from 'discord.js' // TODO: Fix this type