Get started with Peachy now 🍑
PEACHYPEACHY
Social

TikTok

The TikTok command allows users to manage their TikTok profile details, including setting a name or link, viewing their own or another user's details, or accessing help information. This command supports both message and slash command usage.

Command Details

  • Name: tiktok
  • Aliases: tt
  • Category: Profile
  • Description: Manage your TikTok profile
  • Usage:
    • tiktok
    • tiktok @mention
    • tiktok name <YourTikTokName>
    • tiktok link <YourTikTokLink>
    • tiktok help
  • Examples:
    • tiktok - Shows your current TikTok details.
    • tiktok @mention - Shows the TikTok details of the mentioned user.
    • tiktok name MyTikTokName - Sets your TikTok name.
    • tiktok link https://tiktok.com/@MyProfile - Sets your TikTok link.
    • tiktok help - Shows command usage examples.
  • Cooldown: 5 seconds
  • Arguments: Optional (subcommand, name, link, or user mention)
  • Slash Command: Enabled
  • Permissions:
    • Bot: SendMessages, ViewChannel, EmbedLinks
    • User: None
  • Player Requirements: User must be registered for profile updates or viewing

Functionality

  • Supports subcommands:
    • name → Sets TikTok name (max 21 characters).
    • link → Sets TikTok profile link (valid URL required).
    • help → Displays usage instructions and examples.
  • Default behavior (no subcommand): Shows TikTok name and link (or "Not set" if missing).
  • Retrieves user data from the Users schema; checks if user exists.
  • Handles both message-based commands and slash commands.
  • Validates:
    • Name: Non-empty, max length 21.
    • Link: Matches URL regex pattern.
  • Updates database using Users.updateOne() for name/link changes.
  • Builds localized embeds for:
    • Success (e.g., "Your TikTok name has been set.")
    • Errors (e.g., invalid input)
    • Help instructions
  • Display format:
    • If both name and link exist → [Name](Link) clickable.
    • If only name exists → shows name.
    • If neither → "Not set".

Code Overview

The command:

  • Extends the Command class from ../../structures/index.js.
  • Uses ctx.isInteraction to detect slash command usage.
  • Determines subCommand (name, link, help, or default view).
  • Fetches and updates user TikTok data in social.tiktok fields.
  • Constructs a rich embed with:
    • Title → Includes target username.
    • Description → Displays TikTok info or help text.
  • Handles localization for:
    • Titles, field names, and error messages.
  • Returns the response using ctx.sendMessage().

Example Embed