Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix setBotPower to not use .content #7179

Merged
merged 3 commits into from
Dec 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ScalarMessaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ async function setBotPower(
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;
powerLevels.users && powerLevels.users[userId]
) || powerLevels.users_default || 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion doesn't want to work but this could be much cleaner as

const currentPl = powerLevels.users?.[userId] ?? powerLevels.users_default ?? 0;


if (currentPl >= level) {
return sendResponse(event, {
Expand Down