Skip to content

Commit

Permalink
Log an error when sending the ban reason fails
Browse files Browse the repository at this point in the history
Signed-off-by: nexy7574 <[email protected]>
  • Loading branch information
nexy7574 committed Jan 11, 2025
1 parent 03a080f commit 177bd0f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/protections/WordList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import {
UserConsequences,
Value,
describeProtection,
isError,
} from "matrix-protection-suite";
import { Draupnir } from "../Draupnir";
import {
StringUserID,
StringRoomID,
MatrixRoomID,
} from "@the-draupnir-project/matrix-basic-types";
import { resultifyBotSDKRequestError } from "matrix-protection-suite-for-matrix-bot-sdk";

const log = new Logger("WordList");

Expand Down Expand Up @@ -199,10 +201,22 @@ export class WordListProtection
event.sender,
reason
);
await this.draupnir.client.sendMessage(this.draupnir.managementRoomID, {
msgtype: "m.notice",
body: `Banned ${event.sender} in ${roomID} for saying '${match[0]}'.`,
});
// await this.draupnir.client.sendMessage(this.draupnir.managementRoomID, {
// msgtype: "m.notice",
// body: `Banned ${event.sender} in ${roomID} for saying '${match[0]}'.`,
// });
const messageResult = await this.draupnir.client
.sendMessage(this.draupnir.managementRoomID, {
msgtype: "m.notice",
body: `Banned ${event.sender} in ${roomID} for saying '${match[0]}'.`,
})
.then((_) => Ok(undefined), resultifyBotSDKRequestError);
if (isError(messageResult)) {
log.error(
`Failed to send a message to the management room after banning ${event.sender} in ${roomID} for saying '${match[0]}'.`,
messageResult.error
);
}
await this.eventConsequences.consequenceForEvent(
roomID,
event.event_id,
Expand Down

0 comments on commit 177bd0f

Please sign in to comment.