respond method Null safety
- MessageBuilder builder,
- {bool private = false,
override
Send a response to the command. This is the same as send but it references the original command.
You can set hidden
to true
to send an ephemeral response. Setting hidden
to a value
different that CommandsOptions.hideOriginalResponse will result in unusual behaviour if this
method is invoked more than two seconds after command execution starts.
Calling acknowledge less than two seconds after command execution starts with the same value
for hidden
as this invocation will prevent this unusual behaviour from happening.
hidden
will override the value of private
if both are provided.
Implementation
@override
Future<IMessage> respond(MessageBuilder builder, {bool private = false, bool? hidden}) async {
hidden ??= private;
if (_hasCorrectlyAcked) {
return interactionEvent.sendFollowup(builder, hidden: hidden);
} else {
_hasCorrectlyAcked = true;
try {
await interactionEvent.acknowledge(hidden: hidden);
} on AlreadyRespondedError {
// interaction was already ACKed by timeout or [acknowledge], hidden state of ACK might not
// be what we expect
if (_originalAckHidden != hidden) {
await interactionEvent
.sendFollowup(MessageBuilder.content(MessageBuilder.clearCharacter));
if (!_originalAckHidden) {
// If original response was hidden, we can't delete it
await interactionEvent.deleteOriginalResponse();
}
}
}
return interactionEvent.sendFollowup(builder, hidden: hidden);
}
}