Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Commit

Permalink
Cooldown Inhibitor Change Seconds To Formatted String (#763)
Browse files Browse the repository at this point in the history
* Update cooldown.js

* Update en-US.js

* Update Duration.js

* Update cooldown.js

* Update cooldown.js

* Update Duration.js

* Update cooldown.js

* Update Duration.js

* Update cooldown.js

* Update cooldown.js

* Update cooldown.js

* Update cooldown.js

* Update cooldown.js

* Update cooldown.js

* Update cooldown.js
  • Loading branch information
Skillz4Killz authored and bdistin committed Aug 22, 2019
1 parent 558b59f commit 2ff196b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/inhibitors/cooldown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ module.exports = class extends Inhibitor {
return;
}

if (existing && existing.limited) throw message.language.get('INHIBITOR_COOLDOWN', Math.ceil(existing.remainingTime / 1000), command.cooldownLevel !== 'author');
if (existing && existing.limited) throw message.language.get('INHIBITOR_COOLDOWN', this.secondsToFormattedString(Math.ceil(existing.remainingTime / 1000)), command.cooldownLevel !== 'author');
}

secondsToFormattedString(time) {
const days = Math.floor(time / 86400);
const hours = Math.floor((time % 86400) / 3600);
const minutes = Math.floor((time % 3600) / 60);
const seconds = Math.floor(time % 60);
return `${days ? `${days}d ` : ''}${days || hours ? `${hours}h ` : ''}${days || hours || minutes ? `${minutes}m ` : ''}${seconds}s`;
}

};
2 changes: 1 addition & 1 deletion src/languages/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class extends Language {
MONITOR_COMMAND_HANDLER_REPEATING_REPROMPT: (tag, name, time, cancelOptions) => `${tag} | **${name}** is a repeating argument | You have **${time}** seconds to respond to this prompt with additional valid arguments. Type **${cancelOptions.join('**, **')}** to cancel this prompt.`,
MONITOR_COMMAND_HANDLER_ABORTED: 'Aborted',
// eslint-disable-next-line max-len
INHIBITOR_COOLDOWN: (remaining, guildCooldown) => `${guildCooldown ? 'Someone has' : 'You have'} already used this command. You can use this command again in ${remaining} second${remaining === 1 ? '' : 's'}.`,
INHIBITOR_COOLDOWN: (remaining, guildCooldown) => `${guildCooldown ? 'Someone has' : 'You have'} already used this command. You can use this command again in ${remaining}.`,
INHIBITOR_DISABLED_GUILD: 'This command has been disabled by an admin in this guild.',
INHIBITOR_DISABLED_GLOBAL: 'This command has been globally disabled by the bot owner.',
INHIBITOR_MISSING_BOT_PERMS: (missing) => `Insufficient permissions, missing: **${missing}**`,
Expand Down

0 comments on commit 2ff196b

Please sign in to comment.