mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 00:12:38 +02:00
22.0.0
This commit is contained in:
@@ -12,11 +12,14 @@ module.exports = class BinaryCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to binary?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (this.binary(text).length < 2000) return true;
|
||||
return 'Your text is too long.';
|
||||
validate: (text) => {
|
||||
if (this.binary(text).length < 2000) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Your text is too long.';
|
||||
}
|
||||
},
|
||||
parse: text => this.binary(text)
|
||||
parse: (text) => this.binary(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -28,7 +31,7 @@ module.exports = class BinaryCommand extends Command {
|
||||
}
|
||||
|
||||
binary(text) {
|
||||
return unescape(encodeURIComponent(text)).split('').map(str => {
|
||||
return unescape(encodeURIComponent(text)).split('').map((str) => {
|
||||
const converted = str.charCodeAt(0).toString(2);
|
||||
return `${'00000000'.slice(converted.length)}${converted}`;
|
||||
}).join('');
|
||||
|
||||
@@ -13,9 +13,12 @@ module.exports = class CowsayCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like the cow to say?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (text.length < 1500) return true;
|
||||
return 'Invalid Text. Text must be under 1500 characters.';
|
||||
validate: (text) => {
|
||||
if (text.length < 1500) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Text. Text must be under 1500 characters.';
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -14,11 +14,14 @@ module.exports = class MorseCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to morse?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (letterTrans(text, dictionary, ' ').length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
validate: (text) => {
|
||||
if (letterTrans(text, dictionary, ' ').length < 1999) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Your text is too long.';
|
||||
}
|
||||
},
|
||||
parse: text => letterTrans(text.toLowerCase(), dictionary, ' ')
|
||||
parse: (text) => letterTrans(text.toLowerCase(), dictionary, ' ')
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -14,11 +14,14 @@ module.exports = class PirateCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to pirate?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (wordTrans(text, dictionary).length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
validate: (text) => {
|
||||
if (wordTrans(text, dictionary).length < 1999) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Your text is too long.';
|
||||
}
|
||||
},
|
||||
parse: text => wordTrans(text, dictionary)
|
||||
parse: (text) => wordTrans(text, dictionary)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = class RepeatCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to repeat over and over and over and over?',
|
||||
type: 'string',
|
||||
parse: text => text.repeat(2000).substr(0, 1999)
|
||||
parse: (text) => text.repeat(2000).substr(0, 1999)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = class ReverseCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to reverse?',
|
||||
type: 'string',
|
||||
parse: text => text.split('').reverse().join('')
|
||||
parse: (text) => text.split('').reverse().join('')
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -14,11 +14,14 @@ module.exports = class TemmieCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to Temmie speak?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (wordTrans(text, dictionary).length < 1999) return true;
|
||||
return 'Your text is too long.';
|
||||
validate: (text) => {
|
||||
if (wordTrans(text, dictionary).length < 1999) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Your text is too long.';
|
||||
}
|
||||
},
|
||||
parse: text => wordTrans(text, dictionary)
|
||||
parse: (text) => wordTrans(text, dictionary)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -23,22 +23,28 @@ module.exports = class TranslateCommand extends Command {
|
||||
key: 'to',
|
||||
prompt: 'Which language is being translated to?',
|
||||
type: 'string',
|
||||
validate: to => {
|
||||
if (codes[to.toLowerCase()]) return true;
|
||||
return 'Invalid Language Code. Use `help translate` for a list of codes.';
|
||||
validate: (to) => {
|
||||
if (codes[to.toLowerCase()]) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Language Code. Use `help translate` for a list of codes.';
|
||||
}
|
||||
},
|
||||
parse: to => to.toLowerCase()
|
||||
parse: (to) => to.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'from',
|
||||
prompt: 'Which language is being translated from?',
|
||||
type: 'string',
|
||||
validate: from => {
|
||||
if (codes[from.toLowerCase()]) return true;
|
||||
return 'Invalid Language Code. Use `help translate` for a list of codes.';
|
||||
default: '',
|
||||
validate: (from) => {
|
||||
if (codes[from.toLowerCase()]) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Language Code. Use `help translate` for a list of codes.';
|
||||
}
|
||||
},
|
||||
parse: from => from.toLowerCase(),
|
||||
default: ''
|
||||
parse: (from) => from.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -46,24 +52,20 @@ module.exports = class TranslateCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { text, to, from } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://translate.yandex.net/api/v1.5/tr.json/translate')
|
||||
.query({
|
||||
key: YANDEX_KEY,
|
||||
text,
|
||||
lang: from ? `${from}-${to}` : to
|
||||
});
|
||||
const lang = body.lang.split('-');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.addField(`From: ${codes[lang[0]]}`,
|
||||
text)
|
||||
.addField(`To: ${codes[lang[1]]}`,
|
||||
body.text[0]);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.get('https://translate.yandex.net/api/v1.5/tr.json/translate')
|
||||
.query({
|
||||
key: YANDEX_KEY,
|
||||
text,
|
||||
lang: from ? `${from}-${to}` : to
|
||||
});
|
||||
const lang = body.lang.split('-');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.addField(`❯ From: ${codes[lang[0]]}`,
|
||||
text)
|
||||
.addField(`❯ To: ${codes[lang[1]]}`,
|
||||
body.text[0]);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = class UpsideDownCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to flip upside-down?',
|
||||
type: 'string',
|
||||
parse: text => letterTrans(text, dictionary)
|
||||
parse: (text) => letterTrans(text, dictionary)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -23,20 +23,12 @@ module.exports = class WebhookCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
hasPermission(msg) {
|
||||
return this.client.isOwner(msg.author);
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { content } = args;
|
||||
try {
|
||||
msg.delete();
|
||||
await snekfetch
|
||||
.post(WEBHOOK_URL)
|
||||
.send({ content });
|
||||
return null;
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
msg.delete();
|
||||
await snekfetch
|
||||
.post(WEBHOOK_URL)
|
||||
.send({ content });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,11 +13,14 @@ module.exports = class ZalgoCommand extends Command {
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to convert to zalgo?',
|
||||
type: 'string',
|
||||
validate: text => {
|
||||
if (text.length < 500) return true;
|
||||
return 'Invalid Text. Text must be under 500 characters.';
|
||||
validate: (text) => {
|
||||
if (text.length < 500) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Invalid Text. Text must be under 500 characters.';
|
||||
}
|
||||
},
|
||||
parse: text => zalgo(text)
|
||||
parse: (text) => zalgo(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user