Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Discord bot to streamline running D&D 5e.

License

NotificationsYou must be signed in to change notification settings

avrae/avrae

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Avrae Website

Build Status

Avrae is a Discord bot designed to help you and your friends play D&D online.

You can join the Avrae Development Discordhere, and invite Avrae to your own Discordserverhere!

Key Features

Advanced Dice Roller

With a custom dice parser, Avrae is one of the most advanced dice rollers on Discord, capable of supporting pretty muchevery type of roll needed to play D&D. Advantage, disadvantage, and crits are built in, you can keep, drop, or rerolldice as needed, dice can explode, and dice can be bounded.

Want to use the dice roller in your own code? Check outthe code!

Character Sheet Integration

Avrae can read character sheets from D&D Beyond, Dicecloud, or a Google Sheet, automatically generating macros to rollattacks, ability checks, and saving throws. A player can then simply use a command to make a check, save, attack, orcast, and all necessary rolls will be resolved automatically.

Initiative Tracking

The initiative tracker is a fast way to track combat in a text channel. It supports automatic combatant sorting, HP, AC,resistance, and status effect tracking, and integration with the character sheet manager and 5e content to furtherstreamline combat.

Moddability

Have a feature in mind that isn't already in Avrae? Avrae provides a fully-featured modding API to write your owncommands, and a place to share them with the community!

Check outthe docs and theAlias Workshop!

Contributing

There are a few options to run Avrae locally. Docker is easier to get started with with less managment of dependencies,but slower and more resource-intensive.

Using Docker (Recommended)

Check outREADME-docker.md.

Building Manually

Dependencies

Services/OS

Support Files

You'll need to create a Google Drive Service Account. You can find instructions on how to dothishere.

Follow steps 1-7 in theFor Bots: Using Service Account portion. Rename the JSONavrae-google.json and put it inthe project root.

Python Packages

We recommend using aVirtual Environment for Avrae development to preventpackage installs from polluting the global Python install. You can create and active a virtual environment by running:

$ python3 --version# to ensure that you are creating a venv from the right python version$ python3 -m venv venv$source venv/bin/activate# if the venv was set up correctly, you should see (venv) before your username in the terminal# run these commands to check the installed version and path(venv) $ python --versionPython 3.X.X(venv) $ pip --versionpip X.Y.Z from (project root)/venv/lib/python3.X/site-packages/pip (python 3.X)

To install the dependencies, run:

(venv) $ pip install -r requirements.txt

Optional - You can install theavrae-automation-common anddraconic dependencies from your local filesystemrather than pip+git, to make working on depended libraries in parallel easier:

(venv) $ pip install /path/to/automation-common -e(venv) $ pip install /path/to/draconic -e

Any changes to the library will immediately be picked up in avrae without requiring a reinstall of the library.

Environment Variables

NameDescriptionUsed ForSet By (dev)Set By (prod)Required?
DISCORD_BOT_TOKENThe bot token used to authenticate to the Discord API. See "Discord Bot Token", below.Connecting to the Discord APIyouAWS Secrets Manager via Terraformyes
TESTINGWhether the bot is running in a dev environment. See "Testing Env Var", below. Also set iftest arg supplied in CLI.Enabling certain debug logsyouN/Ano
ENVIRONMENTThe environment the bot is running in. Defaults todevelopment ifTESTING is set, orproduction otherwise.Logs (e.g. Datadog)set todevelopmentTerraformyes
GIT_COMMIT_SHAThe commit SHA of the running deploy.Cluster coordination keyN/ADocker via GH Actionsprod only
NUM_CLUSTERSThe number of clusters (ECS tasks) Avrae is running across. Defaults to 1.Cluster coordinationN/ATerraformprod only
NUM_SHARDSAn explicit override for the number of shards to run across all shards. Defaults to dynamic value from Discord.Cluster coordinationN/ATerraform (nightly/stg)no
RELOAD_INTERVALAn interval to automatically reload gamedata at, in seconds. Defaults to 0. This should be set to 0.Loading gamedataN/AN/Ano
ECS_CONTAINER_METADATA_URIhttps://docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v3-fargate.htmlCluster coordinationN/AAWS Fargateprod only
MONSTER_TOKEN_ENDPOINTThe base URL that monster token paths defined in monster gamedata are relative to.!tokenN/ATerraformprod only
DDB_MEDIA_S3_BUCKET_DOMAINThe S3 bucket domain for DDB media assets, such as character avatars.!tokenN/ATerraformprod only
DRACONIC_SIGNATURE_SECRETThe secret used to sign signatures in the Draconic API'ssignature() function. Defaults tosecret.AliasingoptionalAWS Secrets Manager via Terraformprod only
MONGO_URLThe connection URL used to connect to MongoDB. Defaults tomongodb://localhost:27017.Connecting to databaseyouAWS Secrets Manager via Terraformyes
MONGODB_DB_NAMEThe name of the database in Mongo to use. Defaults toavrae.Connecting to databaseoptionalTerraformno
REDIS_URLThe connection URL used to connect to Redis. Defaults toredis://localhost:6379/0.Connecting to databaseyouTerraformyes
REDIS_DB_NUMThe database number to use in Redis. Defaults to0.Connecting to databaseoptionalTerraformno
DEFAULT_PREFIXThe default command prefix. Defaults to!.Running commandsoptionalTerraformno
DD_SERVICEThe name of the service, used for DataDog. If not set, disables DataDog tracing and profiling.MonitoringoptionalTerraformprod only
NO_DICECLOUDIf set, disables Dicecloud v1 connections in the running bot. Defaults to true ifDICECLOUD_USER is not set.CIoptionalN/Ano
DICECLOUD_USERTheDicecloud v1 username of the bot account.Sheet ImportyouTerraformyes
DICECLOUD_PASSThe Dicecloud v1 password of the bot account.Sheet ImportyouAWS Secrets Manager via Terraformyes
DICECLOUD_TOKENThe Dicecloud v1 API key of the bot account.Sheet ImportyouAWS Secrets Manager via Terraformyes
NO_DICECLOUDV2If set, disables Dicecloud v2 connections in the running bot.CIoptionalN/Ano
DCV2_NO_AUTHIf set, connects to Dicecloud v2 without any form of authentication. As such, any imported sheets must be public. Defaults to true ifDICECLOUDV2_USER is not set.CIoptionalN/Ano
DICECLOUDV2_USERTheDicecloud v2 username of the bot account.Sheet ImportyouTerraformyes
DICECLOUDV2_PASSThe Dicecloud v2 password of the bot account.Sheet ImportyouAWS Secrets Manager via Terraformyes
GOOGLE_SERVICE_ACCOUNTThe contents of theGoogle Drive Service Account JSON key file. Defaults to a file namedavrae-google.json if not set.Sheet ImportyouAWS Secrets Manager via Terraformyes
DDB_AUTH_SECRETThe secret used to sign JWT claims to exchange Discord user info for a STT via the Auth Service.Entitlements1PasswordAWS Secrets Manager via TerraformDDB team only
DDB_AUTH_WATERDEEP_SECRETThe secret used to verify JWTs returned from the Auth Service.Entitlements1PasswordAWS Secrets Manager via TerraformDDB team only
DDB_AUTH_AUDIENCEOverride a verification for theaud claim of an Auth Service JWT. Defaults toavrae.io.EntitlementsN/AN/Ano
DDB_AUTH_ISSUEROverride a verification for theiss claim of an Auth Service JWT. Defaults todndbeyond.com.EntitlementsN/AN/Ano
DDB_AUTH_EXPIRY_SECONDSOverride a JWT's lifetime for the Discord -> STT exchange. Defaults to 5 minutes (300).EntitlementsN/AN/Ano
DDB_AUTH_SERVICE_URLThe base URL for requests to the DDB Auth Service. If not set, all entitlements code is disabled.Entitlements1PasswordTerraformDDB team only
DYNAMO_REGIONThe AWS region to search for resources in. This controls more than Dynamo. Defaults tous-east-1.Entitlements1PasswordTerraformDDB team only
DYNAMO_ENTITLEMENTS_TABLEThe name of the DynamoDB table to query for entitlements data. Defaults toentitlements-live.Entitlements1PasswordTerraformDDB team only
AWS_ACCESS_KEY_IDThe AWS Access Key ID to connect to AWS resources.Entitlements1PasswordAWS FargateDDB team only
AWS_SECRET_ACCESS_KEYThe AWS Secret Access Key to connect to AWS resources.Entitlements1PasswordAWS FargateDDB team only
NLP_KINESIS_DELIVERY_STREAMThe name of the AWK Kinesis Firehose delivery stream used to ingest NLP events.UPenn NLPN/ATerraformno
CHARACTER_COMPUTATION_ENDPOINTThe API endpoint used to call the Character Computation lambda.Sheet ImportyouTerraformDDB team only
DDB_WATERDEEP_URLThe base URL for requests to the Waterdeep monoloth. Defaults tohttps://www.dndbeyond.com.Campaign Link1PasswordTerraformno
DDB_GAMELOG_ENDPOINTThe endpoint used to post Game Log events to the Game Log. Defaults tohttps://game-log-rest-live.dndbeyond.com/v1.Campaign Link1PasswordTerraformno
DDB_CHARACTER_SERVICE_URLThe base URL for requests to the Character Service. Defaults tohttps://character-service.dndbeyond.com/character/v5.Campaign Link1PasswordTerraformno
DDB_SCDS_SERVICE_URLThe base URL for requests to the Simple Character Data Store. Defaults tohttps://character-service-scds.dndbeyond.com/v2.Campaign Link1PasswordTerraformno
LAUNCHDARKLY_SDK_KEYTheLaunchDarkly SDK Key.Feature Flags1PasswordAWS Secrets Manager via TerraformDDB team only
DBL_TOKENThe Discord Bot List API token.Updating server countN/AAWS Secrets Manager via Terraformno

Discord Bot Token

To create a Discord bot user, go to theDiscord Developer Portal.

  • New Application, give it a cool name,Create.
  • Bot >Add Bot.
  • (Optional but recommended): Switch offPublic Bot so only you can add this bot to servers.
  • Scroll down toPrivileged Gateway Intents, and enable the switches to the right ofServer Members IntentandMessage Content Intent.
  • Click to Reveal Token, this is yourDISCORD_BOT_TOKEN.

Testing Env Var

TheTESTING env var, if present, enables/disables the following:

  • Dicecloud Client: Meteor debug logs enabled
  • cogs.publicity: Discord Bot List update disabled
  • config:ENVIRONMENT set todevelopment by default if not manually set
  • Discord Application Commands: enables command sync debug logs and command testing guilds

Running

(venv) $ python dbot.pytest
VSCode launch.json Template
  {"version":"0.2.0","configurations": [      {"name":"Run Avrae","type":"python","request":"launch","program":"dbot.py","console":"integratedTerminal","env": {"DISCORD_BOT_TOKEN":"","DISCORD_OWNER_USER_ID":"","DICECLOUD_USER":"","DICECLOUD_PASS":"","DICECLOUD_TOKEN":"","DICECLOUDV2_USER":"","DICECLOUDV2_PASS":"","MONGO_URL":"","REDIS_URL":"","ENVIRONMENT":"","DDB_AUTH_SECRET":"","DYNAMO_REGION":"","DYNAMO_ENTITLEMENTS_TABLE":"","DDB_AUTH_SERVICE_URL":"","AWS_ACCESS_KEY_ID":"","AWS_SECRET_ACCESS_KEY":"","DDB_AUTH_WATERDEEP_SECRET":"","CHARACTER_COMPUTATION_ENDPOINT":"","DDB_WATERDEEP_URL":"","DDB_GAMELOG_ENDPOINT":"","DDB_CHARACTER_SERVICE_URL":"","DDB_SCDS_SERVICE_URL":"","LAUNCHDARKLY_SDK_KEY":""        }      }    ]  }

Testing

This repo contains a pytest test suite that mocks a number of interactions between Avrae and the Discord API, and runsend-to-end tests between user input, bot output, and database state.

These tests can be found intests/.

Dependencies

(venv) $ pip install -r tests/requirements.txt

Running

Tests can either be run using Docker Compose, or manually.

Docker

docker-compose -f docker-compose.ci.yml -p avrae up -d --builddocker logs -f avrae_tests_1

Once tests complete, it is recommended to clean up the containers withdocker-compose down.

Manually

(venv) $ TESTING=1 pytest tests/

In either case, you should setNO_DICECLOUD=1.

Docs

Avrae uses Sphinx to generate documentation for the Aliasing API and Automation Engine. The source for thisdocumentation can be found indocs/.

By default, each push tomaster will trigger a new build of the docs athttps://avrae.readthedocs.io/en/latest/.

You can also build the docs manually:

# install dependencies(venv) $cd docs(venv) $ pip install -r requirements.txt# build and open browser(venv) $ make preview# build(venv) $ make html

Committing, Formatting, and Linting

Avrae usesBlack to format and lint its Python code.Black is automatically run on every commit via pre-commit hook, and takes its configuration options from thepyproject.toml file.

The pre-commit hook is installed by by runningpre-commit install from the repo root.The hook's configuration is governed by the.pre-commit-config.yaml file.

Dependencies

In order to runpre-commit orblack, they must be installed.These dependencies are contained within thetest/requirements.txt file, and can be installed like so:

(venv) $ pip install -r test/requirements.txt

[8]ページ先頭

©2009-2025 Movatter.jp