Roman Numeral Command Added

This commit is contained in:
dragonfire535
2017-03-13 18:01:27 -04:00
parent c3e541b999
commit abb5275700
4 changed files with 34 additions and 1 deletions
@@ -5,7 +5,7 @@ class MathCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'math',
group: 'random',
group: 'numedit',
memberName: 'math',
description: 'Does Math (;math 2 + 2)',
examples: [';math 2 + 2']
+31
View File
@@ -0,0 +1,31 @@
const commando = require('discord.js-commando');
const romanNumeralConverter = require('roman-numeral-converter-mmxvi');
class RomanCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'roman',
group: 'numedit',
memberName: 'roman',
description: 'Converts numbers to Roman Numerals. (;roman 2)',
examples: [';roman 2']
});
}
async run(message, args) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
}
console.log("[Command] " + message.content);
let messagecontent = message.content.split(" ").slice(1).join(" ");
let numberified = Number(messagecontent);
if(numberified > 10000) {
message.channel.sendMessage(':x: Error! Number is too high!');
} else {
message.channel.sendMessage(romanNumeralConverter.getRomanFromInteger(numberified)).catch(error => message.channel.sendMessage(':x: Error! Something went wrong! Perhaps you entered nothing?'));
}
}
}
module.exports = RomanCommand;