Learn Japanese (or another language) On Stream? Command

Asked Jun 13, 2020·2 replies·Last activity 6 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hey guys,

I'm looking to make a command that I could set to a timer that would pull a random Japanese Kanji character, with Romanji pronunciation and meaning for all the weebs on the platform.

Hypothetically this could by done by pulling from a Japanese API that returns a Json response to Nightbot. However, I'm both having problems finding an API that would do this, and also the exact implementation on this.

Anyone with more knowledge have any insight?

2 replies

Hey @Lucky Jellyfish!

I'm not aware of any API that could provide that service, however, what you can do is fill a paste on Pastebin: create an account so you can edit the paste in the future, and make sure to set the expiration date to never.

The paste should be filled like this:

JAPANESE_KANJI_CHARACTER_1|
JAPANESE_KANJI_CHARACTER_2|
JAPANESE_KANJI_CHARACTER_3|
...
LAST_JAPANESE_KANJI_CHARACTER

Notice how every line ends with a | (vertical bar), except for the last one that doesn't need it, replace JAPANESE_KANJI_CHARACTER with your text, but make sure each character presentation doesn't go above 500 characters, and that you don't use the | (vertical bar) in the text anywhere else than at the end of the presentation.

Then use the following code in the Timer:

$(eval c=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`.split(`|`); c[Math.floor(Math.random()*c.length)])

Replace XXXXXXXX in the command by your paste ID.

Note: if you need to use the | (vertical bar) in your characters descriptions, then replace the one at the end of every description with another character you won't use, and replace it inside the ``.split(|)`` as well.

This is perfect! I had no idea that you could utilize a service like this so easily!

This opens up so many possibilities for unique responses. Just off the top of my head, a !compliment command that allows people to compliment others with premade compliments or better yet a !roast command with just a list different premade roasts for nightbot to call from.

You have drastically improved my chatbot with teaching me this. Thank you!