Skip to main content
Module

x/harmony/mod.ts>Interaction

An easy to use Discord API Library for Deno.
Go to Latest
class Interaction
extends SnowflakeBase
Re-export
import { Interaction } from "https://deno.land/x/harmony@v2.9.0/mod.ts";

Represents a base Interaction.

There are different types of interactions which have different actions you can perform ("respond") based on. Because of that, Interaction class is extended by those subclasses to structure the code properly.

You will be (most of the time if not all) provided with an Interaction object that is actually one of those subclasses, but just TS-type is Interaction - in that case you use type-guards such as isApplicationCommand, isMessageComponent, etc.

Constructors

new
Interaction(
client: Client,
others: { channel?: TextChannel | GuildTextChannel; guild?: Guild; member?: Member; user: User; message?: Message; },
)

Properties

optional
_httpRespond: (d: InteractionResponsePayload) => unknown
optional
_httpResponded: boolean
applicationID: string
optional
channel: TextChannel | GuildTextChannel

Channel in which Interaction was initiated

Data sent with Interaction. Only applies to Application Command

deferred: boolean

Whether response was deferred or not

optional
guild: Guild

Guild in which Interaction was initiated

optional
guildLocale: string

Guild locale (not present on PING type)

id: string

Interaction ID

optional
locale: string

User locale (not present on PING type)

optional
member: Member

Member object of who initiated the Interaction

optional
message: Message
responded: boolean

Whether we have responded to Interaction or not

token: string

Interaction Token

Type of Interaction

readonly
url: string
user: User

User object of who invoked Interaction

Methods

defer(ephemeral?): Promise<this>

Defer the Interaction i.e. let the user know bot is processing and will respond later. You only have 15 minutes to edit the response!

deleteMessage(msg: Message | string): Promise<this>

Delete a follow-up Message

deleteResponse(): Promise<this>

Delete the original Interaction Response

editMessage(msg: Message | string, data: { content?: string; components?: MessageComponentData[]; embeds?: Array<Embed | EmbedPayload>; file?: MessageAttachment; allowed_mentions?: { parse?: string; roles?: string[]; users?: string[]; everyone?: boolean; }; }): Promise<this>

Edit a Followup message

Edit the original Interaction response

Fetch the Message object of the Interaction Response

Checks whether the Interaction is Application Command

Checks whether the Interaction is for Application Command Option autocompletions

Checks whether the Interaction is Message Component

Checks whether the Interaction is for the modal/form submitted by the user

isPing(): boolean

Checks whether the Interaction is Ping (HTTP only)

reply(content: string): Promise<this>

Reply with a Message to the Interaction

reply(options: InteractionMessageOptions): Promise<this>
reply(content: string, options: InteractionMessageOptions): Promise<this>
respond(data: InteractionResponse): Promise<this>

Respond to an Interaction

send(text?: string | AllWebhookMessageOptions, option?: AllWebhookMessageOptions): Promise<Message>

Send a followup message

showModal(modal: InteractionResponseModal): Promise<this>

Respond with a Modal