summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-04 02:19:41 -0700
committerFuwn <[email protected]>2025-10-04 02:19:41 -0700
commitf4590b2b12643e4e28e9970260e4f797cafbbfbe (patch)
treedb446664e568dc72d850237f88d9f8ee91a7cc7b /packages
parentfeat(gateway:listeners): Multi-guild support for messageCreate and umagramCat... (diff)
downloadumabotdiscord-f4590b2b12643e4e28e9970260e4f797cafbbfbe.tar.xz
umabotdiscord-f4590b2b12643e4e28e9970260e4f797cafbbfbe.zip
feat(gateway:voiceConnection): Support multiple guilds
Diffstat (limited to 'packages')
-rw-r--r--packages/gateway/src/listeners/clientReady/voiceConnection.ts37
1 files changed, 22 insertions, 15 deletions
diff --git a/packages/gateway/src/listeners/clientReady/voiceConnection.ts b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
index bdee625..9906c20 100644
--- a/packages/gateway/src/listeners/clientReady/voiceConnection.ts
+++ b/packages/gateway/src/listeners/clientReady/voiceConnection.ts
@@ -5,16 +5,18 @@ import {
createAudioPlayer,
} from "@discordjs/voice";
-const VOICE_CHANNEL_ID = "1422049438863589487";
+const GUILD_VOICE_CHANNELS = {
+ "1406422617724026901": "1422049438863589487", // Central guild
+ "1423919136974835782": "1423919139394949221", // Roleplay guild
+} as const;
-export const handleVoiceConnection = (client: Client) => {
- const voiceChannel = client.channels.cache.get(VOICE_CHANNEL_ID);
+const createVoiceConnection = (client: Client, guildId: string, channelId: string) => {
+ const voiceChannel = client.channels.cache.get(channelId);
if (!voiceChannel || !voiceChannel.isVoiceBased()) {
console.error(
- `Voice channel ${VOICE_CHANNEL_ID} not found or is not a voice channel`,
+ `Voice channel ${channelId} not found or is not a voice channel for guild ${guildId}`,
);
-
return;
}
@@ -28,9 +30,9 @@ export const handleVoiceConnection = (client: Client) => {
connection.subscribe(player);
connection.on("error", (error) => {
- console.error("Voice connection error:", error);
+ console.error(`Voice connection error for guild ${guildId}:`, error);
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 15000);
});
connection.on(VoiceConnectionStatus.Disconnected, () => {
@@ -45,33 +47,38 @@ export const handleVoiceConnection = (client: Client) => {
newConnection.subscribe(newPlayer);
newConnection.on("error", (error) => {
- console.error("Voice reconnection error:", error);
+ console.error(`Voice reconnection error for guild ${guildId}:`, error);
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 15000);
});
newConnection.on(VoiceConnectionStatus.Disconnected, () => {
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 5000);
});
} catch (error) {
- console.error("Failed to reconnect to voice channel:", error);
+ console.error(`Failed to reconnect to voice channel for guild ${guildId}:`, error);
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 10000);
}
}, 5000);
});
connection.on(VoiceConnectionStatus.Destroyed, () => {
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 5000);
});
} catch (error) {
- console.error("Failed to connect to voice channel:", error);
+ console.error(`Failed to connect to voice channel for guild ${guildId}:`, error);
setTimeout(() => {
- handleVoiceConnection(client);
+ createVoiceConnection(client, guildId, channelId);
}, 10000);
}
};
+
+export const handleVoiceConnection = (client: Client) => {
+ for (const [guildId, channelId] of Object.entries(GUILD_VOICE_CHANNELS))
+ createVoiceConnection(client, guildId, channelId);
+};