From ae2eb50b9c9bc4dda2b4571197703b439d3403a4 Mon Sep 17 00:00:00 2001 From: ayeuhugyu Date: Thu, 21 Sep 2023 18:16:05 -0700 Subject: [PATCH] added p/eulogy and the capability for command arguments --- README.md | 4 ++++ src/commands/test.js | 9 +++++++-- src/events/messageCreate.js | 26 ++++++++++++++++---------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2c00f89..a58300a 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.9 - added p/eulogy and the capability for command arguments + +--- + 1.8 - reorganized files some more, moved all events from index.js to seperate scripts in events folder, 1.8.1 - cleaned up p/vileimagery a bit 1.8.2 - fixed guildMemberAdd event error diff --git a/src/commands/test.js b/src/commands/test.js index 1b89f18..06272b8 100644 --- a/src/commands/test.js +++ b/src/commands/test.js @@ -4,7 +4,12 @@ module.exports = { name: "test", description: "test command", execute(message, args) { - log("failed.log", message, __filename, "test command"); - message.reply("log test completed, don't contact me again"); + let text = + "command arguments test \nthis list should include all arguments you included in the command \n"; + for (let i = 0; i < args.length; i++) { + text += args[i] + "\n"; + } + + message.reply(text); }, }; diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index d02ad59..7529d36 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -15,6 +15,16 @@ for (const file of commandFiles) { })(); } +function parseargs(string) { + const args = string.split(" "); + for (let i = 0; i < args.length; i++) { + if (args[i] === "") { + args.splice(i, 1); + } + } + return args; +} + const prefix = process.env.PREFIX; module.exports.execute = function (message, client) { @@ -27,17 +37,13 @@ module.exports.execute = function (message, client) { ); } if (!message.content.startsWith(prefix)) return; - const args = message.content.slice(prefix.length).split(/ +/); - const command = args.shift().toLowerCase(); - /*if (message.channelId !== "1148814162273763418") { - let text = "commands only work in <#1148814162273763418>"; - if (!client.commands.has(command)) { - text += ", also thats not a command lmao"; - } - message.reply(text); - return; - }*/ + const command = message.content + .slice(prefix.length) + .split(/ +/) + .shift() + .toLowerCase(); + const args = parseargs(message.content.slice(prefix.length + command.length)); if (!commands.has(command)) { message.reply("idiot thats not a command");