From a40017f53e515207f58df7c3bfffba8e194db1c8 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 23 Sep 2023 17:13:40 -0700 Subject: [PATCH] Rearranged code blocks to support future logic --- bot.js | 129 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 65 insertions(+), 64 deletions(-) mode change 100644 => 100755 bot.js diff --git a/bot.js b/bot.js old mode 100644 new mode 100755 index f97747f..4d8dd6b --- a/bot.js +++ b/bot.js @@ -31,7 +31,11 @@ client.on( Events.ClientReady, c => { client.on( Events.MessageCreate, async message => { // Variables that may be useful var d = new Date(); // Today's date and timestamp + // *** FIlter Section *** + + // Prevent any triggering if the message is our own + if( message.author.id === "860345552742907935" ) return; // In the event of a DM... if (message.guild == null) { switch (message.author.id) { @@ -65,6 +69,7 @@ client.on( Events.MessageCreate, async message => { } // *** Process Section *** + // Check for the shutup message if (message.content === "~") { console.log(`!stop issued by ${message.author.tag}`); @@ -76,56 +81,6 @@ client.on( Events.MessageCreate, async message => { } return; } - // Try to find a sound file that matches the message - if (!message.content.match(/[ \/;]/)) { - // we had to add '/' because moose tried to 'play' ../../../../etc/shadow - // Construct the expected sound path - const soundPath = ''; - if( d.getMonth() == 3 && d.getDate() == 1 ) { - // TODO: april fools! - // Scan the directory as an array - // select randomly from the array - // play that sound instead - } - else soundPath = `./Sounds/${message.content}.ogg`; - if (message.author.id === "172538370440953867") { - switch(message.content) { - case "butthash": - message.react('859687015247511561'); - default: - } - } - if (message.author.id === "144317130026778624") { - switch(message.content) { - case "daytona": - case "e": - if ([0,5,6].includes(d.getDay()) && Math.random() < 0.8) return; - default: - } - } - // Test if there is a file at the expected path - if (message.member.voice.channel && existsSync(soundPath)) { - console.log(`Sound '${message.content}' issued by ${message.author.tag} ${message.author.id}`); - // Join the Voice Channel of the author - const connection = Voice.joinVoiceChannel({ - channelId: message.member.voice.channelId, - guildId: message.guild.id, - adapterCreator: message.guild.voiceAdapterCreator, - }); - // Create an audio player for the desired sound - const resource = Voice.createAudioResource(createReadStream(soundPath)); - const player = Voice.createAudioPlayer(); - // Play the resource through the player to the connection (i hate discord v16) - player.play(resource); - // Connect the player to the voice connection (internal screaming intensifies) - connection.subscribe(player); - return; - } - } - else { - // Somebody tried to escape characters or semicolon - message.channel.send('NO FUCK YOU'); - } // Check for youtube play command if (message.content.startsWith('!play') && message.member.voice.channel) { console.log(`!play issued by ${message.author.tag} ${message.author.id}`); @@ -178,7 +133,7 @@ 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.2 \'Angelica root\'\n'; + var response = 'ZeSkypeBot v7.2.3 \'Angelica root\'\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'; @@ -201,7 +156,17 @@ 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; + } // Generic message responses if (message.content.match(/https:\/\/ootbingo\.github\.io/)) { var response = 'ooh its bingo time, i call '; @@ -211,19 +176,55 @@ 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; + // Try to find a sound file that matches the message + if (!message.content.match(/[ \/;]/)) { + // we had to add '/' because moose tried to 'play' ../../../../etc/shadow + // Construct the expected sound path + const soundPath = ''; + if( d.getMonth() == 3 && d.getDate() == 1 ) { + // TODO: april fools! + // Scan the directory as an array + // select randomly from the array + // play that sound instead + } + else soundPath = `./Sounds/${message.content}.ogg`; + if (message.author.id === "172538370440953867") { + switch(message.content) { + case "butthash": + message.react('859687015247511561'); + default: + } + } + if (message.author.id === "144317130026778624") { + switch(message.content) { + case "daytona": + case "e": + if ([0,5,6].includes(d.getDay()) && Math.random() < 0.8) return; + default: + } + } + // Test if there is a file at the expected path + if (message.member.voice.channel && existsSync(soundPath)) { + console.log(`Sound '${message.content}' issued by ${message.author.tag} ${message.author.id}`); + // Join the Voice Channel of the author + const connection = Voice.joinVoiceChannel({ + channelId: message.member.voice.channelId, + guildId: message.guild.id, + adapterCreator: message.guild.voiceAdapterCreator, + }); + // Create an audio player for the desired sound + const resource = Voice.createAudioResource(createReadStream(soundPath)); + const player = Voice.createAudioPlayer(); + // Play the resource through the player to the connection (i hate discord v16) + player.play(resource); + // Connect the player to the voice connection (internal screaming intensifies) + connection.subscribe(player); + return; + } + } else { + //message.channel.send('NO FUCK YOU'); + console.log(`user ${message.author.tag} used some bad characters: ${message.content}`); } - }); // Now our client is prepared, we can log in. client.login(token);