From 354d4cd098ff8eeb45f67328eb8e4191ab9d6960 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 9 May 2023 09:44:24 +0200 Subject: [PATCH] Add timer show command This command shows information about the timer with the ID you have as an argument. --- commands/misc/timer.js | 3 +++ util/timer/showTimer.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 util/timer/showTimer.js diff --git a/commands/misc/timer.js b/commands/misc/timer.js index e59d522..0c5799a 100644 --- a/commands/misc/timer.js +++ b/commands/misc/timer.js @@ -2,6 +2,7 @@ const createTimer = require('../../util/timer/createTimer'); const deleteTimer = require('../../util/timer/deleteTimer'); const parseTime = require('../../util/timer/parseTime'); const fs = require('fs'); +const showTimer = require('../../util/timer/showTimer'); module.exports = { name: "timer", description: "Set a timer for a time in minutes.", @@ -25,6 +26,8 @@ module.exports = { let timerID = args[1]; sendText = deleteTimer(client, message.author.id, timerID); break; + case "show": + sendText = showTimer(client, message.author.id, args[1]); default: sendText = "not sure what you mean" if(!isNaN(parseTime(args[0], Math.floor(new Date() / 1000)))) diff --git a/util/timer/showTimer.js b/util/timer/showTimer.js new file mode 100644 index 0000000..0c7c408 --- /dev/null +++ b/util/timer/showTimer.js @@ -0,0 +1,12 @@ +const fs = require('fs'); + +module.exports = function (client, authorID, timerID) { + let timerToShow = client.timers.find(timer => timer.ID === parseInt(timerID)); + if (timerToShow === undefined) + return "Timer not found"; + if (timerToShow.user !== authorID){ + return "You can only show info about your own timers."; + } + return `${timerToShow.ID} will remind you () with the message "${timerToShow.customMessage}"`; + +}