Hi there, and welcome to the docs on trialBot! Check out the table of contents, and follow along as I tell you about the bot, and how to get it up and running.
What can it do?
The first thing I would like to do is explain what trial bot is, and what it can do to improve the experience of the users in your guilds.
grant temporary access of roles to users
This bot allows you to give a role to a user in your guild for a set amount of time. If you have some channels restricted to only paying users, you can give them a trial period of those channels to try and gain their business. This functionality gives the user the role you denote immediately, and removes it after the set amount of time you choose.
temporarily grant users a role when they join your server
**Coming Soon** – This will allow you to give a user a temporary role as they join your server, and then it be removed after the amount of time you have chosen.
grant temporary access of a role starting and ending at certain times
**Coming Soon** – This will allow you to set up events on your server in which you can choose that all your users, or certain users get access to a role for a certain amount of time.
Prerequisites
There are a few prerequisites that you need to take into account.
- If you would like to use a bot I have hosted, it is $5 a month, and you can reach me through discord
- You will need a 24/7 server to run this bot. There are many different providers you can choose from, but it is up to you to make that decision
- The only requirement for the bot is installing node
- node v16.11.1
- The only requirement for the bot is installing node
Creating the Discord Application
If you are familiar with creation a Discord Bot Application it is very likely you can skip this section, the only important pieces are.
Important Bot Settings
– Bot needs Server Member Intents enabled.
– After the bot has been added to your servers, move their role above others in the hierarchy.
– Make sure that the bot has read message / send message permissions on the log channel you create.
There are many better tutorials than this on how to create a Discord application, but I’ll add a quick list.
- Create a Discord Bot at https://discord.com/developers/applications
- Click New Application
- Note down the application id in the config.json
- Enable Server Members Intent
- So that we can add and remove roles as the roles expire
- On the left hand side click Bot
- Click Ok
- Note down the Token for use in config.json below
- Click OAuth2 in the left sidebar, Url Generator
- In the Url Generator
- in the scopes section
- select “bot” and “application.commands”
- in the bot permissions section
- “manage roles” & “view audit log”
- in the scopes section
- Copy the URL in the bottom of the “scopes” section and paste it into your web browser
- IMPORTANT: After the bot has joined your server, make sure the bot’s role is located above the roles you want added/removed in the role hierarchy.
Getting Started
The Config File – Explained
In the code files you fetched from the trial bot github, there is a file named config.example.json This is the file that you need to update with your bots various data, and then save as config.json
Edit config.example.json and save as config.json
Warning, if you have forked the trialbot repo, do not commit this file to your repo as it contains sensitive data.
To make filling in the config file easier, I would highly recommend enabling discord developer mode. It simply adds menu items to lists in discord giving you access to different ids.
How to – Enable discord developer mode
In discord, click the settings cog by your username -> Advanced -> Developer Mode Toggle
Enter the bot token
You can find your bots token by going to https://discord.com/developers/applications
- Select your Application
- Select Bot on the Left
- If you noted down the token in the creation of the bot above, paste it here, otherwise you can reset and copy the token.
"token": "OTt024H3729NjQ4Njkx.YjSn7A.something97ai3k0aU723GTJ4"
Enter the application id
Your bot application id and client id are the same number. It can be found in General Information as Application Id, or in OAuth2 -> General as Client Id. Copy either of these values into your config file.
"clientId": "123456789123456789"
Registering the Commands
After you have finished filling out the config file it is time to register the slash commands so that they are usable on your server.
run “node register.js”
Navigate to the folder where the bot was installed using your command line or terminal, and type into the console node register.js
This will register the /add command on your server using information you input into the config.json file.
Starting the Bot
After registering the commands on your server, you are ready to start up the bot! Don’t forget, that the command you are about to run will need to stay running 24/7 for the bot to grant and remove roles at the times you desire.
run “node trialbot-lowdb.js”
You should still be in the same folder where you ran the register command in your command line. From this same location, start the bot using the command node trialbot-lowdb.js
this will start the bot using a JSON database from the dependency lowdb. This means it’s super easy to get up and running and you do not need to worry about setting up a database separately.
trialbot-mysql.js
You will see that there is another option in the folder to run the bot using a mysql database. This is outdated at the moment and I am working to update it to work again. This is what you will want to wait for if you are going to be using this bot at a large scale. Reach out to me on Discord to let me know you’re interested!
Using the Bot
Now you are ready to use the /add command to add roles for a user for a certain amount of time
/add @role @user time type
For this command, after typing /add, you will need to supply the role that you want granted, the user you want it granted to, the number of time you want to give, and the type of time you want to give. For example, the command /add Jim Admin 1 hour would grant Jim the role “Admin” for 1 hour.
Walkthrough Videos
Coming Soon