Skip to Content
Integrations

Telegram and Discord bots

Connect the site's bot in Telegram and Discord so it sends notifications and answers commands from players and staff.

By the end of this page your site will have its own bot in Telegram, Discord or both. It sends players the site's notifications as direct messages and answers commands: /online shows who is playing right now, and /me shows the roles and balance of the linked account. Posts to a shared Discord channel about payments and new players come from webhooks, no bot needed.

Open AdminBots. The screen has three tabs: "Telegram", "Discord" and "Commands". Only the owner (admin.boss) sees the "Telegram" tab. "Discord" and "Commands" need the "Sign-in methods" permission (admin.socials), and an admin with only that permission lands on "Discord".

Each bot is connected through a step-by-step wizard. Tokens and secrets are never shown again after saving: leave the field empty to keep the stored one. Pasting a new token or secret asks you to confirm with your password or 2FA.

Telegram

Bot

Click "Open @BotFather", send it /newbot, and pick a name and a username for the bot (the username ends in bot). BotFather replies with a token like 123456789:AAH…. Paste all of it into "Bot token" and click "Check and connect".

The Connect the Telegram bot wizard on the Bot step with the token field

Setup

The site fills in the bot description, adds the /start command and picks how the bot receives messages. If the site is served over public HTTPS, Telegram delivers messages instantly. Otherwise the scheduler fetches them once a minute, and the checks list shows "The scheduler is running" or "The scheduler is not running".

Sign-in

This step is optional. Turn on "Sign in with Telegram" and a Telegram button appears on the sign-in page. Send /setdomain to @BotFather, pick your bot and paste the domain from "Domain for /setdomain". Paste the secret from BotFather → your bot → Bot Settings → Web Login into "Client secret from BotFather". Click "Save and continue".

Done

The screen shows the bot, how it receives messages and whether sign-in is on. Click "Get notifications in Telegram", then Start in the bot, to try the connection on yourself. After that a "Send me a test message" button appears.

Players turn notifications on themselves: they click "Connect Telegram" in their site profile, then Start in the bot. "Disconnect the bot" stops Telegram notifications and turns sign-in with Telegram off. Players' links are kept: reconnect the same bot and they won't have to press Start again.

Could not reach Telegram: the site server cannot open api.telegram.org

Telegram is blocked in some countries and networks. Expand "If Telegram is unreachable from the server" on the Bot step and set "Proxy", for example socks5://user:pass@1.2.3.4:1080. Every request to Telegram goes through it: the bot, notifications and sign-in. The same block has "Bot API address" for your own Bot API server or a mirror.

The scheduler is not running, so the bot will not see Start.

Without public HTTPS the bot reads messages only through the scheduler. Add a cron job on the server that runs php flute cron:run every minute. The scheduler page shows how.

Discord

The Discord bot works on behalf of an application in the Discord Developer Portal. Players sign in to the site through the same application, so sign-in with Discord turns on by itself after the first step.

Application

Click "Open Discord Developer Portal" and create an application with New Application. In OAuth2, copy the Client ID and click Reset Secret to get the Client Secret. In the same place add both addresses from the screen to Redirects: "Address for signing in" and "Address for linking an account". Paste "Client ID" and "Client Secret" and click "Save and continue".

The Connect the Discord bot wizard on the Application step with the addresses to copy

Bot

In the Developer Portal open Bot, click Reset Token and paste the token into "Bot token". If Discord is unreachable from your server, set "Proxy" under "If Discord is unreachable from the server". Click "Check and continue".

Server

Click "Add the bot to a server", pick your Discord server and confirm (you need the right to manage the server). Come back to the admin panel and pick the server under "Server". Site commands appear on that server, and its roles can be given to players.

Commands

Discord posts every command and button press to the site itself. Copy "Address for commands", which looks like https://<YOUR_DOMAIN>/discord/interactions. In the Developer Portal open General Information, paste the address into Interactions Endpoint URL and click Save Changes. Discord checks the address right away. Once it accepts it, click "Check and turn commands on".

The Done step shows a list of checks: the token, the server, the public key, the address for commands and the registered commands. "Send me a test message" sends you a direct message. If your Discord isn't linked to your site account yet, you get "Link my Discord" in its place.

Discord notifications arrive as direct messages for players who linked Discord to their account. Giving out Discord roles based on site roles is covered in Discord sync.

Discord did not deliver the message: you and the bot must share a server

Discord lets a bot send direct messages only to people who share a server with it and allow direct messages from its members. The same rule applies to notifications for players.

The token belongs to another application, not the one sign-in is set up with

The bot token was copied from a different application in the Developer Portal. Open the application whose Client ID is on the Application step and issue the token in its Bot section.

Commands

The "Commands" tab lists every bot command. A command is written once and works in both Telegram and Discord. The engine ships six commands, and modules add their own once installed.

The Commands tab: the command table and the Greeting block
CommandWhat it does
/helpwhat the bot can do. It can't be switched off: every bot answer leads to it
/memy account: roles, balance
/balancemy balance
/onlinewho is playing now
/inboxwhat waits for staff, shown to staff only
/taketake a record, shown to staff only

/me, /balance and the staff commands work once the player links Telegram or Discord to their site account. Without a link the bot answers "This command works once you link your site account.".

Each row has an "On" switch, a "Works in" choice ("Telegram", "Discord" or "Both") and an "On the greeting" switch. A switched-off command does not answer and leaves the menu, help and greeting. "Edit" changes the "Name" and "Description". The command stops answering to its old name.

The "Greeting" block sets the buttons under the bot's greeting and the first lines of help. Everyone sees the first three commands from "For everyone" that are open to them, plus one from "For staff". Drag to change the order.

Changes take effect at once when a command is typed. The / menu in Telegram and the command list in Discord pick them up only after "Update the menu" at the top of the screen. Until then the screen shows "The bots' menu is out of date". A module's new command reaches the menus the same way, after an update.

Troubleshooting

For any other message, use the error lookup.

"Telegram does not know this token." means you should copy the token from @BotFather again in full, or issue a new one with /token.

"The name /… belongs to the bot itself, pick another" means you picked start or cancel, which are reserved. A command name uses lowercase Latin letters, digits and _, up to 32 characters, and a description is up to 100 characters.

"Discord does not know this address yet." on the Commands step means the address isn't saved in Interactions Endpoint URL. Paste it in the Developer Portal, click Save Changes and check again.

"Too many commands in a row. Wait a minute." is what a Discord player sees after more than 10 commands in a minute. In Telegram, after 20 commands and button presses in a minute, the bot stays silent until the minute is over.

Reference

Next

On this page