Skip to content

Commit 081c937

Browse files
authored
Add README (#24)
1 parent 4f2da8e commit 081c937

File tree

3 files changed

+98
-3
lines changed

3 files changed

+98
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*.yaml
2-
*.md # I like to write notes sometimes
2+
*.md
33
.vscode
44
*.json
55
*.sh

README.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
11
# Bytebot Discord Gateway
22

3-
[Add Bytebot to your Discord server!](https://discord.com/api/oauth2/authorize?client_id=853394505625632768&permissions=67584&scope=bot)
3+
[![Docker Build and Push](https://github.com/bytebot-chat/gateway-discord/actions/workflows/docker_build.yaml/badge.svg?branch=0.0.1)](https://github.com/bytebot-chat/gateway-discord/actions/workflows/docker_build.yaml)
4+
![Latest Release](https://img.shields.io/github/v/release/bytebot-chat/gateway-discord?sort=semver)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/bytebot-chat/gateway-discord)](https://goreportcard.com/report/github.com/bytebot-chat/gateway-discord)
6+
[![Go Reference](https://pkg.go.dev/badge/github.com/bytebot-chat/gateway-discord.svg)](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.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626
redisPass = flag.String("rpass", "", "Redis password")
2727
id = flag.String("id", "discord", "ID to use when publishing messages")
2828
inbound = flag.String("inbound", "discord-inbound", "Pubsub queue to publish inbound messages to")
29-
outbound = flag.String("outbound", *id, "Pubsub to subscribe to for sending outbound messages. Defaults to being equivalent to `id`")
29+
outbound = flag.String("outbound", "discord-outbound", "Pubsub to subscribe to for sending outbound messages. Defaults to being equivalent to `id`")
3030
verbose = flag.Bool("verbose", false, "Enable verbose logging")
3131
)
3232

0 commit comments

Comments
 (0)