Fix setBotPower to not use `.content` (#7179)

* Fix setBotPower to not use `.content`

* Simplify currentPl
pull/21833/head
Will Hunt 2021-12-01 17:23:26 +00:00 committed by GitHub
parent fb11779785
commit 11aa362eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -473,10 +473,7 @@ async function setBotPower(
// If the PL is equal to or greater than the requested PL, ignore.
if (ignoreIfGreater === true) {
// As per https://matrix.org/docs/spec/client_server/r0.6.0#m-room-power-levels
const currentPl = (
powerLevels.content.users && powerLevels.content.users[userId]
) || powerLevels.content.users_default || 0;
const currentPl = powerLevels.users?.[userId] ?? powerLevels.users_default ?? 0;
if (currentPl >= level) {
return sendResponse(event, {
success: true,