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 TypeMethodDescriptiondefault booleanCheck if the requesting user can manage the guild.Get additional context data provided by the agent system.default ObjectgetContextValue(String key) Get a specific context value.default <T> TgetContextValue(String key, Class<T> type) Get a typed context value.default longGet the guild ID (returns 0 if not in guild).net.dv8tion.jda.api.entities.MemberGet the Member object for the requesting user (guild context only).longGet the ID of the user who triggered the agent.longGet the ID of the guild (if in guild context) or user (if in DM).default longGet the user ID for DM context.default booleanhasPermission(net.dv8tion.jda.api.Permission permission) Check if the requesting user has a specific Discord permission.default booleanisAdmin()Check if the requesting user is a guild administrator.booleanisGuild()Check if this is a guild context.default booleanCheck 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
-
getContextValue
-
getContextValue
-