Add the ability to delete timers
This commit is contained in:
parent
7aa1f43f29
commit
5317d59e9a
2 changed files with 15 additions and 1 deletions
11
util/timer/deleteTimer.js
Normal file
11
util/timer/deleteTimer.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const fs = require('fs');
|
||||
|
||||
module.exports = function (client, authorID, timerID) {
|
||||
|
||||
let timerToDelete = client.timers.find(timer => timer.ID === parseInt(timerID) && timer.user === authorID);
|
||||
if (timerToDelete === undefined)
|
||||
return "Timer not found";
|
||||
client.timers.splice(client.timers.indexOf(timerToDelete), 1);
|
||||
fs.writeFileSync('data/timers.json', JSON.stringify(client.timers, null, 4))
|
||||
return `Timer with ID:${timerID} deleted.`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue