Developers Writing a plugin
How plugins run
What happens between a plugin file in the world and an answer in Discord. Your plugin never sees a Discord token, channel or role, and doesn't need to.
From the world to Discord
- Loading. When the world starts, BedrockRelay loads each plugin listed in
index.json its own. A plugin that throws or is missing is logged and skipped; the others, and the relay, carry on. - Reporting. BedrockRelay tells our service which plugins loaded and what they declare. It sends names, options and settings, never code.
- Switching on. A plugin is switched on the first time a world reports it. After that, the owner's switch on the dashboard decides. Its commands are registered only while it's on, and only in the Discord servers that world is connected to.
- Access. At first only Discord administrators can use a plugin's commands. The owner can add roles for each plugin.
- Running. When someone uses a command, BedrockRelay checks it's allowed, asks first if the command has
confirm, and sends it to the world. Yourrun()executes on the next game tick. - Answering. Whatever you return goes back to BedrockRelay, which cleans it up and shows it in Discord. See Answers and context.
No answer within about 12 seconds is shown to the person as the world being offline.
On a Realm
The steps are the same. A Realm can't reach the internet, so our bot, a hidden player in the Realm, carries each request to the world and the answer back. Your plugin can't tell the difference, apart from what Plugins on Realms describes.
Why it's built this way
Everything Discord lives on our side, so new plugin features usually need no pack update: since pack v0.4.0 the pack passes on everything your definition declares, and our service decides what it understands. That's why fields like board and postKinds could arrive without owners reinstalling anything.
For the same reason, plugin code only ever reaches a world as a file installed there. BedrockRelay never downloads and runs code at runtime.
Running a Minecraft world rather than building for one? The help covers everything from setup to troubleshooting.
Read the help