Added activity when listening to system

This commit is contained in:
Logan Cusano
2024-02-11 04:49:37 -05:00
parent ed33654b8c
commit 3ebccdba0c
2 changed files with 10 additions and 7 deletions

View File

@@ -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;
@@ -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,6 +105,9 @@ 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);
});

View File

@@ -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");