Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itzg/discord-github-melder-bot
Discord bot that provides a command for users to link their Github user and apply contributor role
https://github.com/itzg/discord-github-melder-bot
discord-bot github
Last synced: 16 days ago
JSON representation
Discord bot that provides a command for users to link their Github user and apply contributor role
- Host: GitHub
- URL: https://github.com/itzg/discord-github-melder-bot
- Owner: itzg
- Created: 2022-01-17T02:00:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-07T11:22:08.000Z (about 1 month ago)
- Last Synced: 2024-10-12T18:53:35.464Z (about 1 month ago)
- Topics: discord-bot, github
- Language: Java
- Homepage:
- Size: 186 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is a Discord bot that provides an application command for Discord users to link their Github user and automatically apply a contributor role to those users that have contributed to the configured repositories.
# Installation
## [Create Discord application](https://discord.com/developers/applications)
Go to the Bot section and create a bot there.
When generating the application invite URL, enable the scopes
- bot
- Manage Roles
- applications.commandsThe generated URL should end with `permissions=268435456&scope=bot%20applications.commands`
Add a role named "Contributor" to servers that the bot will join and **make sure the bot's role is higher than the "Contributor" role**.
## [Create Github OAuth2 application](https://github.com/settings/developers)
- Generate a client secret
- Set "Authorization callback URL" to the base URL of your bot with the path `/login/oauth2/code/github`## Optional: [Generate personal access token](https://github.com/settings/tokens)
If you would like the bot to install a webhook into each Github repository, allocate a personal access token with the scope
- `admin:repo_hook`It can be given a very short expiration since it is only needed during initial setup and any time more repositories are added to the configuration.
## MongoDB
**Version:** 4.x
**Database:** discord-github-melder
> **INFO** Database can be created from mongo CLI with `use discord-github-melder`
Create user for the bot application's access, such as:
```
db.createUser({
user: "dev",
pwd: "dev",
roles: ["readWrite"]
})
```## Configure container
### Image
[`ghcr.io/itzg/discord-github-melder-bot:{tag}`](https://github.com/itzg/discord-github-melder-bot/pkgs/container/discord-github-melder-bot)
### Ports
- `8080` : For HTTP requests
### Environment Variables
> **WARNING** Be sure to securely declare application IDs and tokens
| Variable | Required | Description |
|----------------------------|----------|--------------------------------------------------------------------------------|
| GITHUB_CLIENT_ID | Yes | Github OAuth2 client ID |
| GITHUB_CLIENT_SECRET | Yes | Github OAuth2 client secret |
| MONGO_HOST | Yes | |
| MONGO_USERNAME | Yes | A user with read/write, create collection/index permissions |
| MONGO_PASSWORD | Yes | |
| APP_DISCORD_APPLICATION_ID | Yes | From `https://discord.com/developers/applications/{id}/information` |
| APP_DISCORD_BOT_TOKEN | Yes | From `https://discord.com/developers/applications/{id}/bot` |
| APP_GITHUB_REPOS | Yes | Comma-separated list of `{org}/{name}` |
| APP_BASE_URL | Yes | Publicly accessible URL that is routed to this container. |
| APP_GITHUB_ACCESS_TOKEN | No | Personal access token used at startup to install missing webhook declarations. |
| APP_GITHUB_WEBHOOK_SECRET | No | If set, the installed webhook will use the given secret for signing calls. |
| LOGGING_LEVEL_APP | No | Change application logging level, such as `debug` |There are more optional, lower priority properties declared [here](src/main/java/me/itzg/melderbot/config/AppProperties.java).