Get started with Peachy now 🍑
PEACHYPEACHY
Work

Apply Job

The applyjob command allows users to apply for a job from available positions such as Police, IT, Doctor, Teacher, Engineer, or Student. This command supports both message and slash command usage.

Command Details

  • Name: applyjob
  • Aliases: apply, jobapply
  • Category: Work
  • Description: Apply for a job with one of the five available positions.
  • Usage:
    • applyjob <position>
  • Examples:
    • applyjob Police
    • applyjob IT
    • applyjob Doctor
    • applyjob Teacher
    • applyjob Engineer
    • applyjob Student
  • Cooldown: 10 seconds
  • Arguments: Required (position)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: User must be registered to apply for a job.

Functionality

  • Accepts one argument or slash option: position.
  • Valid positions: police, doctor, it, engineer, teacher, student.
  • Validation:
    • If an invalid position is provided → Returns an error message.
    • If user is not registered → Returns an error message.
    • If user already has an awaiting or approved job → Returns an error message.
  • Job Status:
    • If position = student → Auto-approved immediately (status: approved).
    • Otherwise → Status set to awaiting for manual approval.
  • Saves job application details to the Users schema:
    • work.position → Selected position.
    • work.applyDate → Current date.
    • work.statusawaiting or approved.
    • work.approvedDate → If auto-approved.
  • Responds with an embed:
    • Displays job title, application or approval date, and user details.
    • Shows an emoji thumbnail based on position.
  • Handles errors gracefully and logs exceptions.

Code Overview

The command:

  • Extends the Command class from ../../structures/index.js.
  • Retrieves localized messages from language.locales.
  • Normalizes and validates the position input (case-insensitive).
  • Checks user registration and job status.
  • Updates Users collection with new job details.
  • Uses helper utilities for:
    • Emojis for positions.
    • Formatted text with formatCapitalize.
  • Sends response as an embed:
    • For Student: Shows instant approval message with date.
    • For Others: Shows success message with application date.

Example Embed