diff --git a/commands/random/math.js b/commands/numedit/math.js similarity index 97% rename from commands/random/math.js rename to commands/numedit/math.js index 68bdfca7..bcd9c06f 100644 --- a/commands/random/math.js +++ b/commands/numedit/math.js @@ -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'] diff --git a/commands/numedit/roman.js b/commands/numedit/roman.js new file mode 100644 index 00000000..c24647f1 --- /dev/null +++ b/commands/numedit/roman.js @@ -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; \ No newline at end of file diff --git a/index.js b/index.js index a4597423..39a84294 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ client.registry ['response', 'Random Response'], ['avataredit', 'Avatar Manipulation'], ['textedit', 'Text Manipulation'], + ['numedit', 'Number Manipulation'], ['imageedit', 'Image Manipulation'], ['search', 'Search'], ['random', 'Random/Other'], diff --git a/package.json b/package.json index 27f2e0da..4d072313 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "mathjs": "^3.10.0", "pirate-speak": "^1.0.1", "request-promise": "^4.1.1", + "roman-numeral-converter-mmxvi": "^1.0.5", "string-to-binary": "^0.1.2", "urban": "^0.3.1", "yahoo-weather": "^2.2.2",