diff --git a/commands/bonus.js b/commands/bonus.js index 982b087..6ad439a 100644 --- a/commands/bonus.js +++ b/commands/bonus.js @@ -3,6 +3,7 @@ exports.description = ":star: Sums and calculates bonus for player stat numbers."; exports.usage = "< [inf optional extra numbers]"; exports.example = "< { let is1nan = false; if (!args[0]) diff --git a/commands/cat.js b/commands/cat.js index 6e27482..f8153cb 100644 --- a/commands/cat.js +++ b/commands/cat.js @@ -2,6 +2,7 @@ exports.name = "cat"; exports.description = ":cat: Calculates boost for cat."; exports.usage = "< "; exports.example = "< { if (!args[0] || !args[1]) return message.channel.send("Not enough arguments, consult < { if (!args[0] || !args[1]) return message.channel.send("Not enough arguments, consult < { let embed = new EmbedBuilder(); embed.setTitle("Commands Helper"); @@ -13,6 +14,7 @@ exports.run = (client, message, args) => { return message.channel.send( "Command not found, try `< { ); } else { client.commands.forEach((cmd) => { + if (cmd.hidden && message.author.id != client.ownerID) return; embed.addFields({ name: cmd.name, value: cmd.description, diff --git a/commands/ms.js b/commands/ms.js index 3e290e2..20e0a09 100644 --- a/commands/ms.js +++ b/commands/ms.js @@ -3,6 +3,7 @@ exports.description = ":tada: Calculate moon staff damage taking in to account projectile speed."; exports.usage = "< [projectile speed]"; exports.example = "< { if (!args[0] || !args[1]) return message.channel.send("Not enough arguments, consult < { + const url = "https://drive.overflow.fun/public/react.json"; + client.usersToReactTo = []; + const res = await fetch(url); + const data = await res.json(); + + client.usersToReactTo = data.map((entry) => { + const [userId, emoji] = entry.split(":"); + return { userId, emoji }; + }); + + message.channel.send( + "Refetched react data. " + JSON.stringify(client.usersToReactTo) + ); +}; diff --git a/commands/res.js b/commands/res.js index d5ac130..105aa0a 100644 --- a/commands/res.js +++ b/commands/res.js @@ -4,6 +4,7 @@ exports.description = exports.usage = "< [res] | [second hero stat]"; exports.example = "< { for (let i = 0; i < args.length; i++) { if (args[i] == "|") continue; diff --git a/index.js b/index.js index 3d34a25..0a156f4 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ const client = new Client({ ], }); client.commands = new Collection(); +client.ownerID = 263247134147608578; fs.readdir("./commands/", (err, files) => { if (err) return console.error(err); @@ -32,12 +33,12 @@ fs.readdir("./commands/", (err, files) => { }); const url = "https://drive.overflow.fun/public/react.json"; -let userstoreact = []; +client.usersToReactTo = []; client.once(Events.ClientReady, async (readyClient) => { const res = await fetch(url); const data = await res.json(); - userstoreact = data.map((entry) => { + client.usersToReactTo = data.map((entry) => { const [userId, emoji] = entry.split(":"); return { userId, emoji }; }); @@ -46,12 +47,14 @@ client.once(Events.ClientReady, async (readyClient) => { client.on(Events.MessageCreate, async (message) => { if (message.author.bot) return; - console.log(message.mentions.users); - userstoreact.forEach(async (usr) => { - if (message.mentions.users.find((u) => u.id == usr.userId)) { + client.usersToReactTo.forEach(async (item) => { + if ( + message.mentions.users.find((u) => u.id == item.userId) && + !message.reference + ) { try { - await message.react(usr.emoji); + await message.react(item.emoji); } catch (err) { console.error("Failed to react to message:", err); } @@ -67,7 +70,7 @@ client.on(Events.MessageCreate, async (message) => { if (!cmd) return; - cmd.run(client, message, args); + await cmd.run(client, message, args); }); // Log in to Discord with your client's token