From 74e482ed90663f3a0a2098999a4b52d84d62de19 Mon Sep 17 00:00:00 2001 From: ethanf Date: Tue, 23 Jan 2024 04:29:14 -0600 Subject: [PATCH] fix: limit rank input and change to method --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d98a217..c71f128 100644 --- a/index.js +++ b/index.js @@ -298,7 +298,7 @@ client.on("messageCreate", async (message) => { return; } - const args = message.content.toLowerCase.split(" "); + const args = message.content.toLowerCase().split(" "); if (args[0] === "setrank") { const pickupGuild = client.guilds.cache.get(GUILD_ID); @@ -312,6 +312,12 @@ client.on("messageCreate", async (message) => { const playerId = player.id; const rank = parseInt(args[2]); + if (isNaN(rank) || rank < 0 || rank > 5) { + await interaction.reply( + `invalid rank ${args[2]}. must be an integer between 0 and 5` + ); + return; + } // create rankings.json if it doesn't exist const rankingsPath = path.join(__dirname, "rankings.json");