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

Convert notes cmds to slashcmds #309

Closed mikejoh12 closed 2 years ago

mikejoh12 commented 2 years ago

What issue is this solving?

Closes #295

Description

Creates notes, addnote, and removenote slash-commands. It also fixes issues 196 and 164 for the slash note commands by enabling them to work with users who have left server. Moves some logic that is also shared by other commands out into separate files. Updates the db-logic for the notes commands to use async/await. Modifies db logic to use only one SQL statement per db query.

Any helpful knowledge/context for the reviewer?

We can now more easily manage users who have left server as the .getUser method in the slash-commands gives us an instance of the User class which is documented here: https://discord.js.org/#/docs/discord.js/stable/class/User

For the text commands there is currently a function called notHighRoller which many commands use to check that target user is not an admin type role. This functionality was created in a new function named isServerStaff which the slash-commands can utilize to check if the target user is staff. There was also logic selecting a random color in a few commands. This was also extracted into a new function that can be shared by several commands going forward.

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