Interface AgentToolContext


public interface AgentToolContext
Provides contextual information about the environment in which an agent tool is being executed. This includes details about the target (guild or user), the requesting user, and additional metadata that may be relevant to the tool's operation.

Implementations of this interface are typically used within agent tools to determine execution context, check permissions, and access supplementary data related to the event that triggered the tool.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Check if the requesting user can manage the guild.
    Get additional context data provided by the agent system.
    default Object
    Get a specific context value.
    default <T> T
    getContextValue(String key, Class<T> type)
    Get a typed context value.
    default long
    Get the guild ID (returns 0 if not in guild).
    net.dv8tion.jda.api.entities.Member
    Get the Member object for the requesting user (guild context only).
    long
    Get the ID of the user who triggered the agent.
    long
    Get the ID of the guild (if in guild context) or user (if in DM).
    default long
    Get the user ID for DM context.
    default boolean
    hasPermission(net.dv8tion.jda.api.Permission permission)
    Check if the requesting user has a specific Discord permission.
    default boolean
    Check if the requesting user is a guild administrator.
    boolean
    Check if this is a guild context.
    default boolean
    Check if the requesting user is the guild owner.
  • Method Details

    • getTargetId

      long getTargetId()
      Get the ID of the guild (if in guild context) or user (if in DM).
      Returns:
      the target ID
    • isGuild

      boolean isGuild()
      Check if this is a guild context.
      Returns:
      true if guild, false if DM
    • getRequestingUserId

      long getRequestingUserId()
      Get the ID of the user who triggered the agent.
      Returns:
      the requesting user's ID
    • getRequestingMember

      net.dv8tion.jda.api.entities.Member getRequestingMember()
      Get the Member object for the requesting user (guild context only). Used for permission checking.
      Returns:
      the member or null if not in guild or unavailable
    • getGuildId

      default long getGuildId()
      Get the guild ID (returns 0 if not in guild).
      Returns:
      guild ID or 0
    • getUserId

      default long getUserId()
      Get the user ID for DM context.
      Returns:
      user ID if in DM, or the requesting user ID
    • hasPermission

      default boolean hasPermission(net.dv8tion.jda.api.Permission permission)
      Check if the requesting user has a specific Discord permission.
      Parameters:
      permission - the permission to check
      Returns:
      true if user has permission, false otherwise (also false in DM)
    • isAdmin

      default boolean isAdmin()
      Check if the requesting user is a guild administrator.
      Returns:
      true if admin, false otherwise
    • canManageGuild

      default boolean canManageGuild()
      Check if the requesting user can manage the guild.
      Returns:
      true if can manage, false otherwise
    • isGuildOwner

      default boolean isGuildOwner()
      Check if the requesting user is the guild owner.
      Returns:
      true if owner, false otherwise
    • getContextData

      Map<String,Object> getContextData()
      Get additional context data provided by the agent system. May include things like channel ID, message ID, etc.
      Returns:
      context data map (may be empty, never null)
    • getContextValue

      default Object getContextValue(String key)
      Get a specific context value.
      Parameters:
      key - the context key
      Returns:
      the value or null if not present
    • getContextValue

      default <T> T getContextValue(String key, Class<T> type)
      Get a typed context value.
      Type Parameters:
      T - the type
      Parameters:
      key - the context key
      type - the expected type
      Returns:
      the value cast to the type, or null