-
Notifications
You must be signed in to change notification settings - Fork 9
Setup CodeGrind Bot Locally
To set up a testing version of the bot, you need to follow the steps ahead:
-
Create a Discord application: Visit Discord developers applications and create an application.
-
Add bot: Substitute
<YOUR_BOT_CLIENT_ID>with your application's client id in the link below and press the link to add it to your selected server.
Make sure to also select all the 'Privileged Gateway Intents' on the Bot page.
https://discord.com/oauth2/authorize?client_id=<YOUR_BOT_CLIENT_ID>&scope=bot&permissions=8
-
Create a MongoDB database: Go to MongoDB, create a database, get the MongoDB URI (connection string), and add your IP address to the IP access list in the network access tab.
-
Create a .env file: Within the project's root directory, create a
.envfile and add the environment variables given below. Replace<your_discord_bot_token>and<your_mongodb_uri>with your specific values.DISCORD_TOKEN=<your_discord_bot_token> MONGODB_URI=<your_mongodb_uri> TOPGG_TOKEN=null LOGGING_CHANNEL_ID=<the_channel_id_to_log_to> DEVELOPER_DISCORD_ID=<your_discord_account_id> PRODUCTION=False
-
Python version: Ensure Python version
3.11or later is installed on your computer. -
Setup a virtual environment: Install the Python
venvmodule and set up a virtual environment. Here are the instructions for setting up a Python's virtual environment.
Make sure to call your virtual environment either
.venvorvenvwhen creating it, so that it is correctly ignored and not added to your commits.
To activate the virtual environment, navigate to the directory where the virtual environment is located and run the following commands:
-
For Windows:
.\env\Scripts\activate -
For Unix or macOS:
source env/bin/activate
-
Install required libraries: With the virtual environment activated, install all the necessary libraries using the following pip commands:
pip install -r requirements.txt python -m playwright install
-
Run the bot: With all the setup complete, run the following command (from the root directory of the project):
python -m src.mainThe first time you run the bot, you will also need to write and send a message within a channel in the server your local bot is in that pings your bot and says "sync" (e.g. "
@CodeGrind Botsync") in order to sync and see all of your bot's commands. This only needs to be done when the bot is setup initially, or when new commands are implemented.After you've synced the commands, make sure to restart Discord.
Whilst the program is running, you should now be able to execute bot commands on your server.