From 3ebccdba0c2f4326895a2736d5d8f265937274fb Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 11 Feb 2024 04:49:37 -0500 Subject: [PATCH] Added activity when listening to system --- client/discordAudioBot/dab.mjs | 15 +++++++++------ client/modules/socketClient.mjs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/discordAudioBot/dab.mjs b/client/discordAudioBot/dab.mjs index e916b02..8afecb8 100644 --- a/client/discordAudioBot/dab.mjs +++ b/client/discordAudioBot/dab.mjs @@ -12,7 +12,7 @@ import { import { GatewayIntentBits } from 'discord-api-types/v10'; -import { Client, Events } from 'discord.js'; +import { Client, Events, ActivityType } from 'discord.js'; import prism_media from 'prism-media'; const { FFmpeg } = prism_media; @@ -74,7 +74,7 @@ player.on('stateChange', (oldState, newState) => { export async function connectToChannel(channel) { const connection = joinVoiceChannel({ channelId: channel.id, - guildId: channel.guild.id, + guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, }); try { @@ -88,7 +88,7 @@ export async function connectToChannel(channel) { } export async function getVoiceChannelFromID(client, channelID) { - return client.channels.cache.get(channelID) + return client.channels.cache.get(channelID) } export async function checkIfConnectedToVC(guildId) { @@ -97,7 +97,7 @@ export async function checkIfConnectedToVC(guildId) { return connection } -export async function initDiscordBotClient(token, readyCallback){ +export async function initDiscordBotClient(token, systemName, readyCallback) { const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent], }); @@ -105,9 +105,12 @@ export async function initDiscordBotClient(token, readyCallback){ client.on(Events.ClientReady, () => { console.log('discord.js client is ready!'); attachRecorder(); + client.user.setPresence({ + activities: [{ name: `${systemName}`, type: ActivityType.Listening }], + }); readyCallback(client); }); - + /* on event create // TODO - Implement methods for discord users to interact directly with the bots for realtime info (last talked ID/TG, etc.) client.on(Events.MessageCreate, async (message) => { @@ -129,6 +132,6 @@ export async function initDiscordBotClient(token, readyCallback){ } }); */ - + client.login(token); } \ No newline at end of file diff --git a/client/modules/socketClient.mjs b/client/modules/socketClient.mjs index 7319f5c..a37301b 100644 --- a/client/modules/socketClient.mjs +++ b/client/modules/socketClient.mjs @@ -17,7 +17,7 @@ export const initSocketConnection = async (localNodeConfig) => { // TODO - Implement logic to control OP25 for the requested channel/system // Join the requested channel with the requested ID - initDiscordBotClient(joinData.clientID, client => { + initDiscordBotClient(joinData.clientID, joinData.system, client => { getVoiceChannelFromID(client, joinData.channelID).then(vc => { const connection = connectToChannel(vc); console.log("Bot Connected to VC");