Romaji Command

This commit is contained in:
Dragon Fire
2021-01-24 13:47:42 -05:00
parent 9615597e33
commit e3f8e090d1
3 changed files with 41 additions and 2 deletions
+2 -1
View File
@@ -261,7 +261,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 587
Total: 588
### Utility:
@@ -828,6 +828,7 @@ Total: 587
* **pirate:** Converts text to pirate.
* **repeat:** Repeat text over and over and over and over (etc).
* **reverse:** Reverses text.
* **romaji:** Converts Japanese text to Romaji.
* **say:** Make me say what you want, master.
* **sha-1:** Creates a hash of text with the SHA-1 algorithm.
* **sha-256:** Creates a hash of text with the SHA-256 algorithm.
+36
View File
@@ -0,0 +1,36 @@
const Command = require('../../structures/Command');
const Kuroshiro = require('kuroshiro');
const KuromojiAnalyzer = require('kuroshiro-analyzer-kuromoji');
module.exports = class RomajiCommand extends Command {
constructor(client) {
super(client, {
name: 'romaji',
aliases: ['romajify', 'hepburn'],
group: 'edit-text',
memberName: 'romaji',
description: 'Converts Japanese text to Romaji.',
args: [
{
key: 'text',
prompt: 'What text would you like to convert to romaji?',
type: 'string',
max: 500,
validate: text => Kuroshiro.Util.hasJapanese(text)
}
]
});
this.analyzer = new Kuroshiro();
this.inited = false;
}
async run(msg, { text }) {
if (!this.inited) {
await this.analyzer.init(new KuromojiAnalyzer());
this.inited = true;
}
const result = await this.analyzer.convert(text, { to: 'romaji' });
return msg.say(result);
}
};
+3 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "126.14.2",
"version": "126.15.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
@@ -55,6 +55,8 @@
"ioredis": "^4.19.4",
"js-beautify": "^1.13.4",
"js-chess-engine": "^0.6.0",
"kuroshiro": "^1.1.2",
"kuroshiro-analyzer-kuromoji": "^1.1.0",
"mathjs": "^9.0.0",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",