Added Debug to assist with yt latency troubleshooting

This commit is contained in:
Robert 2023-08-30 19:10:57 -07:00
parent 55500fc439
commit 988707ed9c
2 changed files with 50 additions and 28 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
.env
config.json
.data/*

40
bot.js
View File

@ -12,10 +12,13 @@ const client = new Client( { intents: [GatewayIntentBits.Guilds, GatewayIntentBi
// Define Sigtrap Callback for clean shutdowns
function signalExit(signal) {
console.log(`\tCaught ${signal}`);
// Kills voice connections, and logs the client out
client.destroy();
// Exit with return code 0
process.exit(0);
// Signal via discord that we are closing
client.channels.fetch("860393205401255936")
.then(papi => papi.send('bye bye papi') )
// then disconnect
.then( client.destroy()
// and when that is done finally exit
.then( process.exit(0) ) );
}
// Subscribe to a few signal events
process.on('SIGINT', signalExit); // For Ctrl-C when running in a TTY
@ -24,8 +27,13 @@ process.on('SIGTERM', signalExit); // for systemd's stoppping of services
// Define Discord Callbacks
client.on( Events.ClientReady, c => {
console.log(`Logged in Successfully as ${c.user.tag}`);
// Signal via discord that we are alive
client.channels.fetch("860393205401255936")
.then( papi => papi.send('hello papi') );
});
client.on( Events.MessageCreate, async message => {
// Variables that may be useful
var d = new Date(); // Today's date and timestamp
// *** FIlter Section ***
// In the event of a DM...
if (message.guild == null) {
@ -60,8 +68,6 @@ client.on( Events.MessageCreate, async message => {
}
// *** Process Section ***
// Variables that may be useful
const d = new Date(); // Today's date and timestamp
// Check for the shutup message
if (message.content === "~") {
console.log(`!stop issued by ${message.author.tag}`);
@ -142,7 +148,9 @@ client.on( Events.MessageCreate, async message => {
}
console.log(`yturl: ${yturl}`);
// Create a stream reference to the provided URL
const stream = await play.stream(yturl, { seek: timestamp });
const stream = await play.stream(yturl, {
seek: timestamp
});
// Now that we have a stream reference we can join the channel and play
const connection = Voice.joinVoiceChannel({
channelId: message.member.voice.channel.id,
@ -162,9 +170,10 @@ client.on( Events.MessageCreate, async message => {
}
if (message.content === "!help" ) {
console.log(`!help issued by ${message.author.tag} ${message.author.id}`);
var response = 'ZeSkypeBot v7.2.0 \'Table Salt\'\n';
response += 'Original by moosecrap#5953 for Skype, Remade by Weegee#6402 for Discord\n';
var response = 'ZeSkypeBot v7.2.1 \'Table Salt\'\n';
response += 'Original by @moosecrap for Skype, Remade by @fredstonemason for Discord\n';
response += 'Changelog:\n';
response += 'v7.2.1 Added !echo to try and deduce why theres lag in commands\n';
response += 'v7.2.0 Attempts to fix seemingly random searches, now should support age-restricted videos\n';
response += 'v7.1.0 Added support for searching in !play\n'
response += 'v7.0.0 Update to Discord.js 14\n';
@ -194,6 +203,19 @@ client.on( Events.MessageCreate, async message => {
message.channel.send(response);
return;
}
if (message.content === "!echo" ) {
var response = 'Debug Timers:\n```';
response += `Discord Timestamp: ${message.createdAt.toISOString()}\n`;
response += `Local event start: ${d.toISOString()}\n`;
d = new Date();
response += `Local event now: ${d.toISOString()}\n`;
response += `Online Since: ${client.readyAt.toISOString()}\n`;
response += '```';
message.channel.send(response);
return;
}
});
// Now our client is prepared, we can log in.
client.login(token);