From ba443111c8058bc7cda116bba2259ab25c4313f4 Mon Sep 17 00:00:00 2001 From: ayeuhugyu Date: Sun, 24 Sep 2023 10:53:21 -0700 Subject: [PATCH] added command argument usage for sendlog (mobile support) --- README.md | 1 + src/commands/addguildmember.js | 1 + src/commands/commands.js | 5 ++-- src/commands/crash.js | 1 + src/commands/createreactionrole.js | 1 + src/commands/dmuser.js | 1 + src/commands/eulogy.js | 1 + src/commands/guildmembers.js | 1 + src/commands/links.js | 1 + src/commands/mymovie.js | 15 +++++++----- src/commands/openpepper.js | 1 + src/commands/pepper.js | 1 + src/commands/say.js | 1 + src/commands/sendlog.js | 39 +++++++++++++++++++++--------- src/commands/test.js | 1 + src/commands/vileimagery.js | 1 + src/events/messageCreate.js | 2 +- 17 files changed, 53 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index a58300a..268384a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ 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.9.1 - added command argument usage for sendlog (mobile support) --- diff --git a/src/commands/addguildmember.js b/src/commands/addguildmember.js index ca1cfbc..cfa0636 100644 --- a/src/commands/addguildmember.js +++ b/src/commands/addguildmember.js @@ -14,6 +14,7 @@ module.exports = { name: "addguildmember", description: "manually adds a guild member to the members list, whitelist required", + arguments: "none", execute(message, args) { if (whitelist.includes(message.author.id)) { if (message.author.bot) return; diff --git a/src/commands/commands.js b/src/commands/commands.js index e2d7ff2..7320a11 100644 --- a/src/commands/commands.js +++ b/src/commands/commands.js @@ -2,7 +2,8 @@ const { EmbedBuilder } = require("discord.js"); const fs = require("fs"); module.exports = { name: "commands", - description: "commands list", + description: "displays commands list", + arguments: "none", execute(message, args) { let text = ""; @@ -11,7 +12,7 @@ module.exports = { .filter((file) => file.endsWith(".js")); for (const file of commandFiles) { const command = require(`./${file}`); - text += `p/${command.name} - ${command.description}\n`; + text += `p/${command.name} - ${command.description} - command arguments: ${command.arguments}\n \n`; } const embed = new EmbedBuilder(); diff --git a/src/commands/crash.js b/src/commands/crash.js index ef8264c..5875789 100644 --- a/src/commands/crash.js +++ b/src/commands/crash.js @@ -4,6 +4,7 @@ const fs = require("fs"); module.exports = { name: "crash", description: "crashes the bot (throws an error), requires whitelist", + arguments: "none", execute(message, args) { if (whitelist.includes(message.author.id)) { message.reply("crashing bot..."); diff --git a/src/commands/createreactionrole.js b/src/commands/createreactionrole.js index 2ef73bd..f7d1713 100644 --- a/src/commands/createreactionrole.js +++ b/src/commands/createreactionrole.js @@ -60,6 +60,7 @@ const whitelist = ["440163494529073152", "436321340304392222"]; module.exports = { name: "createreactionrole", description: "creates reaction role, requires whitelist", + arguments: "emoji, user", execute(message, args) { if (whitelist.includes(message.author.id)) { let emojis = getEmojis(message); diff --git a/src/commands/dmuser.js b/src/commands/dmuser.js index 05a1ef9..ce35afb 100644 --- a/src/commands/dmuser.js +++ b/src/commands/dmuser.js @@ -11,6 +11,7 @@ function delay(time) { module.exports = { name: "dmuser", description: "forces bot to dm a user something (this will ghost ping them)", + arguments: "user, message", execute(message, args) { const user = message.mentions.users.first(); const guild = message.guild; diff --git a/src/commands/eulogy.js b/src/commands/eulogy.js index f8365e9..cbc0561 100644 --- a/src/commands/eulogy.js +++ b/src/commands/eulogy.js @@ -6,6 +6,7 @@ const prefix = process.env.PREFIX; module.exports = { name: "eulogy", description: "generates a eulogy", + arguments: "name", execute(message, args) { const msgnoprefix = message.content.slice(prefix.length + this.name.length); const name = msgnoprefix.slice(0, 2000); diff --git a/src/commands/guildmembers.js b/src/commands/guildmembers.js index e09d6c6..5480d9d 100644 --- a/src/commands/guildmembers.js +++ b/src/commands/guildmembers.js @@ -2,6 +2,7 @@ module.exports = { name: "guildmembers", description: "sends a file including all past guild members (may not be accurrate, is mostly manually updated) -- note: also includes allies", + arguments: "none", execute(message, args) { const path = `../pepperbot/data/guildmembers.log`; message.channel.send({ diff --git a/src/commands/links.js b/src/commands/links.js index 356e4a4..8271984 100644 --- a/src/commands/links.js +++ b/src/commands/links.js @@ -2,6 +2,7 @@ const { EmbedBuilder } = require("discord.js"); module.exports = { name: "links", description: 'posts "important" links', + arguments: "none", execute(message, args) { const embed = new EmbedBuilder(); embed.setTitle("very imphortance linkers"); diff --git a/src/commands/mymovie.js b/src/commands/mymovie.js index bd91208..51cc035 100644 --- a/src/commands/mymovie.js +++ b/src/commands/mymovie.js @@ -1,7 +1,10 @@ module.exports = { - name: 'mymovie', - description: 'posts my movie', - execute(message, args){ - message.reply('https://cdn.discordapp.com/attachments/755150633191080073/1149158052784775219/My_Movie.mp4') - } -} \ No newline at end of file + name: "mymovie", + description: "posts my movie", + arguments: "none", + execute(message, args) { + message.reply( + "https://cdn.discordapp.com/attachments/755150633191080073/1149158052784775219/My_Movie.mp4" + ); + }, +}; diff --git a/src/commands/openpepper.js b/src/commands/openpepper.js index f7ec80c..a633fb4 100644 --- a/src/commands/openpepper.js +++ b/src/commands/openpepper.js @@ -1,6 +1,7 @@ module.exports = { name: "openpepper", description: "posts open pepper repo", + arguments: "none", execute(message, args) { message.reply("https://git.reidlab.online/ayeuhugyu/OpenPepper"); }, diff --git a/src/commands/pepper.js b/src/commands/pepper.js index ed6ad2a..e1680c9 100644 --- a/src/commands/pepper.js +++ b/src/commands/pepper.js @@ -4,6 +4,7 @@ const fs = require("fs"); module.exports = { name: "pepper", description: "RPG (random pepper generator)", + arguments: "none", execute(message, args) { const peppers = fs.readdirSync("../pepperbot/resources/peppers"); const maxRan = peppers.length; diff --git a/src/commands/say.js b/src/commands/say.js index 785a054..8ba65d6 100644 --- a/src/commands/say.js +++ b/src/commands/say.js @@ -11,6 +11,7 @@ function delay(time) { module.exports = { name: "say", description: "forces bot to say something", + arguments: "message", execute(message, args) { if (message.author.bot) return; const msgnoprefix = message.content.slice(prefix.length + this.name.length); diff --git a/src/commands/sendlog.js b/src/commands/sendlog.js index d778a66..9f30160 100644 --- a/src/commands/sendlog.js +++ b/src/commands/sendlog.js @@ -1,15 +1,22 @@ +const { Options } = require("discord.js"); const { Collection } = require("discord.js"); const prefix = process.env.PREFIX; -const ignore = []; +const ignore = ["console.log"]; const fs = require("fs"); module.exports = { name: "sendlog", description: "sends log file (if the file is valid)", + arguments: "m, mobile", execute(message, args) { - let msgnoprefix = message.content.slice( - prefix.length + this.name.length + 1 - ); + let mobileMode = false; + if (args.includes("m") || args.includes("mobile")) { + mobileMode = true; + } + //let msgnoprefix = message.content.slice( + //prefix.length + this.name.length + 1, + //); + let msgnoprefix = args[0]; if (!msgnoprefix.endsWith(".log")) { msgnoprefix += ".log"; } @@ -23,13 +30,21 @@ module.exports = { } if (ignore.includes(msgnoprefix)) return; const path = `../pepperbot/logs/${msgnoprefix}`; - message.channel.send({ - files: [ - { - attachment: path, - name: "file.log", - }, - ], - }); + if (!mobileMode) { + message.channel.send({ + files: [ + { + attachment: path, + name: "file.log", + }, + ], + }); + } else { + const filestring = fs.readFileSync(path, "utf8"); + console.log(typeof filestring); + message.channel.send( + filestring.slice(filestring.length - 500, filestring.length) + ); + } }, }; diff --git a/src/commands/test.js b/src/commands/test.js index 06272b8..37339b4 100644 --- a/src/commands/test.js +++ b/src/commands/test.js @@ -3,6 +3,7 @@ const log = require("../util/log.js").execute; module.exports = { name: "test", description: "test command", + arguments: "all", execute(message, args) { let text = "command arguments test \nthis list should include all arguments you included in the command \n"; diff --git a/src/commands/vileimagery.js b/src/commands/vileimagery.js index bedad57..eb39a80 100644 --- a/src/commands/vileimagery.js +++ b/src/commands/vileimagery.js @@ -5,6 +5,7 @@ const prefix = process.env.PREFIX; module.exports = { name: "vileimagery", description: "Do NOT run.", + arguments: "file name", execute(message, args) { let proposedfilename = message.content.slice( prefix.length + this.name.length + 1 diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 7529d36..f15c6b0 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -60,7 +60,7 @@ module.exports.execute = function (message, client) { "commands.log", message, __filename, - `use of command: ${command} by: ${message.author.username} (${message.author})"`, + `use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`, true ); commands.get(command).execute(message, args, client);