From 4e416742729403049a0802f681a0230fe1855f04 Mon Sep 17 00:00:00 2001 From: danbulant Date: Thu, 3 Sep 2020 16:43:28 +0200 Subject: [PATCH] Add hint command --- index.js | 4 +++- src/index.js | 11 ++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index c5ab635..2bbd68a 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,9 @@ client.on("messageReactionAdd", async (react, user) => { var hint = false; if(challenge.get("hint")) { - var msg = await react.message.channel.messages.fetch(challenge.get("hint")); + var hint = challenge.get("hint").split("|"); + let ch = await client.channels.fetch(hint[0]); + let msg = await ch.messages.fetch(hint[1]); if(msg.createdTimestamp < react.message.createdTimestamp) { points -= 0.5; hint = true; diff --git a/src/index.js b/src/index.js index 6048461..3e36c8b 100644 --- a/src/index.js +++ b/src/index.js @@ -20,6 +20,10 @@ app challenge.set("type", 0); msg.reply("Done."); return false; + } else if(msg.author.id === "694395936809418816" && msg.content === "!hint") { + challenge.set("hint", msg.channel.id + "|" + msg.id); + msg.reply("Done."); + return false; } else if(msg.author.id === "694395936809418816" && msg.content.startsWith("!start")) { var num = msg.content.split(" ")[1][0]; if(isNaN(parseInt(num))) { @@ -37,13 +41,6 @@ app msg.cguild = await msg.client.guilds.fetch("745985920116850781"); msg.cmember = await msg.cguild.members.fetch(msg.author.id); }) - .use(msg => { - if(challenge.get("hint")) return; - if(msg.author.id === "694395936809418816") { - challenge.set("hint", msg.id); - return false; - } - }) .use(msg => { if(!/^\[[0-9.]+\]/.test(msg.cmember.displayName)) { msg.author.send("You must register first");