Developers Writing a plugin
Your first plugin
A plugin is one JavaScript file that adds Discord commands to a Minecraft world. BedrockRelay does the Discord side; you write what happens in the game.
The file
A plugin default-exports a definition: who it is, and the Discord commands it adds, each with a run(). This one adds /health:
// health.js
import { findPlayer } from "../relay/api.js";
export default {
id: "health",
name: "Health",
version: "1.0.0",
description: "Check a player's health from Discord.",
commands: [
{
name: "health",
description: "Show a player's health",
options: [{ name: "player", type: "player", description: "The player's name", required: true }],
run({ player: name }) {
const player = findPlayer(name);
if (!player) return `**${name}** isn't online right now.`;
const health = player.getComponent("minecraft:health");
return { embed: { title: player.name, description: `❤ ${Math.ceil(health.currentValue)} / ${health.effectiveMax}` } };
},
},
],
};
Inside run() you have the whole Minecraft Script API, and a few helpers from ../relay/api.js. Whatever you return is the answer in Discord.
Trying it
You need a Bedrock Dedicated Server of your own with BedrockRelay installed (pack v0.3.0 or newer) and connected to a Discord server.
- Put
health.jsindevelopment_behavior_packs/BedrockRelay/scripts/plugins/. - Add its name, without
.js, to the list inscripts/plugins/index.jsin the same folder:export default ["health"]; - Restart the Minecraft server. The console shows
[BedrockRelay] plugin loaded: Health 1.0.0. If it doesn't, see Testing. - In a connected Discord server, run
/health. The plugin is switched on the first time the world reports it, and at first only Discord administrators can use it.
Updating the BedrockRelay pack never touches your files in scripts/plugins/, and keeps your entries in index.js.
A Realm has no files you can reach, so plugins get there only through the dashboard. To try yours on a Realm, upload it as a private plugin. See Plugins on Realms first.
Where next
- Plugin reference: every field, and the options a command can take.
- Answers and context: embeds, player heads, pictures, and who asked.
- Best practices: read these before you share a plugin with anyone.
Running a Minecraft world rather than building for one? The help covers everything from setup to troubleshooting.
Read the help