Developers Other addons

Script events

Any behaviour pack in a world running BedrockRelay can post to Discord by firing a script event. No plugin, no dependency, and nothing to install beyond BedrockRelay itself.

The three events

EventDirectionPurpose
discord:messageYour addon → DiscordA plain text message.
discord:embedYour addon → DiscordA rich Discord embed.
discord:readyBedrockRelay → your addonTells you BedrockRelay is in the world and connected.

They work on dedicated servers and Realms alike, with every pack version.

discord:message

The event's message is a JSON string: build an object and pass it through JSON.stringify.

FieldTypeDescription
messagestring, requiredThe text to post. Discord markdown works.
authorstringThe name the post appears under. Defaults to the world's name.
picturestring (URL)An image link for the post's avatar.
import { system } from "@minecraft/server";

system.sendScriptEvent("discord:message", JSON.stringify({
  author: "Treasure Hunt",
  message: "**Steve** found the golden chest at the old lighthouse!",
}));

discord:embed

Takes embed (a Discord embed object, required), plus author and picture as above.

system.sendScriptEvent("discord:embed", JSON.stringify({
  author: "Weekly Leaderboard",
  embed: {
    title: "Most blocks mined this week",
    color: 0x5de0c7,
    fields: [
      { name: "1. Alex", value: "12,408", inline: true },
      { name: "2. Steve", value: "9,771", inline: true },
    ],
  },
}));

Discord's embed limits apply, such as 256 characters for a title and 25 fields. Bedrock limits a script event's message to 2,048 characters, so keep embeds compact.

discord:ready

BedrockRelay fires discord:ready when it connects, and again each time it reconnects. On a Realm, that's when our bot arrives in the world. The message is always {}. Subscribe when your script loads and you'll hear it:

let discordAvailable = false;

system.afterEvents.scriptEventReceive.subscribe((event) => {
  if (event.id === "discord:ready") discordAvailable = true;
});

You don't have to wait for it before sending. On a dedicated server, messages sent before BedrockRelay connects are kept, up to the last 400, and delivered once it does. On a Realm, messages sent while our bot isn't there are lost, so use discord:ready if that matters.

What happens to your message

  • It's posted in every channel connected to that world with the Other addons event turned on. If there are none, it goes nowhere.
  • Minecraft colour codes are removed, @everyone, @here and role mentions are defused, and long text is cut at 1,900 characters.
  • Malformed JSON is ignored. On a dedicated server there's a warning in the content log.

Writing a plugin instead? Plugins post with postToDiscord, which lets the owner pick channels just for your plugin.

Running a Minecraft world rather than building for one? The help covers everything from setup to troubleshooting.

Read the help