mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
More uniform group names
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const numerals = require('../../assets/json/roman');
|
||||
|
||||
module.exports = class RomanCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'roman',
|
||||
aliases: ['roman-numeral'],
|
||||
group: 'edit-number',
|
||||
memberName: 'roman',
|
||||
description: 'Converts a number to roman numerals.',
|
||||
args: [
|
||||
{
|
||||
key: 'number',
|
||||
prompt: 'What number would you like to convert to roman numerals?',
|
||||
type: 'integer',
|
||||
min: -3999999,
|
||||
max: 3999999
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { number }) {
|
||||
if (number === 0) return msg.reply('_nulla_');
|
||||
let negative = false;
|
||||
if (number < 0) {
|
||||
negative = true;
|
||||
number = Math.abs(number);
|
||||
}
|
||||
let result = '';
|
||||
for (const [numeral, value] of Object.entries(numerals)) {
|
||||
while (number >= value) {
|
||||
result += numeral;
|
||||
number -= value;
|
||||
}
|
||||
}
|
||||
return msg.reply(`${negative ? '-' : ''}${result}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user