fix(mesh): skip gossip when RPC method missing and catch encode errors
Avoid unhandledRejection when pearcord-shared lacks USER_UPSERT (method 0). Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -912,8 +912,9 @@ class PearcordGuild extends EventEmitter {
|
||||
}
|
||||
|
||||
gossipUserUpsert (user) {
|
||||
if (!user?.id) return
|
||||
broadcastGossip(this, RPC.USER_UPSERT, user)
|
||||
const method = RPC.USER_UPSERT
|
||||
if (!user?.id || !method) return
|
||||
void broadcastGossip(this, method, user).catch(() => {})
|
||||
}
|
||||
|
||||
gossipProfileCosmetic (payload) {
|
||||
|
||||
@@ -29,7 +29,14 @@ function attachGossipMesh (guild, conn) {
|
||||
}
|
||||
|
||||
async function broadcastGossip (guild, method, payload) {
|
||||
const buf = encodeRpc(method, b4a.from(JSON.stringify(payload)))
|
||||
const m = Number(method)
|
||||
if (!Number.isInteger(m) || m <= 0 || m > 255) return
|
||||
let buf
|
||||
try {
|
||||
buf = encodeRpc(m, payload)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
const sessions = [...guild._channels.values()]
|
||||
await Promise.all(
|
||||
sessions.map(async (session) => {
|
||||
|
||||
Reference in New Issue
Block a user