respond method
Used to acknowledge a Interaction and send a response. Once this is sent you can then only send ChannelMessages.
Implementation
Future<void> respond(MessageBuilder builder, {bool hidden = false}) async {
final now = DateTime.now();
if (_hasAcked && now.isAfter(this.receivedAt.add(const Duration(minutes: 15)))) {
return Future.error(InteractionExpiredError._15mins());
} else if (now.isAfter(this.receivedAt.add(const Duration(seconds: 3)))) {
return Future.error(InteractionExpiredError._3secs());
}
this._logger.fine("Sending respond for for interaction: ${this.interaction.id}");
if (_hasAcked) {
await this.interactions.interactionsEndpoints.respondEditOriginal(
this.interaction.token,
this.client.app.id,
builder,
hidden
);
} else {
if (!builder.canBeUsedAsNewMessage()) {
return Future.error(ArgumentError("Cannot sent message when MessageBuilder doesn't have set either content, embed or files"));
}
await this.interactions.interactionsEndpoints.respondCreateResponse(
this.interaction.token,
this.interaction.id.toString(),
builder,
hidden,
_respondOpcode
);
}
_hasAcked = true;
}