Logging Update
- Changed to uniform logging with the 'debug' module - Updated all apps
This commit is contained in:
@@ -5,8 +5,8 @@ import ping from './commands/ping.js';
|
||||
import join from './commands/join.js';
|
||||
import leave from './commands/leave.js';
|
||||
// Debug
|
||||
import debugBuilder from "./utilities/debugBuilder.js";
|
||||
const log = new debugBuilder("bot", "app");
|
||||
import ModuleDebugBuilder from "./utilities/moduleDebugBuilder.js";
|
||||
const log = new ModuleDebugBuilder("bot", "app");
|
||||
// Modules
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
// Utilities
|
||||
@@ -65,4 +65,5 @@ function main(){
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
||||
//module.exports = client;
|
||||
@@ -28,6 +28,7 @@ export default async function join(interaction){
|
||||
audioInstance.on('data', buffer => {
|
||||
buffer = Buffer.from(buffer);
|
||||
const encoded = encoder.encode(buffer);
|
||||
// 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(encoded);
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {getVoiceConnection} from "@discordjs/voice";
|
||||
import {replyToInteraction} from "../utilities/messageHandler.js";
|
||||
// Debug
|
||||
//import debugBuilder from "../utilities/debugBuilder.js";
|
||||
//import debugBuilder from "../utilities/moduleDebugBuilder.js";
|
||||
//const log = new debugBuilder("bot", "leave");
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,8 @@ import {getDeviceID} from '../utilities/configHandler.js'
|
||||
// Modules
|
||||
import portAudio from 'naudiodon';
|
||||
// Debug
|
||||
import debugBuilder from "../utilities/debugBuilder.js";
|
||||
const log = new debugBuilder("bot", "audioController");
|
||||
import ModuleDebugBuilder from "../utilities/moduleDebugBuilder.js";
|
||||
const log = new ModuleDebugBuilder("bot", "audioController");
|
||||
|
||||
/**
|
||||
* Checks to make sure the selected audio device is available and returns the device object (PortAudio Device Info)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { readFileSync } from 'fs';
|
||||
// Debug
|
||||
import debugBuilder from "./debugBuilder.js";
|
||||
const log = new debugBuilder("bot", "configHandler");
|
||||
import ModuleDebugBuilder from "./moduleDebugBuilder.js";
|
||||
const log = new ModuleDebugBuilder("bot", "configHandler");
|
||||
|
||||
export function getConfig() {
|
||||
return JSON.parse(readFileSync("./config/botConfig.json"));
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Debug
|
||||
import Debug from 'debug';
|
||||
|
||||
export default class debugBuilder {
|
||||
/**
|
||||
* Create the different logging methods for a function
|
||||
* Namespace template = ("[app]:[fileName]:['INFO', 'WARNING', 'DEBUG', 'ERROR']")
|
||||
* @param {string} appName The name of the app to be used in the 'app' portion of the namespace
|
||||
* @param {string} fileName The name of the file calling the builder to be used in the 'fileName' portion of the namespace
|
||||
*/
|
||||
constructor(appName, fileName) {
|
||||
this.INFO = Debug(`${appName}:${fileName}:INFO`);
|
||||
this.DEBUG = Debug(`${appName}:${fileName}:DEBUG`);
|
||||
this.WARN = Debug(`${appName}:${fileName}:WARNING`);
|
||||
this.ERROR = Debug(`${appName}:${fileName}::ERROR`);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Debug
|
||||
import debugBuilder from "./debugBuilder.js";
|
||||
const log = new debugBuilder("bot", "messageHandler");
|
||||
import ModuleDebugBuilder from "./moduleDebugBuilder.js";
|
||||
const log = new ModuleDebugBuilder("bot", "messageHandler");
|
||||
|
||||
export function replyToInteraction(interaction, message){
|
||||
interaction.reply({ content: message, fetchReply: true })
|
||||
|
||||
17
Client/discord-bot/utilities/moduleDebugBuilder.js
Normal file
17
Client/discord-bot/utilities/moduleDebugBuilder.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Debug
|
||||
import Debug from 'debug';
|
||||
|
||||
/**
|
||||
* Create the different logging methods for a function
|
||||
* Namespace template = ("[app]:[fileName]:['INFO', 'WARNING', 'DEBUG', 'ERROR']")
|
||||
* @param {string} appName The name of the app to be used in the 'app' portion of the namespace
|
||||
* @param {string} fileName The name of the file calling the builder to be used in the 'fileName' portion of the namespace
|
||||
*/
|
||||
export default class ModuleDebugBuilder {
|
||||
constructor(appName, fileName) {
|
||||
this.INFO = Debug(`${appName}:${fileName}:INFO`);
|
||||
this.DEBUG = Debug(`${appName}:${fileName}:DEBUG`);
|
||||
this.WARN = Debug(`${appName}:${fileName}:WARNING`);
|
||||
this.ERROR = Debug(`${appName}:${fileName}:ERROR`);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import {REST} from "@discordjs/rest";
|
||||
import {getApplicationID, getGuildID, getTOKEN} from "./configHandler.js";
|
||||
import { Routes, ChannelType } from "discord.js";
|
||||
// Debug
|
||||
import debugBuilder from "./debugBuilder.js";
|
||||
const log = new debugBuilder("bot", "registerCommands");
|
||||
import ModuleDebugBuilder from "./moduleDebugBuilder.js";
|
||||
const log = new ModuleDebugBuilder("bot", "registerCommands");
|
||||
|
||||
const pingCommand = new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
|
||||
Reference in New Issue
Block a user