mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Clean-Ups
This commit is contained in:
+10
-10
@@ -1,11 +1,4 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const binary = (str) => {
|
||||
return unescape(encodeURIComponent(str))
|
||||
.split('').map(str => {
|
||||
const binary = str.charCodeAt(0).toString(2);
|
||||
return `${'00000000'.slice(binary.length)}${binary}`;
|
||||
}).join('');
|
||||
};
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class BinaryCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -20,10 +13,10 @@ module.exports = class BinaryCommand extends Command {
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (binary(text).length < 2000) return true;
|
||||
if (this.binary(text).length < 2000) return true;
|
||||
return 'Your text is too long.';
|
||||
},
|
||||
parse: text => binary(text)
|
||||
parse: text => this.binary(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -33,4 +26,11 @@ module.exports = class BinaryCommand extends Command {
|
||||
const { text } = args;
|
||||
return msg.say(text);
|
||||
}
|
||||
|
||||
binary(text) {
|
||||
return unescape(encodeURIComponent(text)).split('').map(str => {
|
||||
const converted = str.charCodeAt(0).toString(2);
|
||||
return `${'00000000'.slice(converted.length)}${converted}`;
|
||||
}).join('');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user