CodecademyCommunity / codecademy-discord-bot

Custom moderation bot for the official Codecademy Community Discord server.
https://codecademycommunity.github.io/
MIT License
11 stars 1 forks source link

Create timeout command #314

Closed Victoria-DR closed 2 years ago

Victoria-DR commented 2 years ago

What issue is this solving?

Closes #235

Description

Any helpful knowledge/context for the reviewer?

Please make sure you've attempted to meet the following coding standards

mikejoh12 commented 2 years ago

I did some quick testing on the input validation for the duration. Some invalid inputs currently get through the RegEx validation and throw errors. One example is using this string for duration: 112sm. This makes the command fail with a couple of error messages. I think the most solid solution is to create a drop-down of duration options which is fairly easy to do with slash commands. This is what the built in Discord timeout command uses. Another option may be to use a combination of an input field for an Integer with a dropdown for units such as minutes, hours, days, weeks.

mikejoh12 commented 2 years ago

It would be good to modify the code so that multiple interaction.reply methods are not executed since this causes an Unhandled Promise Rejection, at least when the 2nd reply is in the catch block. One case where this currently happens is if writing to the DB fails. Since we are handling the error already - sending a reply and logging it with console.error it should not have to trigger an additional Unhandled Promise Rejection. I posted some more info on Discord about the issue.