Class DefaultErrorMessageFactory
java.lang.Object
io.github.kaktushose.jdac.embeds.error.DefaultErrorMessageFactory
- All Implemented Interfaces:
ErrorMessageFactory
The default implementation of ErrorMessageFactory using Components V2.
Localization
For simple localization of these error messages you can add a jdac_LOCALE.ftl file to the resources folder and
provide the keys/ use the variables as listed below.
Type Adapting Failed
Keys
adapting-failed-titleadapting-failed-detailsadapting-failed-message
Variables
command: The full command with parameter names, with the failed argument underlined, for instance: /example arg1 arg2expected: The expected argument typeactual: The provided argument typeraw: The raw, textual user inputmessage: The error message of the type adapter
Insufficient Permissions
Keys
insufficient-permissions
Variables
interaction: The name of the interaction that failedpermissions: The permissions that are required
Constraint Failed
Keys
constraint-failed
Variables
message: The already localized error message of the failed constraint
Interaction Execution Failed
Keys
execution-failed-titleexecution-failed-message
Variables
user: the user executing the interactioninteraction: the interaction typetimestamp: the current timestampexception: the name of the exception class
Unknown Interaction
Keys
unknown-interaction
Own Implementation
Alternatively, you can pass your own ErrorMessageFactory implementation to
JDACBuilder.errorMessageFactory(ErrorMessageFactory).
-
Nested Class Summary
Nested classes/interfaces inherited from interface ErrorMessageFactory
ErrorMessageFactory.ErrorContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.components.MessageTopLevelComponentgetConstraintFailedMessage(ErrorMessageFactory.ErrorContext context, String message) Gets aMessageTopLevelComponentto send when a parameter constraint fails.net.dv8tion.jda.api.components.MessageTopLevelComponentGets aMessageTopLevelComponentto send when a user is missing permissions.net.dv8tion.jda.api.components.MessageTopLevelComponentgetInteractionExecutionFailedMessage(ErrorMessageFactory.ErrorContext context, Throwable exception) Gets aMessageTopLevelComponentto send when the command execution failed.net.dv8tion.jda.api.components.MessageTopLevelComponentgetTimedOutComponentMessage(net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent event) Gets aMessageTopLevelComponentto send when an incoming component interaction already timed out.net.dv8tion.jda.api.components.MessageTopLevelComponentgetTypeAdaptingFailedMessage(ErrorMessageFactory.ErrorContext context, io.github.kaktushose.proteus.conversion.ConversionResult.Failure<?> failure) Gets aMessageTopLevelComponentto send when type adapting of the user input failed.
-
Constructor Details
-
DefaultErrorMessageFactory
-
-
Method Details
-
getTypeAdaptingFailedMessage
public net.dv8tion.jda.api.components.MessageTopLevelComponent getTypeAdaptingFailedMessage(ErrorMessageFactory.ErrorContext context, io.github.kaktushose.proteus.conversion.ConversionResult.Failure<?> failure) Gets aMessageTopLevelComponentto send when type adapting of the user input failed.- Specified by:
getTypeAdaptingFailedMessagein interfaceErrorMessageFactory- Parameters:
context- theErrorMessageFactory.ErrorContextfailure- theConversionResult.Failure- Returns:
- a
MessageTopLevelComponentto send when type adapting failed
-
getInsufficientPermissionsMessage
public net.dv8tion.jda.api.components.MessageTopLevelComponent getInsufficientPermissionsMessage(ErrorMessageFactory.ErrorContext context) Gets aMessageTopLevelComponentto send when a user is missing permissions.- Specified by:
getInsufficientPermissionsMessagein interfaceErrorMessageFactory- Parameters:
context- theErrorMessageFactory.ErrorContext- Returns:
- a
MessageTopLevelComponentto send when a user is missing permissions
-
getConstraintFailedMessage
public net.dv8tion.jda.api.components.MessageTopLevelComponent getConstraintFailedMessage(ErrorMessageFactory.ErrorContext context, String message) Gets aMessageTopLevelComponentto send when a parameter constraint fails.- Specified by:
getConstraintFailedMessagein interfaceErrorMessageFactory- Parameters:
context- theErrorMessageFactory.ErrorContext- Returns:
- a
MessageTopLevelComponentto send when a parameter constraint fails
-
getInteractionExecutionFailedMessage
public net.dv8tion.jda.api.components.MessageTopLevelComponent getInteractionExecutionFailedMessage(ErrorMessageFactory.ErrorContext context, Throwable exception) Gets aMessageTopLevelComponentto send when the command execution failed.- Specified by:
getInteractionExecutionFailedMessagein interfaceErrorMessageFactory- Parameters:
context- theErrorMessageFactory.ErrorContextexception- theThrowablethat made the command execution fail- Returns:
- a
MessageTopLevelComponentto send when the command execution failed
-
getTimedOutComponentMessage
public net.dv8tion.jda.api.components.MessageTopLevelComponent getTimedOutComponentMessage(net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent event) Gets aMessageTopLevelComponentto send when an incoming component interaction already timed out.- Specified by:
getTimedOutComponentMessagein interfaceErrorMessageFactory- Parameters:
event- theGenericInteractionCreateEventmo runtime was found for- Returns:
- a
MessageTopLevelComponentto send when an incoming component interaction already timed out
-