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");