Skip to content

Commit

Permalink
add errors to PermissionsCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Nov 13, 2023
1 parent 0910efe commit ead98f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/commands/PermissionsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@ export class PermissionsCommand implements ICommand {
}

public static async ensureModerator(client: MatrixClient, roomId: string, people: ResolvedPersonIdentifier[]) {
const powerLevels = await client.getRoomStateEvent(roomId, "m.room.power_levels", "");
let powerLevels;
try {
powerLevels = await client.getRoomStateEvent(roomId, "m.room.power_levels", "");
}
catch (error) {
throw Error(`Error fetching power levels for room ${roomId}`, {cause:error})
}

for (const person of people) {
if (!person.mxid) continue;
if (powerLevels['users'][person.mxid]) continue;
powerLevels['users'][person.mxid] = 50;
}
await client.sendStateEvent(roomId, "m.room.power_levels", "", powerLevels);

try {
await client.sendStateEvent(roomId, "m.room.power_levels", "", powerLevels);
}
catch (error) {
throw Error(`Error sending powerlevels event into room ${roomId}`, {cause:error})
}
}
}
2 changes: 1 addition & 1 deletion src/commands/actions/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function runRoleCommand(action: IAction, conference: Conference, cl
const aud = backstageOnly ? conference.getAuditoriumBackstage(args[0]) : conference.getAuditorium(args[0]);
if (!aud) {
const spiRoom = conference.getInterestRoom(args[0]);
if (!spiRoom) return client.replyNotice(roomId, event, "Unknown auditorium/interest room");
if (!spiRoom) return client.replyNotice(roomId, event, `Unknown auditorium/interest room: ${spiRoom}`);
await doInterestResolveAction(action, client, spiRoom, conference, isInvite);
} else {
await doAuditoriumResolveAction(action, client, aud, conference, backstageOnly, skipTalks, isInvite);
Expand Down

0 comments on commit ead98f0

Please sign in to comment.