mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 21:40:51 +02:00
Another Rewrite Type Thing
This commit is contained in:
@@ -27,8 +27,8 @@ 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 turnToBinary = args.text;
|
||||
const binaryText = stringToBinary(turnToBinary);
|
||||
return message.say(binaryText);
|
||||
const text = args.text;
|
||||
const binary = stringToBinary(text);
|
||||
return message.say(binary);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,9 +21,9 @@ 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 turnToCowsay = args.text;
|
||||
const text = args.text;
|
||||
return message.code(null, cowsay.say({
|
||||
text: turnToCowsay,
|
||||
text: text,
|
||||
e: 'oO',
|
||||
T: 'U '
|
||||
})).catch(() => message.say(':x: Error! Perhaps the content is too long?'));
|
||||
|
||||
@@ -24,12 +24,12 @@ module.exports = class EmbedCommand extends Command {
|
||||
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 embedMessage = args.text;
|
||||
const text = args.text;
|
||||
const embed = new RichEmbed()
|
||||
.setAuthor(message.author.username, message.author.avatarURL)
|
||||
.setColor(0x00AE86)
|
||||
.setTimestamp()
|
||||
.setDescription(embedMessage);
|
||||
.setDescription(text);
|
||||
await message.delete();
|
||||
return message.embed(embed);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ 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 toMorse = args.text;
|
||||
const morseEncoded = morse.encode(toMorse);
|
||||
return message.say(morseEncoded);
|
||||
const text = args.text;
|
||||
const encoded = morse.encode(text);
|
||||
return message.say(encoded);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,9 +31,8 @@ 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 turnToPirate = args.text;
|
||||
const pirate = pirateSpeak.translate(turnToPirate);
|
||||
if (pirate.length > 1950) return message.say(':x: Error! Your message is too long!');
|
||||
const text = args.text;
|
||||
const pirate = pirateSpeak.translate(text);
|
||||
return message.say(`\u180E${pirate}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ 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 stringToReverse = args.text;
|
||||
const reversed = stringToReverse.split('').reverse().join('');
|
||||
const text = args.text;
|
||||
const reversed = text.split('').reverse().join('');
|
||||
return message.say(`\u180E${reversed}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,8 +33,8 @@ module.exports = class RomajiCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const romajify = args.kana;
|
||||
const romajified = hepburn.fromKana(romajify);
|
||||
return message.say(romajified);
|
||||
const kana = args.kana;
|
||||
const romaji = hepburn.fromKana(kana);
|
||||
return message.say(romaji);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,8 +28,8 @@ module.exports = class SayCommand 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 copycat = args.text;
|
||||
const text = args.text;
|
||||
await message.delete();
|
||||
return message.say(`\u180E${copycat}`);
|
||||
return message.say(`\u180E${text}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,7 +32,8 @@ module.exports = class ShuffleCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const thingToShuffle = args.text;
|
||||
return message.say(`\u180E${thingToShuffle.shuffle()}`);
|
||||
const text = args.text;
|
||||
const shuffled = text.shuffle();
|
||||
return message.say(`\u180E${shuffled}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,8 +27,8 @@ 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 thingToTranslate = args.text;
|
||||
const temmized = temmize(thingToTranslate);
|
||||
const text = args.text;
|
||||
const temmized = temmize(text);
|
||||
return message.say(`\u180E${temmized}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,7 +232,7 @@ const dictionary = {
|
||||
};
|
||||
|
||||
function translateWord(word) {
|
||||
let wordTranslate = dictionary[word.toLowerCase()];
|
||||
var wordTranslate = dictionary[word.toLowerCase()];
|
||||
if (wordTranslate === undefined) return word;
|
||||
else return applyCase(word, wordTranslate);
|
||||
}
|
||||
@@ -241,8 +241,8 @@ function applyCase(wordA, wordB) {
|
||||
if (wordA.length === 1 && wordB.length !== 1) return wordB;
|
||||
if (wordA === wordA.toUpperCase()) return wordB.toUpperCase();
|
||||
if (wordA === wordA.toLowerCase()) return wordB.toLowerCase();
|
||||
let firstChar = wordA.slice(0, 1);
|
||||
let otherChars = wordA.slice(1);
|
||||
var firstChar = wordA.slice(0, 1);
|
||||
var otherChars = wordA.slice(1);
|
||||
if (firstChar === firstChar.toUpperCase() && otherChars === otherChars.toLowerCase()) {
|
||||
return wordB.slice(0, 1).toUpperCase() + wordB.slice(1).toLowerCase();
|
||||
}
|
||||
@@ -255,16 +255,16 @@ function isLetter(character) {
|
||||
}
|
||||
|
||||
function translator(text) {
|
||||
let translatedText = '';
|
||||
let word = '';
|
||||
for (let i = 0; i < text.length; i += 1) {
|
||||
let character = text[i];
|
||||
var translatedText = '';
|
||||
var word = '';
|
||||
for (var i = 0; i < text.length; i += 1) {
|
||||
var character = text[i];
|
||||
if (isLetter(character)) {
|
||||
word += character;
|
||||
}
|
||||
else {
|
||||
if (word != '') {
|
||||
let wordTranslate = translateWord(word);
|
||||
var wordTranslate = translateWord(word);
|
||||
translatedText += wordTranslate;
|
||||
word = '';
|
||||
}
|
||||
@@ -278,8 +278,10 @@ function translator(text) {
|
||||
}
|
||||
|
||||
module.exports = function(text) {
|
||||
let currentTranslation = translator(text);
|
||||
let temmify = currentTranslation.split('ing').join('in').split('!').join('!!!!111!11!1!!!1!!!1111!').split("'").join('');
|
||||
const currentTranslation = translator(text);
|
||||
let temmify = currentTranslation.replace(/[ing]/g, 'in');
|
||||
temmify = temmify.replace(/[!]/g, '!!!!111!11!1!!!1!!!1111!');
|
||||
temmify - temmify.replace(/[']/g, '');
|
||||
|
||||
return temmify;
|
||||
};
|
||||
|
||||
@@ -135,14 +135,14 @@ module.exports = class TranslateCommand extends Command {
|
||||
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!');
|
||||
}
|
||||
const languageto = args.to.toLowerCase();
|
||||
const language = args.to.toLowerCase();
|
||||
const query = args.text;
|
||||
try {
|
||||
const response = await request
|
||||
.get(`https://translate.yandex.net/api/v1.5/tr.json/translate`)
|
||||
.query({
|
||||
key: process.env.YANDEX_KEY,
|
||||
lang: languageto,
|
||||
lang: language,
|
||||
text: query
|
||||
});
|
||||
const data = response.body;
|
||||
|
||||
@@ -30,13 +30,13 @@ 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 content = args.text;
|
||||
const text = args.text;
|
||||
try {
|
||||
await message.delete();
|
||||
await request
|
||||
.post(process.env.WEBHOOK_URL)
|
||||
.send({
|
||||
content: content
|
||||
content: text
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ module.exports = class YodaCommand extends Command {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const turnToYoda = args.text;
|
||||
const text = args.text;
|
||||
try {
|
||||
const response = await request
|
||||
.get('https://yoda.p.mashape.com/yoda')
|
||||
@@ -30,7 +30,7 @@ module.exports = class YodaCommand extends Command {
|
||||
'Accept': 'text/plain'
|
||||
})
|
||||
.query({
|
||||
sentence: turnToYoda
|
||||
sentence: text
|
||||
});
|
||||
return message.say(`\u180E${response.text}`);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ 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 zalgoified = zalgo(args.text);
|
||||
const text = args.text;
|
||||
const zalgoified = zalgo(text);
|
||||
return message.say(`\u180E${zalgoified}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user