summaryrefslogtreecommitdiff
path: root/src/commands/fun/romannumeral.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/fun/romannumeral.ts')
-rw-r--r--src/commands/fun/romannumeral.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/commands/fun/romannumeral.ts b/src/commands/fun/romannumeral.ts
new file mode 100644
index 0000000..f7a805f
--- /dev/null
+++ b/src/commands/fun/romannumeral.ts
@@ -0,0 +1,55 @@
+import { Command, CommandoMessage } from 'discord.js-commando';
+import emoji from 'emoji-random'
+import romanize from 'romanize'
+
+module.exports = class RomanNumeralFun extends Command {
+ constructor(client) {
+ super(client, {
+ name: 'romannumeral',
+ aliases: [
+ 'roman-numeral',
+ 'romannumerals',
+ 'roman-numerals'
+ ],
+ group: 'fun',
+ memberName: 'romannumeral',
+ description: 'Converts a number to a roman numeral.',
+ examples: ['uwu!romannumeral 12'],
+ throttling: {
+ usages: 5,
+ duration: 30
+ },
+ userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
+ args: [
+ {
+ key: 'nNum',
+ prompt: 'What number would you like to translate',
+ type: 'integer',
+ min: 1
+ }
+ ]
+ });
+ }
+ run(msg: CommandoMessage, { nNum }) {
+ if (nNum === parseInt(nNum, 10)) {
+ msg.reply(romanize(nNum))
+ }
+
+ const back = value => {
+ let res = 0
+
+ const decimal = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
+ const roman = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
+ for (let i = 0; i <= decimal.length; i++) {
+ while (value.indexOf(roman[i]) === 0) {
+ res += decimal[i]
+ value = value.replace(roman[i], '')
+ }
+ }
+ return res
+ }
+
+ msg.reply(back(nNum))
+ }
+}; \ No newline at end of file