A Discord bot designed to identify AI-generated text, promoting transparency and authenticity in conversations.
Collaborators: Nick Ching (nc2935), Naren Loganathan (nl2878), Suwei Ma (sm5011), Avery Fan (mf3332) Contributions + Tasks:
BotBuster is a Discord bot that utilizes the Veritas backend service. At its core, this bot aims to help identify bots/users generating messages using AI within various Discord groups. Please feel free to view Veritas at the following link.
Our client application is essentially a simple Discord Bot - our bot will simply make an HTTP call to Veritas. Once the request has been processed, the bot will return a relevant response in chat.
BotBuster is an instructive example of an implementation of the Veritas service. At its core, BotButser simply checks every message sent in a discord group chat.
To run this bot, ensure you have the following installed:
- Python 3.8 or higher
- Discord Developer Token
.env
file with the following environment variables:
DISCORD_BOT_TOKEN=your_discord_bot_token
VERITAS_URL=http://34.70.245.192:8080 # (or) http://localhost:8080 if hosting Veritas locally
- Clone the repository:
git clone https://github.com/nick-ching23/BotBuster.git veritas-discord-bot
cd veritas-discord-bot
- Create a .env file in the root directory:
DISCORD_BOT_TOKEN=your_discord_bot_token
VERITAS_URL=http://34.70.245.192:8080 # (or) http://localhost:8080 if hosting Veritas locally
- Install dependencies (we recommend doing this within a Python virtual environment):
pip install -r requirements.txt
- Run the bot locally:
python app.py
1. Add Veritas to Your Guild
Option 1 [Easier] - Use a bot hosted by us:
We have app.py
running on a configured GCP VM. Add our Discord bot to your guild using the following link: Invite Veritas to Your Guild
Option 2 - Run your own bot:
To run your own instance of the bot, a discord bot token is necessary.
If you don't have a bot token, you can obtain one by following these steps:
- Go to the Discord Developer Portal: https://discord.com/developers/applications
- Log in with your Discord account, or create an account if you don't have one
- Click on 'New Application' to create a new bot.
- Give your application a name and click 'Create'.
- Navigate to the 'Bot' tab on the left sidebar and click 'Add Bot'.
- Once the bot is created, you will find a 'Token' section. Click 'Reset Token' to generate a new token.
- Copy the generated token securely. Set the value of
DISCORD_BOT_TOKEN
to this token in your.env
file and follow steps 2 to 4 from the previous section!
To invite the bot:
- Navigate to the 'OAuth2' tab, then to 'URL Generator'.
- Under 'Scopes', select 'bot'.
- Under 'Bot Permissions', select the permissions your bot will need (e.g., 'Send Messages', 'Read Messages' for our bot use)
- Copy the generated URL and paste it into your browser to invite the bot to your server.
To grant the bot permissions:
- Navigate to the 'Bot' tab
- Under 'Privileged Gateway Intents', check 'Server Members Intent' and 'Message Content Intent'.
For more details, you can also check the official Discord bot documentation: https://discord.com/developers/docs/intro
2. Receive Your Guild ID
Once Veritas is added to your guild, it will automatically generate a Guild ID. This unique ID is required for registration.
3. Register Your Organization via Postman
Use Postman to register your organization. Run the following command:
This step ensures your guild is registered in our system, allowing the Veritas API to interact with messages from your guild.
4. Start Monitoring with Veritas
To start monitoring messages in your guild, use the following command in Discord:
@Veritas start monitoring
4. Just type messages
From now, the system will automatically check each message to determine if it was generated by generated AI or not.
5. Stop Veritas Monitoring
To stop monitoring messages in your guild, use the following command in Discord:
@Veritas stop monitoring
Our testing has largely been driven by user-testing. As a discord bot, we implemented some basic unit tests to ensure that the bot correctly starts and stops monitoring.
Testing can be accomplished by following the above instructions and entering the following command:
pytest test_bot.py
Results
Note that the warning is from a package used by discord. This is out of our hands
End-to-end testing can be done manually by performing the following steps:
-
Make sure that no other applications run on ports like 8080 and 5000 on your system (ignore this if you aren't running the bot, service or ML microservice locally).
-
Run the service portion of the system: Refer to this section if you would like to run the service locally. Note that running the service locally also requires you to set up a SQL database and an instance of the ML microservice. Alternatively, you can interact with a running instance of our service by referring to this.
-
Run the client portion of the system: Refer to the previous sections for instructions on how to build and run the bot. If you're creating and hosting your own bot instance, make sure that you point
VERITAS_URL
in the.env
appropriately (depending on whether your service in question is a local one or not). -
Invite the client (discord bot) to your discord server - again, follow the steps from the section on activation.
-
Now, send messages in chat (*Note that the ML microservice is still being tweaked - it's a work in progress):
e.g. a ChatGPT response to write a haiku about yourself
e.g. my response to Nick wasn't flagged
e.g. messages with attachments are ignored