return and await

This commit is contained in:
Daniel Odendahl Jr
2017-03-23 13:16:59 +00:00
parent cea110ce4b
commit 7c0a39ec5c
83 changed files with 295 additions and 264 deletions
+1 -1
View File
@@ -18,6 +18,6 @@ module.exports = class BinaryCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let turnToBinary = message.content.split(" ").slice(1).join(" ");
message.channel.send(stringToBinary(turnToBinary)).catch(error => message.channel.send(':x: Error! Translation is too long, or nothing was entered!'));
return message.channel.send(stringToBinary(turnToBinary)).catch(error => message.channel.send(':x: Error! Translation is too long, or nothing was entered!'));
}
};
+3 -3
View File
@@ -18,16 +18,16 @@ module.exports = class CowsayCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
if (!message.content.split(" ").slice(1).join(" ")) {
message.channel.send(":x: Error! You entered nothing!");
return message.channel.send(":x: Error! You entered nothing!");
}
else {
let turnToCowsay = message.content.split(" ").slice(1).join(" ");
message.channel.sendCode(null, cowsay.say({
return message.channel.sendCode(null, cowsay.say({
text: turnToCowsay,
e: "oO",
T: "U "
})).catch(error => {
message.channel.send(':x: Error! Perhaps the content is too long?');
return message.channel.send(':x: Error! Perhaps the content is too long?');
});
}
}
+18 -9
View File
@@ -19,17 +19,26 @@ module.exports = class EmbedCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let embedMessage = message.content.split(" ").slice(1).join(" ");
if (!embedMessage) {
message.channel.send(":x: Error! Nothing to embed!");
return message.channel.send(":x: Error! Nothing to embed!");
}
else {
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(embedMessage);
message.channel.sendEmbed(embed).catch(console.error);
if (message.channel.type === 'dm') return;
message.delete();
if (message.channel.type === 'dm') {
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(embedMessage);
return message.channel.sendEmbed(embed).catch(console.error);
}
else {
const embed = new Discord.RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(embedMessage);
await message.delete();
return message.channel.sendEmbed(embed).catch(console.error);
}
}
}
};
+4 -4
View File
@@ -23,16 +23,16 @@ module.exports = class MorseCommand extends commando.Command {
let [methodToUse] = message.content.toLowerCase().split(" ").slice(1);
let toMorse = message.content.split(" ").slice(2).join(" ");
if (!toMorse) {
message.channel.send(":x: Error! Nothing to translate! Perhaps you forgot to set the method? Use either encode or decode before your text.");
return message.channel.send(":x: Error! Nothing to translate! Perhaps you forgot to set the method? Use either encode or decode before your text.");
}
else if (methodToUse === 'encode') {
message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
return message.channel.send(morse.encode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
}
else if (methodToUse === 'decode') {
message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
return message.channel.send(morse.decode(toMorse)).catch(error => message.channel.send(':x: Error! Something went wrong! Perhaps you entered incorrect text?'));
}
else {
message.channel.send(":x: Error! Method not set/not correct! Use either encode or decode.");
return message.channel.send(":x: Error! Method not set/not correct! Use either encode or decode.");
}
}
};
+3 -3
View File
@@ -24,14 +24,14 @@ module.exports = class PirateCommand extends commando.Command {
let turnToPirate = message.content.split(" ").slice(1).join(" ");
let pirate = pirateSpeak.translate(turnToPirate);
if (!turnToPirate) {
message.channel.send(":x: Error! Nothing to translate!");
return message.channel.send(":x: Error! Nothing to translate!");
}
else {
if (pirate.length > 1950) {
message.channel.send(":x: Error! Your message is too long!");
return message.channel.send(":x: Error! Your message is too long!");
}
else {
message.channel.send(pirate);
return message.channel.send(pirate);
}
}
}
+2 -2
View File
@@ -18,11 +18,11 @@ module.exports = class ReverseCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let stringToReverse = message.content.split(" ").slice(1).join(" ");
if (!stringToReverse) {
message.channel.send(":x: Error! Nothing to reverse!");
return message.channel.send(":x: Error! Nothing to reverse!");
}
else {
let reversed = stringToReverse.split("").reverse().join("");
message.channel.send(reversed);
return message.channel.send(reversed);
}
}
};
+3 -3
View File
@@ -25,17 +25,17 @@ module.exports = class RinSayCommand extends commando.Command {
}
console.log(`[Command] ${message.content}`);
let rinContent = message.content.split(" ").slice(1).join(" ");
request
await request
.post(config.webhook)
.send({
content: rinContent
})
.then(function(parsedBody) {
if (message.content.type === 'dm') return;
message.delete();
return message.delete();
}).catch(function(err) {
message.channel.send(':x: Error! Message failed to send! Check the logs for details.');
console.log(err);
return message.channel.send(':x: Error! Message failed to send! Check the logs for details.');
});
}
};
+3 -3
View File
@@ -24,14 +24,14 @@ module.exports = class RomajiCommand extends commando.Command {
if (hepburn.containsKana(romajify)) {
let romajified = hepburn.fromKana(romajify);
if (romajified.length > 1950) {
message.channel.send(":x: Error! Your message is too long!");
return message.channel.send(":x: Error! Your message is too long!");
}
else {
message.channel.send(romajified);
return message.channel.send(romajified);
}
}
else {
message.channel.send(":x: Error! Message contains no Kana!\n:notepad_spiral: Note: You cannot use this command on Kanji!");
return message.channel.send(":x: Error! Message contains no Kana!\n:notepad_spiral: Note: You cannot use this command on Kanji!");
}
}
};
+8 -4
View File
@@ -24,12 +24,16 @@ module.exports = class SayCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let copycat = message.content.split(" ").slice(1).join(" ");
if (!copycat) {
message.channel.send(":x: Error! Nothing to say!");
return message.channel.send(":x: Error! Nothing to say!");
}
else {
message.channel.send(copycat);
if (message.channel.type === 'dm') return;
message.delete();
if (message.channel.type === 'dm') {
return message.channel.send(copycat);
}
else {
await message.delete();
return message.channel.send(copycat);
}
}
}
};
+2 -2
View File
@@ -30,10 +30,10 @@ module.exports = class ShuffleCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let thingToShuffle = message.content.split(" ").slice(1).join(" ");
if (!thingToShuffle) {
message.channel.send(":x: Error! Nothing to shuffle!");
return message.channel.send(":x: Error! Nothing to shuffle!");
}
else {
message.channel.send(thingToShuffle.shuffle());
return message.channel.send(thingToShuffle.shuffle());
}
}
};
+2 -2
View File
@@ -288,11 +288,11 @@ module.exports = class TemmieCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let thingToTranslate = message.content.split(" ").slice(1).join(" ");
if (!thingToTranslate) {
message.channel.send(':x: Error! Nothing to translate!');
return message.channel.send(':x: Error! Nothing to translate!');
}
else {
let temmized = temmize(thingToTranslate);
message.channel.send(temmized);
return message.channel.send(temmized);
}
}
};
+8 -7
View File
@@ -128,17 +128,17 @@ module.exports = class TranslateCommand extends commando.Command {
let [languageto] = message.content.toLowerCase().split(" ").slice(1);
let thingToTranslate = message.content.split(" ").slice(2).join(" ");
if (languageto === "list") {
message.channel.send("af': 'Afrikaans\nsq': 'Albanian'\n'ar': 'Arabic\nhy': 'Armenian\naz': 'Azerbaijani\neu': 'Basque\nbe': 'Belarusian\nbn': 'Bengali\nbs': 'Bosnian\nbg': 'Bulgarian\nca': 'Catalan\nceb': 'Cebuano\nny': 'Chichewa\nzh-cn': 'Chinese Simplified\nzh-tw': 'Chinese Traditional\nco': 'Corsican\nhr': 'Croatian\ncs': 'Czech\nda': 'Danish\nnl': 'Dutch\nen': 'English\neo': 'Esperanto\net': 'Estonian\ntl': 'Filipino\nfi': 'Finnish\nfr': 'French\nfy': 'Frisian\ngl': 'Galician\nka': 'Georgian\nde': 'German\nel': 'Greek\ngu': 'Gujarati\nht': 'Haitian Creole\nha': 'Hausa\nhaw': 'Hawaiian\niw': 'Hebrew\nhi': 'Hindi\nhmn': 'Hmong\nhu': 'Hungarian\nis': 'Icelandic\nig': 'Igbo\nid': 'Indonesian\nga': 'Irish\nit': 'Italian\nja': 'Japanese\njw': 'Javanese\nkn': 'Kannada\nkk': 'Kazakh\nkm': 'Khmer\nko': 'Korean\nku': 'Kurdish (Kurmanji)\nky': 'Kyrgyz\nlo': 'Lao\nla': 'Latin\nlv': 'Latvian\nlt': 'Lithuanian\nlb': 'Luxembourgish\nmk': 'Macedonian\nmg': 'Malagasy\nms': 'Malay\nml': 'Malayalam\nmt': 'Maltese\nmi': 'Maori\nmr': 'Marathi\nmn': 'Mongolian\nmy': 'Myanmar (Burmese)\nne': 'Nepali\nno': 'Norwegian\nps': 'Pashto\nfa': 'Persian\npl': 'Polish\npt': 'Portuguese\nma': 'Punjabi\nro': 'Romanian\nru': 'Russian\nsm': 'Samoan\ngd': 'Scots Gaelic\nsr': 'Serbian\nst': 'Sesotho\nsn': 'Shona\nsd': 'Sindhi\nsi': 'Sinhala\nsk': 'Slovak\nsl': 'Slovenian\nso': 'Somali\nes': 'Spanish\nsu': 'Sudanese\nsw': 'Swahili\nsv': 'Swedish\ntg': 'Tajik\nta': 'Tamil\nte': 'Telugu\nth': 'Thai\ntr': 'Turkish\nuk': 'Ukrainian\nur': 'Urdu\nuz': 'Uzbek\nvi': 'Vietnamese\ncy': 'Welsh\nxh': 'Xhosa\nyi': 'Yiddish\nyo': 'Yoruba\nzu': 'Zulu'");
return message.channel.send("af': 'Afrikaans\nsq': 'Albanian'\n'ar': 'Arabic\nhy': 'Armenian\naz': 'Azerbaijani\neu': 'Basque\nbe': 'Belarusian\nbn': 'Bengali\nbs': 'Bosnian\nbg': 'Bulgarian\nca': 'Catalan\nceb': 'Cebuano\nny': 'Chichewa\nzh-cn': 'Chinese Simplified\nzh-tw': 'Chinese Traditional\nco': 'Corsican\nhr': 'Croatian\ncs': 'Czech\nda': 'Danish\nnl': 'Dutch\nen': 'English\neo': 'Esperanto\net': 'Estonian\ntl': 'Filipino\nfi': 'Finnish\nfr': 'French\nfy': 'Frisian\ngl': 'Galician\nka': 'Georgian\nde': 'German\nel': 'Greek\ngu': 'Gujarati\nht': 'Haitian Creole\nha': 'Hausa\nhaw': 'Hawaiian\niw': 'Hebrew\nhi': 'Hindi\nhmn': 'Hmong\nhu': 'Hungarian\nis': 'Icelandic\nig': 'Igbo\nid': 'Indonesian\nga': 'Irish\nit': 'Italian\nja': 'Japanese\njw': 'Javanese\nkn': 'Kannada\nkk': 'Kazakh\nkm': 'Khmer\nko': 'Korean\nku': 'Kurdish (Kurmanji)\nky': 'Kyrgyz\nlo': 'Lao\nla': 'Latin\nlv': 'Latvian\nlt': 'Lithuanian\nlb': 'Luxembourgish\nmk': 'Macedonian\nmg': 'Malagasy\nms': 'Malay\nml': 'Malayalam\nmt': 'Maltese\nmi': 'Maori\nmr': 'Marathi\nmn': 'Mongolian\nmy': 'Myanmar (Burmese)\nne': 'Nepali\nno': 'Norwegian\nps': 'Pashto\nfa': 'Persian\npl': 'Polish\npt': 'Portuguese\nma': 'Punjabi\nro': 'Romanian\nru': 'Russian\nsm': 'Samoan\ngd': 'Scots Gaelic\nsr': 'Serbian\nst': 'Sesotho\nsn': 'Shona\nsd': 'Sindhi\nsi': 'Sinhala\nsk': 'Slovak\nsl': 'Slovenian\nso': 'Somali\nes': 'Spanish\nsu': 'Sudanese\nsw': 'Swahili\nsv': 'Swedish\ntg': 'Tajik\nta': 'Tamil\nte': 'Telugu\nth': 'Thai\ntr': 'Turkish\nuk': 'Ukrainian\nur': 'Urdu\nuz': 'Uzbek\nvi': 'Vietnamese\ncy': 'Welsh\nxh': 'Xhosa\nyi': 'Yiddish\nyo': 'Yoruba\nzu': 'Zulu'");
}
else if (languages[languageto]) {
if (!thingToTranslate) {
message.channel.send(":x: Error! Nothing to translate!");
return message.channel.send(":x: Error! Nothing to translate!");
}
else if (thingToTranslate.length > 200) {
message.channel.send(":x: Error! Please keep translations below 200 characters!");
return message.channel.send(":x: Error! Please keep translations below 200 characters!");
}
else {
translate(thingToTranslate, {
await translate(thingToTranslate, {
to: languageto
}).then(res => {
let languagefrom = res.from.language.iso.toLowerCase();
@@ -148,14 +148,15 @@ module.exports = class TranslateCommand extends commando.Command {
thingToTranslate)
.addField(`Translation (To: ${languages[languageto]}):`,
res.text);
message.channel.sendEmbed(embed).catch(console.error);
return message.channel.sendEmbed(embed).catch(console.error);
}).catch(err => {
message.channel.send(":x: Error! Something went wrong!");
console.log(err);
return message.channel.send(":x: Error! Something went wrong!");
});
}
}
else {
message.channel.send(":x: Error! Language not found! Use `;translate list` to view a list of translate codes!");
return message.channel.send(":x: Error! Language not found! Use `;translate list` to view a list of translate codes!");
}
}
};
+6 -5
View File
@@ -20,10 +20,10 @@ module.exports = class YodaCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let turnToYoda = message.content.split(" ").slice(1).join(" ");
if (!turnToYoda) {
message.channel.send(':x: Error! Nothing to translate!');
return message.channel.send(':x: Error! Nothing to translate!');
}
else {
request
await request
.get('https://yoda.p.mashape.com/yoda')
.set({
'X-Mashape-Key': config.mashapekey,
@@ -34,13 +34,14 @@ module.exports = class YodaCommand extends commando.Command {
})
.then(function(response) {
if (response === undefined) {
message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
return message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.');
}
else {
message.channel.send(response.text).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
return message.channel.send(response.text).catch(error => message.channel.send(':x: Error! Something went wrong! Keep it simple to avoid this error.'));
}
}).catch(function(err) {
message.channel.send(":x: Error! Unknown Error. Try again later!");
console.log(err);
return message.channel.send(":x: Error! Unknown Error. Try again later!");
});
}
}
+3 -3
View File
@@ -19,13 +19,13 @@ module.exports = class ZalgoCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let zalgoified = zalgo(message.content.split(" ").slice(1).join(" "));
if (!zalgoified) {
message.channel.send(":x: Error! Nothing to zalgoify!");
return message.channel.send(":x: Error! Nothing to zalgoify!");
}
else if (zalgoified.length > 1950) {
message.channel.send(":x: Error! Your message is too long!");
return message.channel.send(":x: Error! Your message is too long!");
}
else {
message.channel.send(zalgoified);
return message.channel.send(zalgoified);
}
}
};