YAGPDB Documentation

website·Indexed 33 days ago

https://help.yagpdb.xyz

Documentation for YAGPDB, a Discord bot featuring advanced automoderation, custom commands with a built-in database, and notification feeds for Twitch, YouTube, and Reddit. Includes guides on scripting, custom interactions using buttons and modals, template functions, and instructions for self-hosting via Docker or baremetal.

Tokens
58.7K
Snippets
273
Records
482
Agent score
61%

What's inside YAGPDB

  1. Overview of componentBuilder for Discord Components V2

    The componentBuilder is a helper used to assemble complex Discord Components V2 layouts (sections, buttons, menus, galleries) using a template-based approach. It converts key-value pairs into the required JSON format and handles validation, allowing developers to create rich messages with images, files, and interactive elements without writing raw JSON.
  2. Access RoleSubscriptionData

    Role subscription data provides details about a user's paid tier subscription:

    • .RoleSubscriptionListingID: The ID of the SKU and listing.
    • .TierName: The name of the subscribed tier.
    • .TotalMonthsSubscribed: Cumulative months subscribed.
    • .IsRenewal: Boolean indicating if the notification is for a renewal.
  3. Access Primary Guild identity data

    Primary Guild data is available via .User.PrimaryGuild and contains information about a user's identity guild tag.
    .IdentityGuildID // ID of the primary guild
    .IdentityEnabled // Boolean; if the user is displaying the tag
    .Tag             // The text of the server tag
    .Badge           // The server tag badge hash
    .BadgeURL        // Method: returns the URL for the server tag badge
  4. Assign or remove roles in bulk with YAGPDB

    The Bulk Role feature allows you to assign or remove a specific role from multiple members simultaneously. This is a premium-only feature. Only one bulk role process can run at a time; you must wait for the current process to complete or cancel it before starting a new one.
  5. Access Member data in YAGPDB custom commands

    The .Member object provides detailed information about a guild member. Note that .Member.JoinedAt is of type discordgo.Timestamp and requires the .Parse method to be converted to time.Time.
    // Example: Get a member's avatar URL with a specific size
    {{.Member.AvatarURL "512"}}
  6. Get bot and server information

    Use these general commands to retrieve basic information about the bot, its status, or premium availability.
    /help [command:Text] # Shows help for all or a specific command
    /info                # Responds with bot information
    /invite              # Provides the bot invite link
    /premium [user:Mention/ID] # Shows premium status for the server and user slots
  7. Use Go-flavored RegEx in YAGPDB

    YAGPDB uses Go-flavored regular expressions (RE2 syntax). For full technical specifications, refer to the RE2 syntax reference or the official Go regexp package documentation.
  8. Understand YAGPDB templating syntax basics

    YAGPDB uses a modified version of Go's text/template package. It requires standard ASCII quotation marks: " for double quotes, ' for single quotes, and ` for backticks. 'Smart quotes' (curly quotes) are not supported and will cause errors. For detailed information on global functions like printf, index, and len, refer to the official Go text/template documentation.
  9. Understand the Advanced Automoderator system hierarchy

    Advanced Automoderator is a flexible system for automating server moderation based on user-configurable rules. The system is structured as follows:

    • Lists: Collections of words or domains used as triggers (denylists or allowlists).
    • Rulesets: Containers for rules. Rulesets can be toggled on/off via the control panel or the automod toggle <ruleset name> command.
    • Rules: The core logic consisting of Triggers, Conditions, and Effects.

    Rule Logic Flow:

    • Triggers (OR logic): A rule fires if any one of its triggers is true.
    • Conditions (AND logic): For a rule to fire, all specified conditions must be met.
    • Effects (AND logic): If the triggers and conditions are met, all specified effects are executed.
  10. Access Channel data in YAGPDB custom commands

    The .Channel object provides detailed information about the channel where the command was executed. This includes support for forum channels, threads, and voice channels.
    {{.Channel.ID}}                   - The ID of the channel
    {{.Channel.Name}}                 - The name of the channel
    {{.Channel.Mention}}              - Mentions the channel object
    {{.Channel.Topic}}                - The topic of the channel
    {{.Channel.Type}}                 - The type of the channel
    {{.Channel.GuildID}}              - Guild ID of the channel
    {{.Channel.ParentID}}             - ID of the channel’s parent category (0 if none)
    {{.Channel.Position}}             - Channel position from top-down
    {{.Channel.NSFW}}                 - Boolean: whether the channel is NSFW
    {{.Channel.IsPrivate}}             - Boolean: whether the channel is a DM
    {{.Channel.IsThread}}             - Boolean: whether the channel is a thread
    {{.Channel.IsForum}}              - Boolean: whether the channel is a forum channel
    {{.Channel.Bitrate}}              - Bitrate used (only set on voice channels)
    {{.Channel.OwnerID}}              - ID of the thread creator (0 for normal channels)
    {{.Channel.AppliedTags}}          - Slice of tag IDs applied to a forum post ([]int64)
    {{.Channel.AvailableTags}}        - Slice of available forum tags ([]discordgo.ForumTag)
    {{.Channel.PermissionOverwrites}} - Slice of Discord permission overwrite structures
    {{.Channel.ThreadMetadata}}       - Metadata for threads (only present on threads)
  11. Understand Advanced Automoderator Effect Logic

    In the Advanced Automoderator, Effects define the actions taken when a rule is triggered. All effects assigned to a rule are executed only after all prior checks/conditions are met. The effects are combined according to the logical AND operator.
  12. Handle Interaction data in component or modal triggers

    When a custom command is triggered by a component (button/select menu) or a modal submission, the .Interaction object is available. This object contains metadata about the interaction and the user who triggered it. The .Interaction.Token is specifically required for sending followup interactions.
    {{/* Example fields available in .Interaction */}}
    Channel ID: {{.Interaction.ChannelID}}
    Interaction ID: {{.Interaction.ID}}
    User Locale: {{.Interaction.Locale}}
    Interacting Member: {{.Interaction.Member}}
    Interaction Token: {{.Interaction.Token}}