|
1 | 1 | # Bytebot Discord Gateway
|
2 | 2 |
|
3 |
| -[Add Bytebot to your Discord server!](https://discord.com/api/oauth2/authorize?client_id=853394505625632768&permissions=67584&scope=bot) |
| 3 | +[](https://github.com/bytebot-chat/gateway-discord/actions/workflows/docker_build.yaml) |
| 4 | + |
| 5 | +[](https://goreportcard.com/report/github.com/bytebot-chat/gateway-discord) |
| 6 | +[](https://pkg.go.dev/github.com/bytebot-chat/gateway-discord) |
| 7 | + |
| 8 | +## Table of Contents |
| 9 | +- [Introduction](#introduction) |
| 10 | +- [Installation](#installation) |
| 11 | + - [Prerequisites](#prerequisites) |
| 12 | + - [Docker](#docker) |
| 13 | + - [Docker-Compose](#docker-compose) |
| 14 | + - [Manual](#manual) |
| 15 | +- [Usage](#usage) |
| 16 | + - [Configuration](#configuration) |
| 17 | +- [Contributing](#contributing) |
| 18 | +- [License](#license) |
| 19 | +- [Acknowledgements](#acknowledgements) |
| 20 | + |
| 21 | +## Introduction |
| 22 | + |
| 23 | +_A simpler way to write Discord bots._ |
| 24 | + |
| 25 | +Bytebot is a message-passing framework designed to make it easier to write bots for multiple platforms. This repository contains the Discord gateway, which allows you to connect to the Discord API present a single interface to your bot while you run as many applications and services as you like, in any language, without having to worry much about the underlying platform. This particular repository is the gateway for Discord. |
| 26 | + |
| 27 | +This tool is not a complete working bot on its own. The gateway is responsible for authenticating and managing a connection to Discord while passing messages to and from your bot. You will need to write your own bot to take advantage of this gateway. You can see an example of a bot written in Go [here](examples/pingpong/main.go). |
| 28 | + |
| 29 | +Because messages are JSON-encoded, you can write your bot in any language you like. You can even write multiple bots in different languages and run them all at the same time. You can also run multiple instances of the same bot, each with a different configuration, if you like. The only requirement is that your bot can read and write JSON-encoded messages to standard input and output. |
| 30 | + |
| 31 | +Here is an example of a python implementation of a bot that responds to the `ping` command with `pong`: [bytebot-chat/examples/py-pingpong](examples/py-pingpong/pingpong.py) |
| 32 | +## Installation |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | +- Redis server (for pub/sub) |
| 36 | +- Docker (optional, required for docker or docker-compose) |
| 37 | +- Golang (optional, required for building from source) |
| 38 | +- A Discord bot token (see [here](https://discord.com/developers/docs/intro) for more info) |
| 39 | + |
| 40 | +### Docker |
| 41 | + |
| 42 | +The easiest way to get started is to use the Docker image. You can find the image on the Github Container Registry [here](https://github.com/bytebot-chat/gateway-discord/pkgs/container/gateway-discord). It is strongly recommended that you pull either the `main` or `edge` tag, as these are the most up-to-date versions of the gateway. Semver tags are only updated when a new release is made but are not guaranteed to be the most up-to-date version. However, they are guaranteed to be more stable. |
| 43 | + |
| 44 | +### Docker Compose |
| 45 | + |
| 46 | +The easiest way to get started for development or just poking around is to use the provided [example docker-compose file](docker-compose-example.yaml). This file will start the gateway and a Redis server used for pub/sub and is required for the gateway to function. You will also need to provide your Discord bot token in the args section of the gateway service in the `docker-compose-example.yml` file. You can see your existing apps and retrieve your Discord bot token here [here](https://discord.com/developers/applications). |
| 47 | + |
| 48 | +1. Copy the `docker-compose-example.yml` file to `docker-compose.yml` |
| 49 | +2. Edit the `docker-compose.yml` file and replace the `YOUR_DISCORD_BOT_TOKEN` placeholder with your Discord bot token |
| 50 | +3. Run `docker-compose up -d` to start the gateway and Redis server. |
| 51 | + |
| 52 | +From this point you can connect to the redis pubsub to watch for messages from the gateway or connect an app. Try running one of the apps in [`examples/`](examples/) to see how it works. |
| 53 | + |
| 54 | +### Manual |
| 55 | + |
| 56 | +If you would like to install the gateway manually, you can do so by cloning this repository and running `go build` in the root directory. You will need to have Go installed on your system. You can find instructions for installing Go [here](https://golang.org/doc/install). |
| 57 | + |
| 58 | +You may also install the gateway using `go get`: |
| 59 | + |
| 60 | +```bash |
| 61 | +go get github.com/bytebot-chat/gateway-discord |
| 62 | +``` |
| 63 | + |
| 64 | +To install a specific version, you can use the `@` symbol to specify a version: |
| 65 | + |
| 66 | +```bash |
| 67 | +go get github.com/bytebot-chat/ [email protected] |
| 68 | +``` |
| 69 | + |
| 70 | +## Usage |
| 71 | + |
| 72 | +### Configuration |
| 73 | + |
| 74 | +The gateway can currently only be configured by CLI flags. The following table shows the available configuration options: |
| 75 | + |
| 76 | +| Flag | Description | Default | |
| 77 | +| --- | --- | --- | |
| 78 | +| redis | The address of the Redis server | `localhost:6379` | |
| 79 | +| rpass | The password for the Redis server | `""` | |
| 80 | +| token | The Discord bot token | `""` | |
| 81 | +| id | The ID of the Discord bot | `""` | |
| 82 | +| inbound | The channel to listen for inbound messages on | `discord-inbound` | |
| 83 | +| outbound | The channel to publish outbound messages to | `discord-outbound` | |
| 84 | +| verbose | Whether to print verbose logs | `false` | |
| 85 | + |
| 86 | +## Contributing |
| 87 | + |
| 88 | +If you would like to contribute to this project, please see the [contributing guidelines](CONTRIBUTING.md). |
| 89 | + |
| 90 | +## License |
| 91 | + |
| 92 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. |
| 93 | + |
| 94 | +## Acknowledgements |
| 95 | + |
| 96 | +- @m-242 and @parsec for endless code review, suggestions, and tolerating me blowing up their Discord servers with test messages. |
| 97 | +- @drewpearce for early iterations and inspiration for the project from a prior project, [Legobot/Legobot](https://github.com/Legobot/). |
| 98 | +- Several unnamed friends for their adversarial testing and feedback. |
0 commit comments