diff options
Diffstat (limited to 'packages')
5 files changed, 58 insertions, 28 deletions
diff --git a/packages/gateway/src/commands/pin.ts b/packages/gateway/src/commands/pin.ts index 603c172..dc95032 100644 --- a/packages/gateway/src/commands/pin.ts +++ b/packages/gateway/src/commands/pin.ts @@ -59,7 +59,12 @@ export const handlePinCommand = async (message: Message) => { } try { - const results: { success: boolean; messageId: string; action: string; error?: string }[] = []; + const results: { + success: boolean; + messageId: string; + action: string; + error?: string; + }[] = []; for (const messageId of messageIds) { try { @@ -70,7 +75,7 @@ export const handlePinCommand = async (message: Message) => { success: false, messageId, action: "fetch", - error: "Message not found" + error: "Message not found", }); continue; @@ -81,14 +86,14 @@ export const handlePinCommand = async (message: Message) => { results.push({ success: true, messageId, - action: "unpin" + action: "unpin", }); } else { await targetMessage.pin(); results.push({ success: true, messageId, - action: "pin" + action: "pin", }); } } catch (error) { @@ -97,15 +102,15 @@ export const handlePinCommand = async (message: Message) => { success: false, messageId, action: "process", - error: error instanceof Error ? error.message : "Unknown error" + error: error instanceof Error ? error.message : "Unknown error", }); } } await message.delete(); - const successCount = results.filter(r => r.success).length; - const failCount = results.filter(r => !r.success).length; + const successCount = results.filter((r) => r.success).length; + const failCount = results.filter((r) => !r.success).length; let resultMessage = `📌 Processed ${results.length} message(s):\n`; resultMessage += `✅ ${successCount} successful, ❌ ${failCount} failed\n\n`; diff --git a/packages/gateway/src/listeners/clientReady/umagramCatchup.ts b/packages/gateway/src/listeners/clientReady/umagramCatchup.ts index f6b7870..c8b7c5a 100644 --- a/packages/gateway/src/listeners/clientReady/umagramCatchup.ts +++ b/packages/gateway/src/listeners/clientReady/umagramCatchup.ts @@ -5,10 +5,20 @@ const GUILD_UMAGRAM_CHANNELS = { "1423919136974835782": "1423923190953934960", // Roleplay guild } as const; -const processUmagramChannel = async (client: Client, guildId: string, channelId: string) => { +const processUmagramChannel = async ( + client: Client, + guildId: string, + channelId: string, +) => { const channel = client.channels.cache.get(channelId); - if (!channel || !channel.isTextBased() || !("guildId" in channel) || channel.guildId !== guildId) return; + if ( + !channel || + !channel.isTextBased() || + !("guildId" in channel) || + channel.guildId !== guildId + ) + return; const processChannelMessages = async ( targetChannel: any, @@ -71,7 +81,10 @@ const processUmagramChannel = async (client: Client, guildId: string, channelId: for (const thread of allThreads) try { - await processChannelMessages(thread, `Guild ${guildId} - Thread: ${thread.name}`); + await processChannelMessages( + thread, + `Guild ${guildId} - Thread: ${thread.name}`, + ); } catch (error) { console.error(`Error processing thread ${thread.name}:`, error); } @@ -87,4 +100,4 @@ export const handleUmagramCatchup = async (client: Client) => { } catch (error) { console.error("Error adding hearts to existing messages:", error); } -};
\ No newline at end of file +}; diff --git a/packages/gateway/src/listeners/clientReady/voiceConnection.ts b/packages/gateway/src/listeners/clientReady/voiceConnection.ts index 5cc3897..a6d697a 100644 --- a/packages/gateway/src/listeners/clientReady/voiceConnection.ts +++ b/packages/gateway/src/listeners/clientReady/voiceConnection.ts @@ -35,8 +35,10 @@ const createVoiceConnection = ( connection.subscribe(player); connection.on(VoiceConnectionStatus.Disconnected, (oldState, newState) => { - console.log(`Voice disconnected in guild ${guildId}: ${oldState.status} -> ${newState.status}`); - + console.log( + `Voice disconnected in guild ${guildId}: ${oldState.status} -> ${newState.status}`, + ); + if (newState.reason !== VoiceConnectionDisconnectReason.Manual) setTimeout(() => { console.log(`Attempting to reconnect voice in guild ${guildId}...`); @@ -44,18 +46,25 @@ const createVoiceConnection = ( }, 5000); }); connection.on(VoiceConnectionStatus.Destroyed, () => { - console.log(`Voice connection destroyed in guild ${guildId}, attempting to reconnect...`); + console.log( + `Voice connection destroyed in guild ${guildId}, attempting to reconnect...`, + ); setTimeout(() => { createVoiceConnection(client, guildId, channelId); }, 10000); }); connection.on("error", (error) => { console.error(`Voice connection error for guild ${guildId}:`, error); - + const errorCode = (error as any).code; - if (errorCode === 'ENOTFOUND' || errorCode === 'UND_ERR_CONNECT_TIMEOUT') { - console.log(`Network error for guild ${guildId}, retrying in 30 seconds...`); + if ( + errorCode === "ENOTFOUND" || + errorCode === "UND_ERR_CONNECT_TIMEOUT" + ) { + console.log( + `Network error for guild ${guildId}, retrying in 30 seconds...`, + ); setTimeout(() => { createVoiceConnection(client, guildId, channelId); }, 30000); @@ -77,11 +86,11 @@ const createVoiceConnection = ( }; export const handleVoiceConnection = (client: Client) => { - process.on('uncaughtException', (error) => { - console.error('Uncaught Exception in voice connection:', error); + process.on("uncaughtException", (error) => { + console.error("Uncaught Exception in voice connection:", error); }); - process.on('unhandledRejection', (reason, promise) => { - console.error('Unhandled Rejection in voice connection:', reason); + process.on("unhandledRejection", (reason) => { + console.error("Unhandled Rejection in voice connection:", reason); }); for (const [guildId, channelId] of Object.entries(GUILD_VOICE_CHANNELS)) diff --git a/packages/gateway/src/listeners/messageCreate/randomEyesReaction.ts b/packages/gateway/src/listeners/messageCreate/randomEyesReaction.ts index 0f2f914..8768474 100644 --- a/packages/gateway/src/listeners/messageCreate/randomEyesReaction.ts +++ b/packages/gateway/src/listeners/messageCreate/randomEyesReaction.ts @@ -2,20 +2,20 @@ import { Message } from "discord.js"; const EYES_REACTION_CHANNELS = [ "1410333697701314791", - "1406422619087044675", - "1418154524178255932" + "1406422619087044675", + "1418154524178255932", ] as const; export const handleRandomEyesReaction = async (message: Message) => { if (!EYES_REACTION_CHANNELS.includes(message.channelId as any)) return; - + if (message.author.bot) return; - + if (Math.floor(Math.random() * 100) !== 0) return; - + try { await message.react("👀"); - + const messageLink = `https://discord.com/channels/${message.guildId}/${message.channelId}/${message.id}`; console.log(`👀 Random reaction added to message: ${messageLink}`); diff --git a/packages/gateway/src/listeners/messageCreate/roleplayUmagram.ts b/packages/gateway/src/listeners/messageCreate/roleplayUmagram.ts index 9ed6e2a..23f97bd 100644 --- a/packages/gateway/src/listeners/messageCreate/roleplayUmagram.ts +++ b/packages/gateway/src/listeners/messageCreate/roleplayUmagram.ts @@ -8,7 +8,10 @@ const GUILD_UMAGRAM_CHANNELS = { export const handleRoleplayUmagram = async (message: Message) => { if (!message.guildId || !(message.guildId in GUILD_UMAGRAM_CHANNELS)) return; - const umagramChannelId = GUILD_UMAGRAM_CHANNELS[message.guildId as keyof typeof GUILD_UMAGRAM_CHANNELS]; + const umagramChannelId = + GUILD_UMAGRAM_CHANNELS[ + message.guildId as keyof typeof GUILD_UMAGRAM_CHANNELS + ]; const isMainChannel = message.channelId === umagramChannelId; const isThreadInChannel = message.channel?.isThread() && |