Phase 432: voice/stage audit trail and leave error logging.

Record STAGE_LEAVE on stage channel exit, stage speaker moderation audits,
and voice.leave error spans so voice-errors diagnostics stay actionable.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-23 17:40:11 -04:00
co-authored by Cursor
parent d3637b4e20
commit 2da13ea78b
+34
View File
@@ -6605,8 +6605,23 @@ class PearcordPlatform extends EventEmitter {
channelId: this.voice?.myChannelId || null channelId: this.voice?.myChannelId || null
}) })
try { try {
const leavingId = this.voice?.myChannelId
let leavingIsStage = false
if (guild && leavingId) {
const ch = await this.db.get(COLLECTIONS.CHANNELS, {
guildId: guild.id,
id: leavingId
})
leavingIsStage = isStageChannel(ch)
}
const payload = await this._leaveVoice({ gossip: true }) const payload = await this._leaveVoice({ gossip: true })
if (payload && guild) { if (payload && guild) {
if (leavingIsStage) {
await this._audit('STAGE_LEAVE', {
guildId: guild.id,
targetId: payload.channelId
})
}
await this._audit('VOICE_LEAVE', { guildId: guild.id, targetId: payload.channelId }) await this._audit('VOICE_LEAVE', { guildId: guild.id, targetId: payload.channelId })
} }
if (payload) this.emit('voice', payload) if (payload) this.emit('voice', payload)
@@ -6616,6 +6631,10 @@ class PearcordPlatform extends EventEmitter {
}) })
return payload return payload
} catch (err) { } catch (err) {
this.log.error('voice.leave error', {
channelId: this.voice?.myChannelId || null,
err: err?.message || String(err)
})
span.fail(err) span.fail(err)
throw err throw err
} }
@@ -6683,6 +6702,11 @@ class PearcordPlatform extends EventEmitter {
userId: user.id userId: user.id
}) })
this.guild.gossipStageSpeaker(row) this.guild.gossipStageSpeaker(row)
await this._audit('stage.speaker.request', {
guildId: guild.id,
targetId: ch.id,
meta: { userId: user.id }
})
this.emit('stage', row) this.emit('stage', row)
return row return row
} }
@@ -6706,6 +6730,11 @@ class PearcordPlatform extends EventEmitter {
role: STAGE_ROLE.SPEAKER role: STAGE_ROLE.SPEAKER
}) })
this.guild.gossipStageSpeaker(row) this.guild.gossipStageSpeaker(row)
await this._audit('stage.speaker.approve', {
guildId: guild.id,
targetId: channelId,
meta: { userId: targetUserId }
})
if (targetUserId === user.id && this.voiceMedia) { if (targetUserId === user.id && this.voiceMedia) {
await this.setVoiceMute({ muted: false, deafened: false }) await this.setVoiceMute({ muted: false, deafened: false })
} }
@@ -6732,6 +6761,11 @@ class PearcordPlatform extends EventEmitter {
role: STAGE_ROLE.AUDIENCE role: STAGE_ROLE.AUDIENCE
}) })
this.guild.gossipStageSpeaker(row) this.guild.gossipStageSpeaker(row)
await this._audit('stage.speaker.demote', {
guildId: guild.id,
targetId: channelId,
meta: { userId: targetUserId }
})
if (targetUserId === user.id && this.voiceMedia) { if (targetUserId === user.id && this.voiceMedia) {
await this.setVoiceMute({ muted: true, deafened: false }) await this.setVoiceMute({ muted: true, deafened: false })
} }