Added activity when listening to system
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
|||||||
|
|
||||||
import { GatewayIntentBits } from 'discord-api-types/v10';
|
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';
|
import prism_media from 'prism-media';
|
||||||
const { FFmpeg } = prism_media;
|
const { FFmpeg } = prism_media;
|
||||||
@@ -74,7 +74,7 @@ player.on('stateChange', (oldState, newState) => {
|
|||||||
export async function connectToChannel(channel) {
|
export async function connectToChannel(channel) {
|
||||||
const connection = joinVoiceChannel({
|
const connection = joinVoiceChannel({
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
guildId: channel.guild.id,
|
guildId: channel.guild.id,
|
||||||
adapterCreator: channel.guild.voiceAdapterCreator,
|
adapterCreator: channel.guild.voiceAdapterCreator,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
@@ -88,7 +88,7 @@ export async function connectToChannel(channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getVoiceChannelFromID(client, channelID) {
|
export async function getVoiceChannelFromID(client, channelID) {
|
||||||
return client.channels.cache.get(channelID)
|
return client.channels.cache.get(channelID)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkIfConnectedToVC(guildId) {
|
export async function checkIfConnectedToVC(guildId) {
|
||||||
@@ -97,7 +97,7 @@ export async function checkIfConnectedToVC(guildId) {
|
|||||||
return connection
|
return connection
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initDiscordBotClient(token, readyCallback){
|
export async function initDiscordBotClient(token, systemName, readyCallback) {
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent],
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent],
|
||||||
});
|
});
|
||||||
@@ -105,9 +105,12 @@ export async function initDiscordBotClient(token, readyCallback){
|
|||||||
client.on(Events.ClientReady, () => {
|
client.on(Events.ClientReady, () => {
|
||||||
console.log('discord.js client is ready!');
|
console.log('discord.js client is ready!');
|
||||||
attachRecorder();
|
attachRecorder();
|
||||||
|
client.user.setPresence({
|
||||||
|
activities: [{ name: `${systemName}`, type: ActivityType.Listening }],
|
||||||
|
});
|
||||||
readyCallback(client);
|
readyCallback(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* on event create
|
/* on event create
|
||||||
// TODO - Implement methods for discord users to interact directly with the bots for realtime info (last talked ID/TG, etc.)
|
// 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) => {
|
client.on(Events.MessageCreate, async (message) => {
|
||||||
@@ -129,6 +132,6 @@ export async function initDiscordBotClient(token, readyCallback){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ export const initSocketConnection = async (localNodeConfig) => {
|
|||||||
// TODO - Implement logic to control OP25 for the requested channel/system
|
// TODO - Implement logic to control OP25 for the requested channel/system
|
||||||
|
|
||||||
// Join the requested channel with the requested ID
|
// Join the requested channel with the requested ID
|
||||||
initDiscordBotClient(joinData.clientID, client => {
|
initDiscordBotClient(joinData.clientID, joinData.system, client => {
|
||||||
getVoiceChannelFromID(client, joinData.channelID).then(vc => {
|
getVoiceChannelFromID(client, joinData.channelID).then(vc => {
|
||||||
const connection = connectToChannel(vc);
|
const connection = connectToChannel(vc);
|
||||||
console.log("Bot Connected to VC");
|
console.log("Bot Connected to VC");
|
||||||
|
|||||||
Reference in New Issue
Block a user