Bringing Our Discord Community Together

Michael Haas
Oct 19, 2017 · 4 min read

If you frequent our official Discord server, I am sure you’ve seen non-English speakers come around asking for assistance. Language can be a difficult gap to bridge, and we wanted to simplify that for our users.

On October 14th, we introduced new features to our preexisting Discord bot. Previously, it only handled the recent moderation activity on the site, but now it will automatically translate messages between common languages for users all over the world. Powered by Microsoft’s Translator Text API, the bot currently translates between English, French, German, and Russian on the fly, while maintaining any original files or images.

How We Did It

We wanted the entire process to be as stream-lined as possible for the user. As a result, the translator bot was implemented in a two part method. Standard Discord bots can monitor messages and reply on their own, but that isn’t enough for what we needed. We wanted the conversation to feel natural with the translations, and Discord Webhooks were how we accomplished that.

We implemented the translator by using a standard bot to watch for messages, translate them, then post them to the proper channel using webhooks. Regular bots can post messages, but only as themselves. With webhooks, we can easily manipulate who the author of a message is, resulting in a more natural interaction with the translation bot. Translated messages show up as being posted by the same person as the original message, with the source language in parentheses after their name.

In implementing the bot, one important consideration was being easily expandable. Theoretically, we could add additional languages to be translated with extreme ease.

Use our existing situation as an example: starting with a channel such as “general”, you simply can create a new channel named “general-ru” to add a Russian translation channel. Then, you only have to add a webhook to the channel named “Translator-ru.” Just make sure to also add a translator webhook to the original channel! While you need to indicate a webhook in the bot configuration for the preexisting activity functionality, the translation bot will dynamically read the channels and webhooks from the server to determine which have translation enabled.

Deploying The Translation Bot Yourself

Our Discord bot is available through the GPL V3 open source license from our GitHub organization. Written in Java, the bot is fully compatible across all platforms.

Before getting started, there are a few things you need to do:

  • Follow the simple instructions here to get a subscription key for Microsoft’s Translation API. This is free, and will allow you to translate 2,000,000 characters per month for free.
  • We currently do not distribute our Discord API tokens, so we ask that you make a Discord user bot by following this short guide (ignoring the final section).
  • On your Discord server, you now need to set up your channels and webhooks for translation. Start by adding a webhook to the original channel you want to use, with the name “Translator-{Lang_Code}” where {Lang_Code} is the two letter language code of the channel. Then, create additional channels with the same name as the original, with “-{Lang_Code}” appended to the name. Add the translator webhook in the same way as before, using the channel’s respective language code.

Now comes the final few steps to bring it all together. Download the most recent release of the bot from here. Run the bot once to generate an empty configuration file. The location of the file is outputted to your console on the first run, but should be located at:

  • %LOCALAPPDATA%\FanartTv\FanartDiscordBot\config.ini on Windows
  • ~/.config/FanartDiscordBot/config.ini on Linux and other UNIX systems

Replace the following lines in the config if you don’t plan to use the activity bot features:

  • “MICROSOFT_TRANSLATE_KEY” should be the Microsoft Translation API subscription key you created earlier.
  • “DISCORD_BOT_TOKEN” should be the “Token” of the Discord Bot User you created earlier, located here.
  • “DISCORD_GUILD_ID” should be the Guild ID of your Discord server which you got from the earlier guide.

Everything else is related to the activity bot, and is not required for the translation bot.

Working Collectively

With this new bot, we want to promote collaboration between everyone. We want a community open to all; one where you don’t have to struggle to communicate, because that is so important to what we are doing here. Hopefully this bot will open doors for many, and bring more collaborators to our community and, if you so chose, to yours.

Making the most of your media

Michael Haas

Written by

TripleFrequency; creator of Ather

Making the most of your media