This pack provides a library that can be used to send messages and embeds to discord form a bedrock bds server.
npm install @esploratori/bedrockBridgeDirect instance. A simple class that handles sending messages to BedrockBridge through scriptevents. BedrockBridge will handle the discord connection part.
js
import { bridgeDirect } from "@esploratori/bedrock";
bridgeDirect.events.directInitialize.subscribe(() => {
bridgeDirect.sendMessage("Welcome from bedrock!")
})
`
If you copy the file, the first line of this code will probably look like this import { bridgeDirect } from "./index.js".
!direct_example
Be careful when using the library that the directInitialize event has been sent, otherwise trying to send messages will result in an error.
1. A possible approach to this problem could be checking if the connection is ready before sending logs.
`js
// ...
import { world } from "@minecraft/server"
world.afterEvents.itemUse.subscribe(e=>{
if (e.itemStack.nameTag==="legendary-item"){
if (bridgeDirect.ready){ // making sure that the bridge is active
bridgeDirect.sendMessage(e.source.name + " used a legendary item", "Legendary News")
}
}
})
`
2. While another approach could be including your pack logic inside the bridgeInitialize event.
`js
// ...
bridgeDirect.events.directInitialize.subscribe(()=>{
world.afterEvents.itemUse.subscribe(e => {
if (e.itemStack.nameTag === "legendary-item") {
bridgeDirect.sendMessage(e.source.name + " used a legendary item", "Legendary News")
}
})
})
``