Move Translator Functions Outside of the Command Runner

This commit is contained in:
Daniel Odendahl Jr
2017-03-22 20:35:55 +00:00
parent 87bb4ad408
commit 39f4e49864
+20 -19
View File
@@ -1,23 +1,6 @@
const commando = require('discord.js-commando'); const commando = require('discord.js-commando');
module.exports = class TemmieCommand extends commando.Command { const dictionary = {
constructor(Client){
super(Client, {
name: 'temmie',
group: 'textedit',
memberName: 'temmie',
description: "Translate text to Temmie speak. (;temmie I am Temmie)",
examples: [";temmie I am Temmie."]
});
}
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let dictionary = {
"i": "tem", "i": "tem",
"hi": "hoi", "hi": "hoi",
"that": "dat", "that": "dat",
@@ -167,7 +150,8 @@ module.exports = class TemmieCommand extends commando.Command {
let character = text[i]; let character = text[i];
if (isLetter(character)) { if (isLetter(character)) {
word += character; word += character;
} else { }
else {
if (word != "") { if (word != "") {
let wordTranslate = translateWord(word); let wordTranslate = translateWord(word);
translatedText += wordTranslate; translatedText += wordTranslate;
@@ -182,6 +166,23 @@ module.exports = class TemmieCommand extends commando.Command {
return translatedText; return translatedText;
}; };
module.exports = class TemmieCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'temmie',
group: 'textedit',
memberName: 'temmie',
description: "Translate text to Temmie speak. (;temmie I am Temmie)",
examples: [";temmie I am Temmie."]
});
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log("[Command] " + message.content);
let thingToTranslate = message.content.split(" ").slice(1).join(" "); let thingToTranslate = message.content.split(" ").slice(1).join(" ");
let temspeak = translator(thingToTranslate); let temspeak = translator(thingToTranslate);
let noing = temspeak.split("ing").join("in"); let noing = temspeak.split("ing").join("in");