From 81bd2fe68866553855cf79e0c2f2616f52bff543 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Wed, 27 Sep 2023 19:16:03 +0800 Subject: [PATCH 1/4] Create pollping.js --- bot/discord/commands/staff/pollping.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 bot/discord/commands/staff/pollping.js diff --git a/bot/discord/commands/staff/pollping.js b/bot/discord/commands/staff/pollping.js new file mode 100644 index 00000000..a978786a --- /dev/null +++ b/bot/discord/commands/staff/pollping.js @@ -0,0 +1,9 @@ +const Discord = require("discord.js"); +exports.run = (client, message, args) => { + // Check if user has the dev role + if (!message.member.roles.cache.find((r) => r.id === "898041747597295667")) return; + // Check the message is in the #dev-questions channel + if(message.channel.id !== "1083142107977486389") return message.reply("This command can only be used in <#1083142107977486389>!"); + + message.reply("<@&898041781927682090>"); +}; From d1c958eef2fb0c822c37856a8032dec516747ed6 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Wed, 27 Sep 2023 19:23:34 +0800 Subject: [PATCH 2/4] feat: cooldown --- bot/discord/commands/staff/pollping.js | 3 +++ index.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/bot/discord/commands/staff/pollping.js b/bot/discord/commands/staff/pollping.js index a978786a..fe3f623d 100644 --- a/bot/discord/commands/staff/pollping.js +++ b/bot/discord/commands/staff/pollping.js @@ -4,6 +4,9 @@ exports.run = (client, message, args) => { if (!message.member.roles.cache.find((r) => r.id === "898041747597295667")) return; // Check the message is in the #dev-questions channel if(message.channel.id !== "1083142107977486389") return message.reply("This command can only be used in <#1083142107977486389>!"); + // Command can only be used every 30 minutes + if(pollPingLastUsed + 1800000 > Date.now()) return message.reply(`This command can only be used every 30 minutes! Cooldown expires `) message.reply("<@&898041781927682090>"); + global.pollPingLastUsed = Date.now(); }; diff --git a/index.js b/index.js index f5a1d3ee..2e164006 100644 --- a/index.js +++ b/index.js @@ -57,6 +57,8 @@ global.client = new Discord.Client({ }); global.bot = client; +global.pollPingLastUsed = 0; + require("./bot/discord/commands/mute").init(client); //Event handler From 690d74b61bea136c48b6187f6350c87f568d514c Mon Sep 17 00:00:00 2001 From: William Harrison Date: Thu, 28 Sep 2023 07:33:03 +0800 Subject: [PATCH 3/4] Update pollping.js --- bot/discord/commands/staff/pollping.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/discord/commands/staff/pollping.js b/bot/discord/commands/staff/pollping.js index fe3f623d..f1b7fadb 100644 --- a/bot/discord/commands/staff/pollping.js +++ b/bot/discord/commands/staff/pollping.js @@ -1,4 +1,3 @@ -const Discord = require("discord.js"); exports.run = (client, message, args) => { // Check if user has the dev role if (!message.member.roles.cache.find((r) => r.id === "898041747597295667")) return; From a5ea0fb75599c19e618d164cba784bcb2c2d7db2 Mon Sep 17 00:00:00 2001 From: William Harrison Date: Thu, 28 Sep 2023 07:34:09 +0800 Subject: [PATCH 4/4] Update pollping.js --- bot/discord/commands/staff/pollping.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot/discord/commands/staff/pollping.js b/bot/discord/commands/staff/pollping.js index f1b7fadb..cda5845e 100644 --- a/bot/discord/commands/staff/pollping.js +++ b/bot/discord/commands/staff/pollping.js @@ -4,7 +4,12 @@ exports.run = (client, message, args) => { // Check the message is in the #dev-questions channel if(message.channel.id !== "1083142107977486389") return message.reply("This command can only be used in <#1083142107977486389>!"); // Command can only be used every 30 minutes - if(pollPingLastUsed + 1800000 > Date.now()) return message.reply(`This command can only be used every 30 minutes! Cooldown expires `) + if(pollPingLastUsed + 1800000 > Date.now()) { + message.reply( + `This command can only be used every 30 minutes! Cooldown expires ` + ) + return; + } message.reply("<@&898041781927682090>"); global.pollPingLastUsed = Date.now();