summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-04 02:20:04 -0700
committerFuwn <[email protected]>2025-10-04 02:20:04 -0700
commitb82213f15495be15335d3d64cc18ba28e9f36d26 (patch)
tree3747c869eefe58f71bd27cfb622acb43858889b0
parentfeat(gateway:voiceConnection): Support multiple guilds (diff)
downloadumabotdiscord-b82213f15495be15335d3d64cc18ba28e9f36d26.tar.xz
umabotdiscord-b82213f15495be15335d3d64cc18ba28e9f36d26.zip
feat(gateway): Clean and lint
-rw-r--r--packages/gateway/src/listeners/clientReady/umagramCatchup.ts8
-rw-r--r--packages/gateway/src/listeners/clientReady/voiceConnection.ts21
-rw-r--r--packages/gateway/src/listeners/messageDeletion.ts19
-rw-r--r--packages/gateway/src/listeners/messageEdit.ts15
4 files changed, 41 insertions, 22 deletions
diff --git a/packages/gateway/src/listeners/clientReady/umagramCatchup.ts b/packages/gateway/src/listeners/clientReady/umagramCatchup.ts
index 384e5db..13564e6 100644
--- a/packages/gateway/src/listeners/clientReady/umagramCatchup.ts
+++ b/packages/gateway/src/listeners/clientReady/umagramCatchup.ts
@@ -6,7 +6,13 @@ export const handleUmagramCatchup = async (client: Client) => {
try {
const channel = client.channels.cache.get(ROLEPLAY_UMAGRAM_CHANNEL_ID);
- if (!channel || !channel.isTextBased() || !("guildId" in channel) || channel.guildId !== GUILD_ID) return;
+ if (
+ !channel ||
+ !channel.isTextBased() ||
+ !("guildId" in channel) ||
+ channel.guildId !== GUILD_ID
+ )
+ return;
const processChannelMessages = async (
targetChannel: any,
diff --git a/packages/gateway/src/listeners/clientReady/voiceConnection.ts b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
index 9906c20..81fc539 100644
--- a/packages/gateway/src/listeners/clientReady/voiceConnection.ts
+++ b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
@@ -10,7 +10,11 @@ const GUILD_VOICE_CHANNELS = {
"1423919136974835782": "1423919139394949221", // Roleplay guild
} as const;
-const createVoiceConnection = (client: Client, guildId: string, channelId: string) => {
+const createVoiceConnection = (
+ client: Client,
+ guildId: string,
+ channelId: string,
+) => {
const voiceChannel = client.channels.cache.get(channelId);
if (!voiceChannel || !voiceChannel.isVoiceBased()) {
@@ -47,7 +51,10 @@ const createVoiceConnection = (client: Client, guildId: string, channelId: strin
newConnection.subscribe(newPlayer);
newConnection.on("error", (error) => {
- console.error(`Voice reconnection error for guild ${guildId}:`, error);
+ console.error(
+ `Voice reconnection error for guild ${guildId}:`,
+ error,
+ );
setTimeout(() => {
createVoiceConnection(client, guildId, channelId);
}, 15000);
@@ -58,7 +65,10 @@ const createVoiceConnection = (client: Client, guildId: string, channelId: strin
}, 5000);
});
} catch (error) {
- console.error(`Failed to reconnect to voice channel for guild ${guildId}:`, error);
+ console.error(
+ `Failed to reconnect to voice channel for guild ${guildId}:`,
+ error,
+ );
setTimeout(() => {
createVoiceConnection(client, guildId, channelId);
}, 10000);
@@ -71,7 +81,10 @@ const createVoiceConnection = (client: Client, guildId: string, channelId: strin
}, 5000);
});
} catch (error) {
- console.error(`Failed to connect to voice channel for guild ${guildId}:`, error);
+ console.error(
+ `Failed to connect to voice channel for guild ${guildId}:`,
+ error,
+ );
setTimeout(() => {
createVoiceConnection(client, guildId, channelId);
}, 10000);
diff --git a/packages/gateway/src/listeners/messageDeletion.ts b/packages/gateway/src/listeners/messageDeletion.ts
index e0a73a4..bbd00fe 100644
--- a/packages/gateway/src/listeners/messageDeletion.ts
+++ b/packages/gateway/src/listeners/messageDeletion.ts
@@ -1,5 +1,4 @@
import { Client, Events, EmbedBuilder } from "discord.js";
-import { GUILD_ID } from "../constants";
import { sendAuditLog } from "../commands/utilities";
const GUILD_CHANNEL_MAPPINGS = {
@@ -9,7 +8,11 @@ const GUILD_CHANNEL_MAPPINGS = {
export const handleMessageDeletion = (client: Client) => {
client.on(Events.MessageDelete, async (deletedMessage) => {
- if (!deletedMessage.guildId || !(deletedMessage.guildId in GUILD_CHANNEL_MAPPINGS)) return;
+ if (
+ !deletedMessage.guildId ||
+ !(deletedMessage.guildId in GUILD_CHANNEL_MAPPINGS)
+ )
+ return;
if (deletedMessage.author?.bot) return;
@@ -24,7 +27,10 @@ export const handleMessageDeletion = (client: Client) => {
const author = deletedMessage.author;
const content = deletedMessage.content || "*No text content*";
const attachments = deletedMessage.attachments;
- const guildChannelId = GUILD_CHANNEL_MAPPINGS[deletedMessage.guildId as keyof typeof GUILD_CHANNEL_MAPPINGS];
+ const guildChannelId =
+ GUILD_CHANNEL_MAPPINGS[
+ deletedMessage.guildId as keyof typeof GUILD_CHANNEL_MAPPINGS
+ ];
const embed = new EmbedBuilder()
.setTitle("🗑️ Message Deleted")
@@ -106,12 +112,7 @@ export const handleMessageDeletion = (client: Client) => {
if (isBotOrOwner) {
await sendAuditLog(client, embed, additionalContent);
} else {
- await sendAuditLog(
- client,
- embed,
- additionalContent,
- guildChannelId,
- );
+ await sendAuditLog(client, embed, additionalContent, guildChannelId);
}
}
} catch (error) {
diff --git a/packages/gateway/src/listeners/messageEdit.ts b/packages/gateway/src/listeners/messageEdit.ts
index 9375b8d..f794b44 100644
--- a/packages/gateway/src/listeners/messageEdit.ts
+++ b/packages/gateway/src/listeners/messageEdit.ts
@@ -8,7 +8,8 @@ const GUILD_CHANNEL_MAPPINGS = {
export const handleMessageEdit = (client: Client) => {
client.on(Events.MessageUpdate, async (oldMessage, newMessage) => {
- if (!newMessage.guildId || !(newMessage.guildId in GUILD_CHANNEL_MAPPINGS)) return;
+ if (!newMessage.guildId || !(newMessage.guildId in GUILD_CHANNEL_MAPPINGS))
+ return;
if (newMessage.author?.bot) return;
@@ -25,7 +26,10 @@ export const handleMessageEdit = (client: Client) => {
const author = newMessage.author;
const oldContent = oldMessage.content || "*No text content*";
const newContent = newMessage.content || "*No text content*";
- const guildChannelId = GUILD_CHANNEL_MAPPINGS[newMessage.guildId as keyof typeof GUILD_CHANNEL_MAPPINGS];
+ const guildChannelId =
+ GUILD_CHANNEL_MAPPINGS[
+ newMessage.guildId as keyof typeof GUILD_CHANNEL_MAPPINGS
+ ];
const embed = new EmbedBuilder()
.setTitle("✏️ Message Edited")
.setColor("#ffaa00")
@@ -84,12 +88,7 @@ export const handleMessageEdit = (client: Client) => {
if (isBotOrOwner) {
await sendAuditLog(client, embed, additionalContent);
} else {
- await sendAuditLog(
- client,
- embed,
- additionalContent,
- guildChannelId,
- );
+ await sendAuditLog(client, embed, additionalContent, guildChannelId);
}
} else {
embed.addFields(