mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
23
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class BinaryCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'binary',
|
||||
group: 'text-edit',
|
||||
memberName: 'binary',
|
||||
description: 'Converts text to binary.',
|
||||
args: [
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: (text) => {
|
||||
if (this.binary(text).length < 2000) return true;
|
||||
else return 'Your text is too long.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
const { text } = args;
|
||||
const converted = this.binary(text);
|
||||
return msg.say(converted);
|
||||
}
|
||||
|
||||
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