diff --git a/README.md b/README.md index d745121..d4f6440 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ clean up p/vileimagery, its horrendous **_Note:_** _versions before this were not uploaded to the repo, this is not the first version._ + 1.13 - new blacklist feature (for my own amusement,) random sound feature, tons of bug fixes + +--- + 1.12 - changed most discord actions to be handled by 1 script. this should cut down on errors and allow you to actually use the bot in other servers (i think) 1.12.1 - direct messages are now redirected to main channel 1.12.2 - fixed being able to crash bot by creating messages over 2k characters diff --git a/src/commands/addsound.js b/src/commands/addsound.js index 6946707..055464b 100644 --- a/src/commands/addsound.js +++ b/src/commands/addsound.js @@ -28,7 +28,8 @@ export default { filename.endsWith(".mp3") || filename.endsWith(".wav") || filename.endsWith(".ogg") || - filename.endsWith(".webm") + filename.endsWith(".webm") || + filename.endsWith(".m4a") ) { const filenameNoExtension = filename.split(".")[0]; const files = fs.readdirSync("resources/soundboard"); @@ -95,7 +96,7 @@ export default { } else { action.reply( message, - `invalid file extention; only \`mp3\`, \`wav\`, and \`ogg\` files are supported. \`${ + `invalid file extention; only \`mp3\`, \`wav\`, \`ogg\`, \`webm\`, and \`m4a\` files are supported. \`${ filename.split(".")[1] }\` is not.` ); diff --git a/src/commands/crash.js b/src/commands/crash.js index 8daee23..9e9c7e1 100644 --- a/src/commands/crash.js +++ b/src/commands/crash.js @@ -18,7 +18,7 @@ export default { throw "crash command executed"; } else { action.reply(message, "UNAUTHORIZED"); - const path = require("path"); + return; } }, }; diff --git a/src/commands/soundboard.js b/src/commands/soundboard.js index 326f1e9..fbaf4f7 100644 --- a/src/commands/soundboard.js +++ b/src/commands/soundboard.js @@ -34,6 +34,8 @@ export default { wav: proposedfilename + ".wav", spacedwebm: proposedfilename.replaceAll(" ", "_") + ".webm", webm: proposedfilename + ".webm", + spacedm4a: proposedfilename.replaceAll(" ", "_") + ".m4a", + m4a: proposedfilename + ".m4a", }; for (const value of Object.values(possibleFilenames)) { if (files.includes(value)) { @@ -63,6 +65,7 @@ export default { "unable to find your file in the soundboard folder put `ls` as your args to upload a file of all names. try replacing spaces with _s. you proposed: " + proposedfilename ); + return; } if (!lsmode) { const audioResource = createAudioResource(`resources/soundboard/${file}`); @@ -90,6 +93,7 @@ export default { connection = getVoiceConnection(message.guild.id); connection.subscribe(audioPlayer); audioPlayer.play(audioResource); + action.reply(message, `playing \`${file}\``); } else { action.sendMessage(message.channelId, { files: [ diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 7b3993e..8704acb 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -30,13 +30,16 @@ function parseargs(string) { const prefix = process.env.PREFIX; export default function (message, client) { + const blacklistnosplit = fs.readFileSync("data/blacklisted.log", "utf8"); + const blacklist = blacklistnosplit.split("\n"); + if (message.channel.type === 1) { log( "directmessages.log", message, import.meta.url, `direct message from ${message.author.username} (${message.author}) with: -"${message.content}"` +\`"${message.content}"\`` ); const channel = client.channels.cache.get("1148814162273763418"); channel.send( @@ -44,6 +47,10 @@ export default function (message, client) { ); } if (!message.content.startsWith(prefix)) return; + if (blacklist.includes(message.author.id)) { + message.reply("blacklisted smh"); + return; + } const command = message.content .slice(prefix.length) @@ -54,24 +61,16 @@ export default function (message, client) { if (!commands.has(command)) { message.reply("idiot thats not a command"); - log( - "failed.log", - message, - import.meta.url, - `attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"` - ); - } - - if (commands.get(command)) { - log( - "commands.log", - message, - import.meta.url, - `use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`, - true - ); - (async () => { - commands.get(command).execute(message, args, client); - })(); + return; } + log( + "commands.log", + message, + import.meta.url, + `use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`, + true + ); + (async () => { + commands.get(command).execute(message, args, client); + })(); } diff --git a/src/util/discordAction.js b/src/util/discordAction.js index e9c1c22..5b23d89 100644 --- a/src/util/discordAction.js +++ b/src/util/discordAction.js @@ -4,17 +4,24 @@ import * as index from "../index.js"; const client = index.client; export async function sendMainMessage(message) { - const channel = client.channels.cache.get("1148814162273763418"); - const msg = await channel.send(message.slice(0, 2000)); - return msg; + try { + const channel = client.channels.cache.get("1148814162273763418"); + const msg = await channel.send(message); + return msg; + } catch (err) { + sendError(toString(err).slice(err.length - 1750, err.length)); + console.log(err); + return undefined; + } } export function sendError(message) { const channel = client.channels.cache.get("1148814162273763418"); let msg; try { - msg = channel.send(`**error:** ${message.slice(0, 1750)}`); + msg = channel.send(`**error:** ${message}`); } catch (err) { + sendError(err.rawError.message); console.log(err); return undefined; } @@ -27,7 +34,13 @@ export function messageDelete(message) { return undefined; } if (message.deletable) { - message.delete(); + try { + message.delete(); + } catch (err) { + sendError(err.rawError.message); + console.log(err); + return undefined; + } } else { sendError( `unable to delete message: ${message.url}. most likely caused by invalid permissions` @@ -39,33 +52,29 @@ export function messageDelete(message) { } } -export function sendMessage(channelId, message) { - (async () => { - const channel = client.channels.cache.get(channelId); - let msg; - if (channel) { - try { - msg = await channel.send(message.slice(0, 2000)); - return msg; - } catch (err) { - sendError(err.slice(err.length - 1750, err.length)); - console.log(err); - return undefined; - } - } else { - sendError(`unable to find channel: <#${channelId}>`); +export async function sendMessage(channelId, message) { + const channel = client.channels.cache.get(channelId); + let msg; + if (channel) { + try { + msg = await channel.send(message); + return msg; + } catch (err) { + sendError(err.rawError.message); + console.log(err); + return undefined; } - })(); + } else { + sendError(`unable to find channel: <#${channelId}>`); + } } -export function reply(triggerMessage, message) { +export async function reply(triggerMessage, message) { try { - (async () => { - let msg = await triggerMessage.reply(message.slice(0, 2000)); - return msg; - })(); + let msg = await triggerMessage.reply(message); + return msg; } catch (err) { - sendError(err.slice(err.length - 1750, err.length)); + sendError(err.rawError.message); console.log(err); return undefined; }