
Excalibur is an event management Discord bot written in Node.js that leverages the Google API. It integrates seamlessly with Google Sheets to provide robust reminder functionalities.
Table of Contents
This guide walks you through the process of setting up the Excalibur Discord bot. Follow the steps carefully to ensure the bot is configured correctly and works seamlessly with Google Sheets and Discord.
Prerequisites
Before starting, ensure you have the following:
- A Google Cloud account
- A Discord account
- Node.js installed on your machine
Start by cloning the repository to your local machine:
git clone [email protected]:C-Teo/excalibur.git
Navigate to the root directory of the project and install all required modules:
npm install
To enable the bot to interact with Google Sheets, follow these steps:
- Go to the Google Cloud Console (https://console.cloud.google.com/).
- Create a new project by selecting Select a Project -> New Project.
- Once your project is created, go to API & Services and click on Enable API & Services.
- Search for Google Sheets API and enable it.
- On the Google Sheets API page, click Create Credentials.
- Select Service Account and choose Google Sheets API.
- Check Application Data and provide a name for the service account.
- Click Agree and Continue, then grant the service account IAM Editor access to the project.
- Click Done once the credentials are created.
- In the Credentials tab, click on the service account you just created.
- Under Keys, click Add Key, then select JSON.
- Name the file secrets.json.
- Create a folder named config in the root directory of the project and place the secrets.json file inside it.
- Open your Google Sheet.
- Share it with the service account email, which can be found in the Credentials tab of the Google Sheets API page.
- Give the service account view access (edit permissions are not needed).
Note: If you're having trouble with steps 3-6, refer to this video guide (https://youtu.be/zCEJurLGFRk?si=IhRPMxeZN3T2UXCA) (time: 1:56 - 8:30).
- Go to the Discord Developer Portal.
- Under Applications, create a new application and name it as desired.
- Go to the OAuth2 section and select Bot.
- Under Bot Permissions, give the bot all necessary text permissions.
- Enable Server Member Intent on the bot page.
In the root directory of the project, create a .env file with the following content:
DISCORD_TOKEN=""
CLIENT_ID=""
BOT_ID=
- DISCORD_TOKEN: The bot token you get from the Discord Developer Portal.
- CLIENT_ID: The application ID found under General Info in the Discord Developer Portal.
- BOT_ID: The bot ID found under the Bot section in the Discord Developer Portal.
In the .env file, set the following values:
- SHEET_URL: The URL of your Google Sheet.
- SHEET_RANGE: The range you wish to interact with (e.g., Sheet1!A1:B10).
Run the following command to deploy your Discord bot commands:
node src/utils/deploy-commands.js
- Start the Bot Once everything is set up, run the bot:
node src/index.js
You might wonder why you need to run the bot on your own server instead of using a pre-configured one. The reason is that a service account provides several benefits:
- Persistent access without the need for user login.
- Server-side authentication without manual OAuth token refresh.
- Ideal for background and automated tasks.
Since the bot requires access to your Google Sheets via a service account, it would be insecure to have someone else manage your credentials. Running the bot yourself ensures that your credentials remain secure.
If you encounter any issues, ensure that all steps are followed carefully, particularly the configuration of Google Sheets API and Discord bot permissions.
Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.
For more examples, please refer to the Documentation
- Set up Dynamic GSheet Configuration
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.