The Enjin Discord bot, powered by Discord.js and Bun runtime, enables role assignment based on tokens stored in users' Enjin wallets. Its main function is to assign discord roles to members who possess the designated token set by the server administrator.
To add the Enjin Discord bot to your guild (server), click on the following link: Invite Enjin Bot
-
Invite the Bot: Use the provided link to invite the Enjin bot to your guild.
-
Permissions: Ensure that the bot has the highest role in the server, if not goto server settings > roles and drag the bot role to the top.
-
Run Setup Command: In your Discord server, use the slash command
/setup
to initiate the setup process. -
Add Conditions: Follow the prompts to add rule for a asset, repeat again to add rule for more assets.
To check all existing rules, use the slash command /list
. This will provide a list of tokens and it's role assignments.
-
Add Connect Button: Run
/add-button
to add a connect button to the channel, this will allow users to connect their wallet. -
Connect Walllet: User can click on the "Connect To Wallet" button to connect their wallet to the server.
To self-host this bot, follow the steps below:
-
Requirements:
- Docker: Install Docker on your machine. You can find installation instructions at https://docs.docker.com/get-docker/.
- MySQL: Install MySQL >=8 on your machine. You can find installation instructions at https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/.
- Wallet Connect API Key: Obtain a Wallet Connect API key from https://cloud.walletconnect.com/.
- Discord Developer API Key: Obtain a Discord Developer API key by creating a new application at https://discord.com/developers/applications.
- Discord Bot Token: Obtain a Discord bot token by creating a new bot in your Discord Developer application.
-
Setup Discord Bot
- Create a new Discord bot by following the instructions at https://discord.com/developers/applications.
- Copy the Bot APPLICATION ID (in general information tab) and save it for later use.
- Go to the Bot tab and,
- Add Icon
- Add Username
- Click on "Reset Token" to get the bot token.
- Copy the Bot Token. And save it for later use.
- Enable the "Public Bot" option.
-
Create Docker Image:
- Clone the Enjin Discord Bot repository from https://github.com/enjin/discord-bot/.
- Navigate to the cloned repository directory.
- Build the Docker image using the following command:
docker build -t enjin/discord-bot .
- Alternatively, you can pull the Docker image from the Enjin Docker Hub using the following command:
docker pull enjin/discord-bot:latest
-
Set Environment Variables:
- Create a
.env
file in the cloned repository directory. - Add the following environment variables to the
.env
file:DISCORD_BOT_TOKEN= WALLET_CONNECT_PROJECT_ID= DISCORD_APPLICATION_ID= DB_URL=mysql://user:[email protected]:3306/db_name RPC_URL=wss://rpc.matrix.blockchain.enjin.io
- Create a
-
Run the Bot:
- Start the bot using the following command:
docker run --env-file .env enjin/discord-bot
- Start the bot using the following command:
-
Run without Docker:
- If you prefer to run the bot without Docker, you can do so by running the following command:
Ensure that you have Bun installed on your machine.
bun install bun dev
The bot should now be running and ready to use in your self-hosted environment
- If you prefer to run the bot without Docker, you can do so by running the following command:
-
Invite the Bot:
- Construct the invite URL using the following format:
https://discord.com/oauth2/authorize?client_id=YOUR_DISCORD_APPLICATION_ID&scope=bot&permissions=275146345536
- Construct the invite URL using the following format:
For any issues, questions, or feedback, please contact Enjin Support at [email protected].