mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 16:19:12 +02:00
Destructuring Args
This commit is contained in:
@@ -25,6 +25,9 @@ module.exports = class BinaryCommand extends Command {
|
||||
return 'Your message content is too long.';
|
||||
}
|
||||
return true;
|
||||
},
|
||||
parse: text => {
|
||||
return stringToBinary(text);
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -34,8 +37,7 @@ module.exports = class BinaryCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const binary = stringToBinary(text);
|
||||
return message.say(binary);
|
||||
const { text } = args;
|
||||
return message.say(text);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = class CowsayCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const { text } = args;
|
||||
return message.code(null, `< ${text} >\n \\ ^__^\n \\ (oO)\\_______\n (__)\\ )\\/\\\n U ||----w |\n || ||`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,19 +18,19 @@ module.exports = class EmbedCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
|
||||
}
|
||||
const text = args.text;
|
||||
const { text } = args;
|
||||
const embed = new RichEmbed()
|
||||
.setAuthor(message.author.username, message.author.avatarURL)
|
||||
.setColor(0x00AE86)
|
||||
.setTimestamp()
|
||||
.setDescription(text);
|
||||
await message.delete();
|
||||
message.delete();
|
||||
return message.embed(embed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,6 +22,9 @@ module.exports = class MorseCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
return 'Your text to encode is too long.';
|
||||
},
|
||||
parse: text => {
|
||||
return translator.letterTrans(text.toLowerCase(), dictionary, ' ');
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -31,8 +34,7 @@ module.exports = class MorseCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text.toLowerCase();
|
||||
const encoded = translator.letterTrans(text, dictionary, ' ');
|
||||
return message.say(encoded);
|
||||
const { text } = args;
|
||||
return message.say(text);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,6 +23,9 @@ module.exports = class PirateCommand extends Command {
|
||||
return 'Your message content is too long.';
|
||||
}
|
||||
return true;
|
||||
},
|
||||
parse: text => {
|
||||
return translator.wordTrans(text, dictionary);
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -32,8 +35,7 @@ module.exports = class PirateCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const pirate = translator.wordTrans(text, dictionary);
|
||||
return message.say(`\u180E${pirate}`);
|
||||
const { text } = args;
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,10 @@ module.exports = class ReverseCommand extends Command {
|
||||
args: [{
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to reverse?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
parse: text => {
|
||||
return text.split('').reverse().join('');
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -20,8 +23,7 @@ module.exports = class ReverseCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const reversed = text.split('').reverse().join('');
|
||||
return message.say(`\u180E${reversed}`);
|
||||
const { text } = args;
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,13 +23,13 @@ module.exports = class SayCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
|
||||
}
|
||||
const text = args.text;
|
||||
await message.delete();
|
||||
const { text } = args;
|
||||
message.delete();
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ module.exports = class TemmieCommand extends Command {
|
||||
return 'Your message content is too long.';
|
||||
}
|
||||
return true;
|
||||
},
|
||||
parse: text => {
|
||||
return translator.wordTrans(text, dictionary);
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -28,8 +31,7 @@ module.exports = class TemmieCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const temmized = translator.wordTrans(text, dictionary);
|
||||
return message.say(`\u180E${temmized}`);
|
||||
const { text } = args;
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,10 @@ module.exports = class UpsideDownCommand extends Command {
|
||||
args: [{
|
||||
key: 'text',
|
||||
prompt: 'What text would you like to flip upside-down?',
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
parse: text => {
|
||||
return translator.letterTrans(text, dictionary);
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
@@ -26,8 +29,7 @@ module.exports = class UpsideDownCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const upsideDown = translator.letterTrans(text, dictionary);
|
||||
return message.say(upsideDown);
|
||||
const { text } = args;
|
||||
return message.say(text);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,9 +31,9 @@ module.exports = class WebhookCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
|
||||
}
|
||||
const text = args.text;
|
||||
const { text } = args;
|
||||
try {
|
||||
await message.delete();
|
||||
message.delete();
|
||||
await request
|
||||
.post(process.env.WEBHOOK_URL)
|
||||
.send({
|
||||
|
||||
@@ -18,6 +18,9 @@ module.exports = class ZalgoCommand extends Command {
|
||||
return 'Your message content is too long.';
|
||||
}
|
||||
return true;
|
||||
},
|
||||
parse: text => {
|
||||
return zalgo(text);
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -27,8 +30,7 @@ module.exports = class ZalgoCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const text = args.text;
|
||||
const zalgoified = zalgo(text);
|
||||
return message.say(`\u180E${zalgoified}`);
|
||||
const { text } = args;
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user