This bot has been created to fit the needs of the person who asked me to create it, here there are:
- Count the number of messages sent by users in the server
- Give rewards for certain messages counts
- Having rewards given for a certain message count in a specific channel
- Being able to edit rewards, as well as users' message counts.
- Being able to visualize those informations
There are two commands, both with several subcommands:
-
/rewards
- Manage rewards or get information about them-
manage
- Manage rewards-
create-or-edit
- Creates (or edits) a reward with the specified parameters
@param reward-role
- The role given as reward for a message count
@param required-message-count
- The required message count to get the reward
@param channel
- Optional. Reward for the specified channel (leave empty for a global reward) -
delete
- Deletes the specified reward
@param reward-role
- The role given as reward
@param channel
- Optional. Delete reward for the specified channel (leave empty for a global reward)
-
-
infos
- Infos about rewards-
find-by-role
- Shows you if a reward exists for a role, and if so, its required message count
@param reward-role
- Find a reward for this role
@param channel
- Optional. Delete reward for the specified channel (leave empty for a global reward) -
overview
- Shows you an overview of the rewards available
-
-
-
/sent-messages
- Manage sent messages or get information about them-
manage
- Manage sent messages-
set
- Sets the message count
@param target-user
- The user to edit
@param message-count
- The message count to set
@param channel
- Optional. Set message count in the specified channel (leave empty to edit global count) -
reset
- Resets the message count
@param target-user
- The user to reset
@param channel
- Optional. Reset message count in the specified channel (leave empty to reset globally)
-
-
infos
- Infos about sent messages-
by-user
- Shows you how many messages a user sent
@param target-user
- Show message count of the specified user -
average
- Shows you the average message count of active users
@param channel
- Optional. Average message count in the specified channel (leave empty for a global average)
-
-
This repo is the bot's source code, not a bot itself.
To use it, you must host it yourself. There are several methods to do this, some are free, some are paid (Be careful that your hosting solution allows file editing, sometimes called local database, otherwise all the bot's data will be lost if the server restarts).
Once you found the hoster for your bot, here are the steps to follow:
We will first create the bot :
- Go on Discord Developer Portal and login
- Click New Application, give your bot a name, accept the ToS and developer policy
- In the Installation tab, untick User Install, and in Install Link select None
- Copy the Application ID from the General Information tab, save it for later.
- Select tab Bot, click Reset Token, copy the token, save it for later.
- Cutomize the bot as you want (Profile picture, banner, name...). Below Authorization Flow, untick Public Bot, tick Server Members Intent and Message Content Intent
- Save changes.
- In the OAuth2 tab, in Scopes, select bot and application.commands, then tick the following permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Manage Roles
- Select Guild Install and copy the generated URL
- Follow this URL and add the bot to the server you want, accept everything, the bot should be added to your server !
- Once it's added, in your server settings, in the Roles tab, make sure that the role with the name of your bot is at the top of the list, otherwise it will not work.
Now, we can link the bot to the code, so you can start using it :
- You need to have Node.js installed on your machine.
- Download my code and extract it from the ZIP file (or clone the repo), open the folder where it's located, and open a terminal from here.
- Install the required packages and compile the code by executing the following command:
npm install && npm run build
- In the bot folder, open the config folder, then open config.json in any text editor, fill it with the informations you saved previously, like following:
{
"clientId": "[The Application ID you have saved]",
"token": "[The Token you have saved]",
"ephemeralAnswers": true
}
- Replace "true" by "false", if you want the answers of the bot to be visible to everyone.
Your Bot is ready to be uploaded on the hosting server ! The following steps may vary depending on your hosting solution.
- Upload the whole MessageCounter-main folder on the server.
- Create a routine for restarting the server. Such that the following command is executed from the bot's folder each time the server is restarted.
npm run start
- Open a terminal from the bot' folder and execute the following command :
npm run deploy /a
- Restart the server, or run the following command :
npm run start
All done ! You did it, your bot should be working perfectly ! If you have any problem with it, feel free to message me on Discord, or open an issue on Github
- Yet, I haven't implemented anything to prevent the user from setting a global message count smaller than the sum of the channel specific message counts.