-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more specific errors to CopyModerators
command
#196
Conversation
@@ -61,7 +61,7 @@ export class HelpCommand implements ICommand { | |||
"<pre><code>" + | |||
"!conference inviteme <room> - Asks the bot to invite you to the given room.\n" + | |||
"!conference inviteto <room> <user> - Asks the bot to invite the given user to the given room.\n" + | |||
"!conference join <room> - Makes the bot join the given room.\n" | |||
"!conference join <room> - Makes the bot join the given room.\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a typo I noticed that was causing the last two help commands to not be shown in the client. Drive-by cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate how JavaScript is happy to have these implied semicolons lead to effectively empty / ignored statements. Thanks for catching it :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors are good, just wanted to call out some good practice stuff.
const fromPl: {"users"?: Record<string, any>} = await this.client.getRoomStateEvent(fromRoomId, "m.room.power_levels", ""); | ||
let toPl = await this.client.getRoomStateEvent(toRoomId, "m.room.power_levels", ""); | ||
|
||
let fromPl: { "users"?: Record<string, any> } = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PowerLevelsEventContent
may also work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does - much nicer, thanks!
|
||
try { | ||
var toPl = await this.client.getRoomStateEvent(toRoomId, "m.room.power_levels", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | |
var toPl = await this.client.getRoomStateEvent(toRoomId, "m.room.power_levels", ""); | |
let toPl: PowerLevelsEventContent; | |
try { | |
toPl = await this.client.getRoomStateEvent(toRoomId, "m.room.power_levels", ""); |
Avoid using var
if you can, it doesn't conform to block scoping and tends to surprise you. In this case TypeScript should let you define toPl
outside and it will always be set, because you are throwing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terrific. Thanks!
Merged #196 into main, thanks for the review! |
Part of the effort to improve error messages. I hate that it is a pile of try/catch but I wasn't sure how else to give more specific information about where things are failing. Suggestions welcome.