mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-16 18:56:00 +00:00
additional error logging and debugging.
This commit is contained in:
33
src/events/clientEvents/handler.js
Normal file
33
src/events/clientEvents/handler.js
Normal file
@ -0,0 +1,33 @@
|
||||
module.exports = function (client) {
|
||||
const Discord = require('discord.js');
|
||||
client.on('ready', () => {
|
||||
require(`./ready.js`).execute(client, Discord);
|
||||
}).on('message', (msg) => {
|
||||
require(`./msg.js`).execute(client, msg, Discord);
|
||||
}).on('guildCreate', (guild) => {
|
||||
require(`./guildCreate.js`).execute(client, guild);
|
||||
}).on('voiceStateUpdate', (oldState, newState) => {
|
||||
require(`./voiceStateUpdate.js`).execute(client, oldState, newState);
|
||||
}).on('error', (error) => {
|
||||
console.log(error);
|
||||
}).on('debug', (info) => {
|
||||
if (client.config.devMode) console.log(info);
|
||||
}).on('invalidated', () => {
|
||||
console.log("Client session invalidated! Exiting the process!")
|
||||
process.exit(1);
|
||||
}).on('rateLimit', (rateLimitInfo) => {
|
||||
|
||||
}).on('shardDisconnect', (event, id) => {
|
||||
console.log(`Shard ${id} disconnected event ${event}`);
|
||||
}).on('shardError', (error, shardId) => {
|
||||
console.log(`Shard ${shardId} error ${error}`);
|
||||
}).on('shardReady', (id, unavailableGuilds) => {
|
||||
console.log(`Shard ${id} ready. Unavailable guilds: ${unavailableGuilds || 0}`);
|
||||
}).on('shardReconnecting', (id) => {
|
||||
console.log(`shard ${id} reconnecting.`);
|
||||
}).on('shardResume', (id, replayedEvents) => {
|
||||
console.log(`shard ${id} resume events ${replayedEvents}`);
|
||||
}).on("warn", (info) => {
|
||||
console.log(`Warn! info: ${info}`);
|
||||
});
|
||||
}
|
21
src/events/connectionEvents/handler.js
Normal file
21
src/events/connectionEvents/handler.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = function (client, connection) {
|
||||
connection.on("authenticated", () => {
|
||||
if (client.config.devMode) console.log("Voice connection initiated.");
|
||||
}).on("debug", (message) => {
|
||||
if (client.config.devMode) console.log(message);
|
||||
}).on("disconnect", () => {
|
||||
if (client.config.devMode) console.log("Voice connection disconnected.");
|
||||
}).on("error", (error) => {
|
||||
console.log(error);
|
||||
}).on("failed", (error) => {
|
||||
if (client.config.devMode) console.log(error);
|
||||
}).on("newSession", () => {
|
||||
if (client.config.devMode) console.log("New voice session id received!");
|
||||
}).on("ready", () => {
|
||||
if (client.config.devMode) console.log("Voice connection ready.");
|
||||
}).on("reconnecting", () => {
|
||||
if (client.config.devMode) console.log("Voice connection reconnecting.");
|
||||
}).on("warn", (warning) => {
|
||||
console.log(`Voice connection warning: ${warning}`);
|
||||
})
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
module.exports = async function (client, error, guild) {
|
||||
const queue = client.queue.get(guild.id);
|
||||
console.error(error);
|
||||
console.log(error);
|
||||
/*if (error = "Error: input stream: This video contains content from WMG, who has blocked it on copyright grounds.") {
|
||||
queue.endReason = "skip";
|
||||
queue.connection.dispatcher.end();
|
||||
return queue.textChannel.send(client.messages.songBlockedWMG);
|
||||
}*/
|
||||
client.users.cache.get(client.config.devId).send(client.messages.dispatcherError + error);
|
||||
queue.voiceChannel.leave();
|
||||
client.queue.delete(guild.id);
|
||||
return queue.textChannel.send(client.messages.errorDispatcher + `\`${error}\``);
|
||||
|
@ -1,22 +1,24 @@
|
||||
module.exports = async function (client, reason, guild) {
|
||||
const queue = client.queue.get(guild.id);
|
||||
queue.playing = false;
|
||||
if (reason === "seek") {
|
||||
return (queue.playing = true);
|
||||
}
|
||||
|
||||
if (!queue.songLooping) {
|
||||
if (queue.looping) {
|
||||
queue.songs.push(queue.songs[0]);
|
||||
module.exports = {
|
||||
async execute(client, guild) {
|
||||
const queue = client.queue.get(guild.id);
|
||||
queue.playing = false;
|
||||
if (queue.endReason === "seek") {
|
||||
return (queue.playing = true);
|
||||
}
|
||||
|
||||
queue.time = 0;
|
||||
queue.votes = 0;
|
||||
queue.voters = [];
|
||||
if (reason !== "replay") {
|
||||
if (reason === "previous") queue.songs.unshift(queue.prevSongs.pop())
|
||||
if (reason !== "previous") queue.prevSongs.push(queue.songs.shift());
|
||||
if (!queue.songLooping) {
|
||||
if (queue.looping) {
|
||||
queue.songs.push(queue.songs[0]);
|
||||
}
|
||||
|
||||
queue.time = 0;
|
||||
queue.votes = 0;
|
||||
queue.voters = [];
|
||||
if (queue.endReason !== "replay") {
|
||||
if (queue.endReason === "previous") queue.songs.unshift(queue.prevSongs.pop())
|
||||
if (queue.endReason !== "previous") queue.prevSongs.push(queue.songs.shift());
|
||||
}
|
||||
}
|
||||
}
|
||||
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||
client.funcs.play(guild, queue.songs[0], client, 0, true);
|
||||
},
|
||||
};
|
16
src/events/dispatcherEvents/handler.js
Normal file
16
src/events/dispatcherEvents/handler.js
Normal file
@ -0,0 +1,16 @@
|
||||
module.exports = function (client, dispatcher, queue, guild) {
|
||||
dispatcher.on("finish", () => {
|
||||
if (client.config.devMode) console.log("Dispatcher finish.");
|
||||
require("./finish").execute(client, guild);
|
||||
})
|
||||
.on("start", () => {
|
||||
if (client.config.devMode) console.log("Dispatcher start.");
|
||||
queue.endReason = null;
|
||||
dispatcher.player.streamingData.pausedTime = 0;
|
||||
})
|
||||
.on("error", (error) => {
|
||||
require("./error").execute(client, error, guild);
|
||||
}).on("debug", (info) => {
|
||||
if (client.config.devMode) console.log(info);
|
||||
})
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
module.exports = function (client) {
|
||||
const Discord = require('discord.js');
|
||||
const events = './clientEvents/';
|
||||
client.on('ready', () => {
|
||||
require(`${events}ready.js`).execute(client, Discord);
|
||||
});
|
||||
client.on('message', (msg) => {
|
||||
require(`${events}msg.js`).execute(client, msg, Discord);
|
||||
});
|
||||
client.on('guildCreate', (guild) => {
|
||||
require(`${events}guildCreate.js`).execute(client, guild);
|
||||
});
|
||||
client.on('voiceStateUpdate', (oldState, newState) => {
|
||||
require(`${events}voiceStateUpdate.js`).execute(client, oldState, newState);
|
||||
});
|
||||
client.on('error', (error) => {
|
||||
client.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${client.shard}`);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user