Skip to content

Add-on integration

discord-mcbe supports integration with other add-ons through MCBE-IPC. This allows other add-ons to send messages to Discord through discord-mcbe.

Follow the instructions from MCBE-IPC to add it to the other add-on.

To disable this feature, set bot.allow_addon_messages to false in config.json. The ping endpoint continues to respond so other add-ons can still detect whether discord-mcbe is installed and connected.

The response from dmc:ping is true when connected and false when discord-mcbe is installed but disconnected. If there is no response within 20 ticks, discord-mcbe is not installed. Perform this check only once at startup.

import { system } from '@minecraft/server';
import { IPC, PROTO } from 'mcbe-ipc';
export function getDiscordMcbeStatus(): Promise<boolean | undefined> {
return Promise.race([
IPC.invoke('dmc:ping', PROTO.Void, undefined, PROTO.Boolean),
system.waitTicks(20).then(() => undefined),
]);
}

Send a JSON string containing the source and a message in the Discord Create Message API format to dmc:send_message to send it to Discord.

import { IPC, PROTO } from 'mcbe-ipc';
function sendDiscordMessage(source: string, message: Record<string, unknown>) {
IPC.send('dmc:send_message', PROTO.String, JSON.stringify({ source, message }));
}
sendDiscordMessage('example-addon', {
content: 'This message was sent from another add-on',
});

Set source to the name of the sending addon. In message, you can use Create Message API fields that can be represented as JSON, such as embeds. Transferring attachment data is not supported.

dmc:connect is emitted when a connection starts, and dmc:disconnect is emitted when it ends. Neither event carries data.

import { IPC, PROTO } from 'mcbe-ipc';
IPC.on('dmc:connect', PROTO.Void, () => {
// The connection to discord-mcbe has started
});
IPC.on('dmc:disconnect', PROTO.Void, () => {
// The connection to discord-mcbe has ended
});