Update debugging

- Uniform client name
This commit is contained in:
Logan Cusano
2023-04-30 03:29:38 -04:00
parent 546d9e8829
commit b248e7f40e
9 changed files with 25 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "leave"); const log = new DebugBuilder("client", "leave");
// Modules // Modules
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder } = require('discord.js');
const { leave } = require("../controllers/commandController") const { leave } = require("../controllers/commandController")

View File

@@ -1,6 +1,6 @@
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "status"); const log = new DebugBuilder("client", "status");
// Modules // Modules
const { status } = require('../controllers/commandController'); const { status } = require('../controllers/commandController');
// Utilities // Utilities

View File

@@ -1,6 +1,6 @@
{ {
"ApplicationID": "943742040255115304", "ApplicationID": "943742040255115304",
"GuildID": "367396189529833472", "GuildID": "367396189529833472",
"DeviceID": "5", "DeviceID": "1",
"DeviceName": "VoiceMeeter Aux Output (VB-Audi" "DeviceName": "VoiceMeeter VAIO3 Output (VB-Au"
} }

View File

@@ -4,7 +4,7 @@ exports.clientConfig = {
"id": 13, "id": 13,
"name": "boilin balls in the hall", "name": "boilin balls in the hall",
"ip": "172.16.100.150", "ip": "172.16.100.150",
"port": 3001, "port": 3010,
"location": "the house", "location": "the house",
"nearbySystems": ["Westchester Cty. Simulcast"], "nearbySystems": ["Westchester Cty. Simulcast"],
"online": true "online": true

View File

@@ -1,6 +1,6 @@
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "commandController"); const log = new DebugBuilder("client", "commandController");
// Modules // Modules
const { joinVoiceChannel, VoiceConnectionStatus, getVoiceConnection } = require("@discordjs/voice"); const { joinVoiceChannel, VoiceConnectionStatus, getVoiceConnection } = require("@discordjs/voice");
const { OpusEncoder } = require("@discordjs/opus"); const { OpusEncoder } = require("@discordjs/opus");
@@ -31,7 +31,7 @@ exports.join = async function join({interaction= undefined, guildID= undefined,
log.DEBUG("Channel ID: ", channelID) log.DEBUG("Channel ID: ", channelID)
log.DEBUG("Guild ID: ", guildID) log.DEBUG("Guild ID: ", guildID)
const voiceConnection = joinVoiceChannel({ const voiceConnection = await joinVoiceChannel({
channelId: channelID, channelId: channelID,
guildId: guildID, guildId: guildID,
adapterCreator: guildObj.voiceAdapterCreator, adapterCreator: guildObj.voiceAdapterCreator,
@@ -41,21 +41,24 @@ exports.join = async function join({interaction= undefined, guildID= undefined,
const audioInstance = await createAudioInstance(); const audioInstance = await createAudioInstance();
audioInstance.on('audio', (buffer) => { log.VERBOSE("Audio Instance: ", audioInstance);
buffer = Buffer.from(buffer);
log.DEBUG("Audio buffer: ", buffer); audioInstance.on('data', buffer => {
//buffer = Buffer.from(buffer);
log.VERBOSE("Audio buffer: ", buffer);
const encodedBuffer = encoder.encode(buffer); const encodedBuffer = encoder.encode(buffer);
log.DEBUG("Encoded packet: ", encodedBuffer);
// TODO Add a function here to check the volume of either buffer and only play audio to discord when there is audio to be played // TODO Add a function here to check the volume of either buffer and only play audio to discord when there is audio to be played
voiceConnection.playOpusPacket(encodedBuffer); voiceConnection.playOpusPacket(encodedBuffer);
}) })
// Exit the audio handler when the bot disconnects // Exit the audio handler when the bot disconnects
voiceConnection.on(VoiceConnectionStatus.Destroyed, () => { voiceConnection.on(VoiceConnectionStatus.Destroyed, () => {
audioInstance.close(); audioInstance.quit();
}) })
if (guildID && callback) callback(); audioInstance.start();
if (guildID && callback) return callback();
else return; else return;
} }

View File

@@ -1,6 +1,6 @@
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "configController"); const log = new DebugBuilder("client", "configController");
// Modules // Modules
const { readFileSync } = require('fs'); const { readFileSync } = require('fs');
const path = require("path"); const path = require("path");

View File

@@ -12,6 +12,11 @@ exports.DebugBuilder = class DebugBuilder {
this.INFO = debug(`${appName}:${fileName}:INFO`); this.INFO = debug(`${appName}:${fileName}:INFO`);
this.DEBUG = debug(`${appName}:${fileName}:DEBUG`); this.DEBUG = debug(`${appName}:${fileName}:DEBUG`);
this.WARN = debug(`${appName}:${fileName}:WARNING`); this.WARN = debug(`${appName}:${fileName}:WARNING`);
this.ERROR = debug(`${appName}:${fileName}:ERROR`); this.VERBOSE = debug(`${appName}:${fileName}:VERBOSE`);
this.ERROR = (...messageParts) => {
const error = debug(`${appName}:${fileName}:ERROR`);
error(messageParts);
if (process.env.EXIT_ON_ERROR && process.env.EXIT_ON_ERROR > 0) setTimeout(process.exit, process.env.EXIT_ON_ERROR_DELAY ?? 0);
}
} }
} }

View File

@@ -4,7 +4,7 @@ const { exec } = require("child_process");
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
// Global Vars // Global Vars
const log = new DebugBuilder("client-bot", "executeConsoleCommands"); const log = new DebugBuilder("client", "executeConsoleCommands");
const execCommand = promisify(exec); const execCommand = promisify(exec);

View File

@@ -1,6 +1,6 @@
// Debug // Debug
const { DebugBuilder } = require("../utilities/debugBuilder.js"); const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client-bot", "messageHandler"); const log = new DebugBuilder("client", "messageHandler");
exports.replyToInteraction = async function replyToInteraction(interaction, message){ exports.replyToInteraction = async function replyToInteraction(interaction, message){
interaction.reply({ content: message, fetchReply: true }) interaction.reply({ content: message, fetchReply: true })