This repository contains the source code for a Discord bot integrated with GitHub and Pieces OS Client SDK. Below are the instructions to set up and run the bot locally.
Before you begin, ensure you have the following installed:
- Node.js (version 18 or higher)
- npm or pnpm (as the package manager)
-
Clone the Repository
Start by cloning the repository to your local machine:
git clone https://github.com/mason-at-pieces/pieces-copilot-discord-bot.git cd pieces-copilot-discord-bot
-
Install Dependencies
Install the necessary Node.js dependencies using pnpm:
pnpm install
You need to set up several environment variables before running the bot. Create a .env
file in the root directory of the project and add the following variables:
DISCORD_BOT_TOKEN=your_discord_bot_token
DISCORD_CLIENT_ID=your_discord_client_id
PIECES_CLIENT_BASE_URL=your_pieces_client_base_url
GITHUB_PERSONAL_TOKEN=your_github_personal_token
Replace your_discord_bot_token
, your_discord_client_id
, your_pieces_client_base_url
, and your_github_personal_token
with your actual credentials.
-
Discord Bot Token and Client ID:
- Go to the Discord Developer Portal.
- Create a new application and navigate to the 'Bot' section to add a bot.
- Here you can find your Client ID and generate a new Bot Token.
-
Pieces Client Base URL:
- If you are on macOS or Windows, you can run the Pieces OS Client SDK locally and use
http://localhost:1000
as the base URL. - If you are on linux, you can run the Pieces OS Client SDK locally and use
http://localhost:5323
as the base URL. - This can also be a remote URL if you are using a hosted version of the Pieces OS Client SDK.
- If you are on macOS or Windows, you can run the Pieces OS Client SDK locally and use
-
GitHub Personal Token:
- Visit GitHub Tokens page.
- Generate a new token with the scopes of the repositories you want your bot to access.
To run the bot in development mode, use the following command:
pnpm dev
This will start the bot using nodemon, which will automatically restart the bot if you make any changes to the source code.
To compile the TypeScript code to JavaScript and prepare it for production, run:
pnpm build
This command compiles the code and outputs it to the dist
directory.
After building the project, you can start the bot in production mode:
pnpm start
This will run the compiled JavaScript code located in the dist
directory.
- Make sure to invite the bot to your Discord server using the appropriate OAuth2 URL, which can be generated in the Discord Developer Portal under the OAuth2 section.
- Configure the necessary permissions for the bot depending on what actions it needs to perform.
- TODO: Need to document the required permissions for the bot.
For further assistance or to report issues, refer to the repository's issues section or contact the repository maintainers.
By following these instructions, you should be able to get the Discord bot up and running smoothly in your development environment.