Lots of Changes

This commit is contained in:
Daniel Odendahl Jr
2017-08-26 01:20:43 +00:00
parent d2008c749d
commit 56e72f7509
78 changed files with 393 additions and 389 deletions
+4 -7
View File
@@ -27,12 +27,9 @@ module.exports = class BinaryCommand extends Command {
}
binary(text) {
return unescape(encodeURIComponent(text))
.split('')
.map(str => {
const converted = str.charCodeAt(0).toString(2);
return `${'00000000'.slice(converted.length)}${converted}`;
})
.join('');
return text.split('').map(str => {
const converted = str.charCodeAt(0).toString(2);
return `${'00000000'.slice(converted.length)}${converted}`;
}).join('');
}
};
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = class CowsayCommand extends Command {
name: 'cow-say',
group: 'text-edit',
memberName: 'cow-say',
description: 'Converts text to cowsay.',
description: 'Converts text to cow-say.',
args: [
{
key: 'text',
+2 -3
View File
@@ -8,7 +8,6 @@ module.exports = class SayCommand extends Command {
group: 'text-edit',
memberName: 'say',
description: 'Make XiaoBot say what you wish.',
guildOnly: true,
args: [
{
key: 'text',
@@ -19,9 +18,9 @@ module.exports = class SayCommand extends Command {
});
}
run(msg, args) {
async run(msg, args) {
const { text } = args;
if (msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) msg.delete();
if (msg.guild && msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) await msg.delete();
return msg.say(text);
}
};
+17 -16
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { list } = require('../../structures/Util');
const codes = require('../../assets/json/translate');
const { YANDEX_KEY } = process.env;
@@ -11,7 +12,7 @@ module.exports = class TranslateCommand extends Command {
group: 'text-edit',
memberName: 'translate',
description: 'Translates text to a specified language.',
details: '**Codes:** https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/#languages',
details: `**Codes:** ${Object.keys(codes).join(', ')}`,
clientPermissions: ['EMBED_LINKS'],
args: [
{
@@ -20,42 +21,42 @@ module.exports = class TranslateCommand extends Command {
type: 'string',
validate: text => {
if (text.length < 500) return true;
return 'Text must be under 500 characters.';
return 'Please keep text under 500 characters.';
}
},
{
key: 'to',
prompt: 'Which language is being translated to?',
key: 'target',
prompt: 'Which language would you like to translate to?',
type: 'string',
validate: to => {
if (codes[to.toLowerCase()]) return true;
return 'Invalid Language Code. Use `help translate` for a list of codes.';
validate: target => {
if (codes[target.toLowerCase()]) return true;
return `Invalid target, please enter either ${list(Object.keys(codes), 'or')}.`;
},
parse: to => to.toLowerCase()
parse: target => target.toLowerCase()
},
{
key: 'from',
prompt: 'Which language is being translated from?',
key: 'original',
prompt: 'Which language is your text in?',
type: 'string',
default: '',
validate: from => {
if (codes[from.toLowerCase()]) return true;
return 'Invalid Language Code. Use `help translate` for a list of codes.';
validate: original => {
if (codes[original.toLowerCase()]) return true;
return `Invalid original, please enter either ${list(Object.keys(codes), 'or')}.`;
},
parse: from => from.toLowerCase()
parse: original => original.toLowerCase()
}
]
});
}
async run(msg, args) {
const { text, to, from } = args;
const { text, target, original } = args;
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
lang: original ? `${original}-${target}` : target
});
const lang = body.lang.split('-');
const embed = new MessageEmbed()
+1 -3
View File
@@ -10,9 +10,7 @@ module.exports = class WebhookCommand extends Command {
group: 'text-edit',
memberName: 'webhook',
description: 'Posts a message to the webhook defined in your `process.env`.',
guildOnly: true,
ownerOnly: true,
clientPermissions: ['MANAGE_MESSAGES'],
args: [
{
key: 'content',
@@ -25,7 +23,7 @@ module.exports = class WebhookCommand extends Command {
async run(msg, args) {
const { content } = args;
msg.delete();
if (msg.guild && msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) await msg.delete();
await snekfetch
.post(WEBHOOK_URL)
.send({ content });
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = class YodaCommand extends Command {
type: 'string',
validate: sentence => {
if (sentence.length < 500) return true;
return 'Text must be under 500 characters.';
return 'Please keep text under 500 characters.';
}
}
]
+2 -2
View File
@@ -7,7 +7,7 @@ module.exports = class ZalgoCommand extends Command {
name: 'zalgo',
group: 'text-edit',
memberName: 'zalgo',
description: 'Converts text to Zalgo.',
description: 'Converts text to zalgo.',
args: [
{
key: 'text',
@@ -15,7 +15,7 @@ module.exports = class ZalgoCommand extends Command {
type: 'string',
validate: text => {
if (text.length < 500) return true;
return 'Text must be under 500 characters.';
return 'Please keep text under 500 characters.';
}
}
]