Get started with Peachy now 🍑
PEACHYPEACHY
Company

Approved Job

The `approvedjob` command allows staff or developers to approve or reject a user's job application, optionally providing a rejection reason.

Command Details

  • Name: approvedjob
  • Aliases: aj
  • Category: Company
  • Description: Approve or reject a user's job application.
  • Usage: approvedjob <userId> <approved|rejected> [reason]
  • Examples:
    • approvedjob 123456789012345678 approved
    • approvedjob 123456789012345678 rejected Spamming during interview
  • Cooldown: None specified
  • Arguments:
    • userId: The Discord user ID of the applicant.
    • status: Either approved or rejected.
    • reason: Required only if status is rejected.
  • Slash Command: Disabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: Developer or Staff only
  • Player Requirements: None

Functionality

  • Fetches the user from the Users schema using userId.
  • Validates:
    • User exists in the database.
    • The user has an active application (work.status not "not yet applied").
    • Status is either approved or rejected.
  • If approved:
    • Updates work.status to approved.
    • Sets approvedDate.
  • If rejected:
    • Updates work.status to rejected.
    • Stores rejectionReason.
    • Increments work.rejections.
  • Responds with an embed summarizing the action taken.
  • Handles:
    • Missing parameters.
    • Invalid statuses.
    • Nonexistent users.
    • Errors with client.utils.sendErrorMessage().

Code Overview

  • Extends the Command class.
  • Imports:
    • Users schema from ../../schemas/user.
  • Core logic:
    • Validates input (ID, status, reason).
    • Updates database document with the appropriate status and fields.
    • Returns success embed with custom title and footer.
  • Error handling:
    • Sends descriptive error messages for invalid input, missing data, or database issues.