mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
feat(bot): add interaction.sendFollowupMessage() (#4701)
* feat(bot): add interaction.sendFollowupMessage * fix: sendFollowupMessage return type Co-authored-by: Fleny <Fleny113@outlook.com> --------- Co-authored-by: Fleny <Fleny113@outlook.com>
This commit is contained in:
@@ -151,6 +151,7 @@ export interface TransformersDesiredPropertiesMetadata extends DesiredProperties
|
||||
interaction: {
|
||||
dependencies: {
|
||||
respond: ['type', 'token', 'id'];
|
||||
sendFollowupMessage: ['token'];
|
||||
edit: ['type', 'token', 'id'];
|
||||
deferEdit: ['type', 'token', 'id'];
|
||||
defer: ['type', 'token', 'id'];
|
||||
|
||||
@@ -60,7 +60,7 @@ export const baseInteraction: SetupDesiredProps<Interaction, CompleteDesiredProp
|
||||
}
|
||||
|
||||
// Since this has already been given a response, any further responses must be followups.
|
||||
if (this.acknowledged) return await this.bot.helpers.sendFollowupMessage(this.token, response);
|
||||
if (this.acknowledged) return await this.sendFollowupMessage(response);
|
||||
|
||||
const result = await this.bot.helpers.sendInteractionResponse(
|
||||
this.id,
|
||||
@@ -71,6 +71,12 @@ export const baseInteraction: SetupDesiredProps<Interaction, CompleteDesiredProp
|
||||
this.acknowledged = true;
|
||||
return result;
|
||||
},
|
||||
async sendFollowupMessage(response) {
|
||||
// If user provides a string, change it to a response object
|
||||
if (typeof response === 'string') response = { content: response };
|
||||
|
||||
return await this.bot.helpers.sendFollowupMessage(this.token, response);
|
||||
},
|
||||
async edit(response, messageId, options) {
|
||||
if (this.type === InteractionTypes.ApplicationCommandAutocomplete) throw new Error('Cannot edit an autocomplete interaction.');
|
||||
|
||||
|
||||
@@ -988,7 +988,7 @@ export interface Interaction {
|
||||
* Sends a response to an interaction.
|
||||
*
|
||||
* @remarks
|
||||
* This will send a ChannelMessageWithSource, ApplicationCommandAutocompleteResult or Modal response based on the type of the interaction you are responding to.
|
||||
* If you did not provide a response type, this will send a ChannelMessageWithSource, ApplicationCommandAutocompleteResult or Modal response based on the type of the interaction you are responding to.
|
||||
*
|
||||
* If the interaction has been already acknowledged, indicated by {@link Interaction.acknowledged}, it will send a followup message instead.
|
||||
*/
|
||||
@@ -996,6 +996,8 @@ export interface Interaction {
|
||||
response: string | InteractionCallbackData,
|
||||
options?: { isPrivate?: boolean; withResponse?: boolean; type?: InteractionResponseTypes },
|
||||
) => Promise<Message | InteractionCallbackResponse | void>;
|
||||
/** Sends a followup message to an interaction. */
|
||||
sendFollowupMessage: (response: string | InteractionCallbackData) => Promise<Message>;
|
||||
/**
|
||||
* Edit the original response of an interaction or a followup if the message id is provided.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user