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

Implement `hasTargetUser` helper function (remaining commands) #213

Closed lyallstewart closed 2 years ago

lyallstewart commented 2 years ago

Purpose

Update the remaining commands to use the hasTargetUser() helper function, making the code more DRY.

Is your feature request related to a problem? Please describe.

The current target user is repeated multiple times through the code, it would be more efficient to have this handled in a single place.

Proposed Solution

This one is a bit more difficult to implement than #211 as those were just updating a function call and removing the old code, however most of the remaining commands use a data array and return then contents of that instead:

  if (!data.toBan) {
    data.err = 'Please provide a user to ban.';
    return data;
  }

One option would be to completely remove this and bring it more inline with newer commands but that is potentially a lot of work to make a small end change in efficiency.

Acceptance Criteria

Please list the requirements the implementation of this feature should meet.