Discord Integration for Flows.network
Quick Start
This is a plain text echo bot.
use ;
pub async
async
[get_client()] is a Discord
constructor that represents a bot.
If you don't have a token, please see this section.
[listen_to_event()] is responsible for registering a listener for the bot
represented by the bot_token
. When a new Message
coming, the callback
is called with received Message
.
Creating a Bot Account
Some of the following are excerpts from discord.py docs
- Make sure you’re logged on to the Discord website.
- Navigate to the application page.
- Click on the “New Application” button.
- Give the application a name and click “Create”.
- Navigate to the “Bot”.
- Make sure that Public Bot is ticked if you want others to invite your bot.
And tick all the options of the "Privileged Gateway Intents".
- Click on the "Reset Token" button.
- Confirm reset by clicking "Yes, do it!" button.
- Copy the token using the “Copy” button.
It should be worth noting that this token is essentially your bot’s password. You should never share this with someone else. In doing so, someone can log in to your bot and do malicious things, such as leaving servers, ban all members inside a server, or pinging everyone maliciously.
The possibilities are endless, so do not share this token.
If you accidentally leaked your token, click the “Regenerate” button as soon as possible. This revokes your old token and re-generates a new one. Now you need to use the new token to login.
- Keep your token in a safe place, the token will only be shown once.
Inviting Your Bot
So you’ve made a Bot User but it’s not actually in any server.
If you want to invite your bot you must create an invite URL for it.
- Make sure you’re logged on to the Discord website.
- Navigate to the application page
- Click on your bot’s page.
- Go to the “OAuth2” tab.
- Tick the “bot” checkbox under “scopes”.
- Tick the permissions required for your bot to function under “Bot Permissions”.
- Please be aware of the consequences of requiring your bot to have the “Administrator” permission.
- Bot owners must have 2FA enabled for certain actions and permissions when added in servers that have Server-Wide 2FA enabled. Check the 2FA support page for more information.
- Now the resulting URL can be used to add your bot to a server. Copy and paste the URL into your browser, choose a server to invite the bot to, and click “Authorize”.
The person adding the bot needs “Manage Server” permissions to do so.
Using the default Bot
If you don't want to create your own Discord Bot, we have created a pub Bot which can be used by all users.
use ;
pub async
async
To invite this public Bot, you should compose the auth url with the permissions and scope
and replace the client_id
by 1090851501473271919
.
For example, if the scope is bot
and permissions is Send Messages
then the auth url should look like:
https://discord.com/api/oauth2/authorize?client_id=1090851501473271919&permissions=2048&scope=bot