mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Morse Fixed?
This commit is contained in:
@@ -37,7 +37,6 @@ const morse = {
|
|||||||
"7": "--...",
|
"7": "--...",
|
||||||
"8": "---..",
|
"8": "---..",
|
||||||
"9": "----.",
|
"9": "----.",
|
||||||
" ": "/",
|
|
||||||
".": ".-.-.-",
|
".": ".-.-.-",
|
||||||
"?": "..--..",
|
"?": "..--..",
|
||||||
",": "--..--",
|
",": "--..--",
|
||||||
@@ -74,7 +73,7 @@ module.exports = class MorseCommand extends Command {
|
|||||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||||
}
|
}
|
||||||
const text = args.text.toLowerCase();
|
const text = args.text.toLowerCase();
|
||||||
const encoded = translator.letterTrans(text, morse);
|
const encoded = translator.letterTrans(text, morse, ' ');
|
||||||
return message.say(encoded);
|
return message.say(encoded);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports.wordTrans = (text, words) => {
|
|||||||
return translation.join(' ');
|
return translation.join(' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.letterTrans = (text, letters) => {
|
module.exports.letterTrans = (text, letters, joinWith) => {
|
||||||
text = text.split('');
|
text = text.split('');
|
||||||
let translation = [];
|
let translation = [];
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
@@ -27,5 +27,6 @@ module.exports.letterTrans = (text, letters) => {
|
|||||||
translation.push(letter);
|
translation.push(letter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return translation.join('');
|
joinWith = joinWith || '';
|
||||||
|
return translation.join(joinWith);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user