-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67eb8c4
commit 56cbac9
Showing
12 changed files
with
319 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const Command = require("../../base/Command.js"); | ||
const moment = require("moment") | ||
const { Collection } = require("discord.js") | ||
class Chrono extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: "chrono", | ||
description: (language) => language.get("CHRONO_DESCRIPTION"), | ||
usage: (language, prefix) => language.get("CHRONO_USAGE", prefix), | ||
examples: (language, prefix) => language.get("CHRONO_EXAMPLES", prefix), | ||
dirname: __dirname, | ||
enabled: true, | ||
guildOnly: false, | ||
permLevel: "User", | ||
botPermissions: ["SEND_MESSAGES"], | ||
aliases: ["stopwatch"], | ||
nsfw: false, | ||
adminOnly: false, | ||
cooldown: 2000, | ||
}); | ||
} | ||
|
||
async run(message, args) { | ||
try { | ||
const method = args[0]; | ||
if(!method) return message.channel.send(message.language.get("CHRONO_METHODS")) | ||
if (method.toLowerCase() !== "start" && method.toLowerCase() !== "stop") return message.channel.send(message.language.get("CHRONO_METHODS")); | ||
if (method.toLowerCase() === "start"){ | ||
if (!message.bot.chronos.has(message.guild.id)){ | ||
message.bot.chronos.set(message.guild.id, new Collection()); | ||
} | ||
|
||
const start = moment(); | ||
const timestamps = message.bot.chronos.get(message.guild.id); | ||
|
||
if (timestamps.has(message.author.id)){ | ||
return message.channel.send(message.language.get("CHRONO_RUNNING")) | ||
} | ||
timestamps.set(message.author.id, start); | ||
return message.channel.send(message.language.get("CHRONO_STARTED")) | ||
} | ||
if (method.toLowerCase() === "stop"){ | ||
if (!message.bot.chronos.has(message.guild.id)){ | ||
message.bot.chronos.set(message.guild.id, new Collection()); | ||
} | ||
|
||
const stop = moment(); | ||
const timestamps = message.bot.chronos.get(message.guild.id); | ||
|
||
if (!timestamps.has(message.author.id)){ | ||
return message.channel.send(message.language.get("CHRONO_NOT_RUNNING")) | ||
} | ||
const start = timestamps.get(message.author.id) | ||
timestamps.delete(message.author.id) | ||
const duration = stop.diff(start); | ||
const result = (stop.diff(start) >= 3600000 ? moment(duration).format('H:mm:ss:SSS') : moment(duration).format('m:ss:SSS')) | ||
return message.channel.send(message.language.get("CHRONO_STOPPED", result)) | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
return message.channel.send(message.language.get("ERROR", error)); | ||
} | ||
} | ||
} | ||
|
||
module.exports = Chrono; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const Command = require("../../base/Command.js"); | ||
const ms = require("ms") | ||
|
||
class Reminder extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: "reminder", | ||
description: (language) => language.get("REMINDER_DESCRIPTION"), | ||
usage: (language, prefix) => language.get("REMINDER_USAGE", prefix), | ||
examples: (language, prefix) => language.get("REMINDER_EXAMPLES", prefix), | ||
dirname: __dirname, | ||
enabled: true, | ||
guildOnly: false, | ||
permLevel: "User", | ||
botPermissions: ["SEND_MESSAGES"], | ||
aliases: ["rappel", "remind"], | ||
nsfw: false, | ||
adminOnly: false, | ||
cooldown: 2000, | ||
}); | ||
} | ||
|
||
async run(message, args) { | ||
try { | ||
const time = args[0]; | ||
if (!time) return message.channel.send(message.language.get("REMINDER_NO_TIME")) | ||
const toRemind = args.slice(1).join(" ") | ||
if (!toRemind) return message.channel.send(message.language.get("REMINDER_NO_REMIND")) | ||
if (toRemind.lenght > 1900) return message.channel.send(message.language.get("REMINDER_TOO_LONG")) | ||
message.channel.send({ | ||
embed: { | ||
title: message.language.get("REMINDER_TITLE"), | ||
description: message.language.get("REMINDER_STARTED", toRemind, ms(ms(time), { long: true })), | ||
color: 0x1EF121 | ||
} | ||
}) | ||
return setTimeout(() => { | ||
message.channel.send({ | ||
embed: { | ||
title: message.language.get("REMINDER_TITLE"), | ||
description: message.language.get("REMINDER_ENDED", toRemind), | ||
color: 0xF40C0C | ||
} | ||
}).then(message.channel.send(`<@!${message.author.id}>`).then((m) => m.delete())) | ||
|
||
}, ms(time)) | ||
} catch (error) { | ||
console.error(error); | ||
return message.channel.send(message.language.get("ERROR", error)); | ||
} | ||
} | ||
} | ||
|
||
module.exports = Reminder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.