Class: Discordrb::Events::InteractionCreateEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discordrb/events/interactions.rb

Overview

Generic subclass for interaction events

Direct Known Subclasses

ApplicationCommandEvent, ComponentEvent

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ InteractionCreateEvent



32
33
34
35
# File 'lib/discordrb/events/interactions.rb', line 32

def initialize(data, bot)
  @interaction = Discordrb::Interaction.new(data, bot)
  @bot = bot
end

Instance Attribute Details

#channelChannel (readonly)



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

#channel_idInteger (readonly)



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

#interactionInteraction (readonly)



10
11
12
# File 'lib/discordrb/events/interactions.rb', line 10

def interaction
  @interaction
end

#serverServer? (readonly)

See Also:



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

#server_idInteger (readonly)



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

#typeInteger (readonly)

See Also:



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

#userUser (readonly)

See Also:



30
# File 'lib/discordrb/events/interactions.rb', line 30

delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction

Instance Method Details

#defer(flags: 0, ephemeral: true) ⇒ Object

Defer an interaction, setting a temporary response that can be later overriden by Interaction#send_message. This method is used when you want to use a single message for your response but require additional processing time, or to simply ack an interaction so an error is not displayed.



46
47
48
# File 'lib/discordrb/events/interactions.rb', line 46

def defer(flags: 0, ephemeral: true)
  @interaction.defer(flags: flags, ephemeral: ephemeral)
end

#defer_updateObject

Defer an update to an interaction. This is can only currently used by Button interactions.



84
85
86
# File 'lib/discordrb/events/interactions.rb', line 84

def defer_update
  @interaction.defer_update
end

#delete_message(message) ⇒ Object



79
80
81
# File 'lib/discordrb/events/interactions.rb', line 79

def delete_message(message)
  @interaction.delete_message(message)
end

#delete_responseObject

Delete the original interaction response.



64
65
66
# File 'lib/discordrb/events/interactions.rb', line 64

def delete_response
  @interaction.delete_response
end

#edit_message(message, content: nil, embeds: nil, allowed_mentions: nil) {|builder| ... } ⇒ Object

Yield Parameters:

  • builder (Webhooks::Builder)

    An optional message builder. Arguments passed to the method overwrite builder data.



74
75
76
# File 'lib/discordrb/events/interactions.rb', line 74

def edit_message(message, content: nil, embeds: nil, allowed_mentions: nil, &block)
  @interaction.edit_message(message, content: content, embeds: embeds, allowed_mentions: allowed_mentions, &block)
end

#edit_response(content: nil, embeds: nil, allowed_mentions: nil, components: nil) {|builder| ... } ⇒ InteractionMessage

Edit the original response to this interaction.

Yield Parameters:

  • builder (Webhooks::Builder)

    An optional message builder. Arguments passed to the method overwrite builder data.



59
60
61
# File 'lib/discordrb/events/interactions.rb', line 59

def edit_response(content: nil, embeds: nil, allowed_mentions: nil, components: nil, &block)
  @interaction.edit_response(content: content, embeds: embeds, allowed_mentions: allowed_mentions, components: components, &block)
end

#respond(content: nil, tts: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: nil, wait: false, components: nil) {|builder, view| ... } ⇒ Object

Respond to the creation of this interaction. An interaction must be responded to or deferred, The response may be modified with Interaction#edit_response or deleted with Interaction#delete_response. Further messages can be sent with Interaction#send_message.

Yield Parameters:

  • builder (Webhooks::Builder)

    An optional message builder. Arguments passed to the method overwrite builder data.

  • view (Webhooks::View)

    A builder for creating interaction components.



38
39
40
41
42
43
# File 'lib/discordrb/events/interactions.rb', line 38

def respond(content: nil, tts: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: nil, wait: false, components: nil, &block)
  @interaction.respond(
    content: content, tts: tts, embeds: embeds, allowed_mentions: allowed_mentions,
    flags: flags, ephemeral: ephemeral, wait: wait, components: components, &block
  )
end

#send_message(content: nil, embeds: nil, tts: false, allowed_mentions: nil, flags: 0, ephemeral: nil, components: nil) {|builder| ... } ⇒ Object

Yield Parameters:

  • builder (Webhooks::Builder)

    An optional message builder. Arguments passed to the method overwrite builder data.



69
70
71
# File 'lib/discordrb/events/interactions.rb', line 69

def send_message(content: nil, embeds: nil, tts: false, allowed_mentions: nil, flags: 0, ephemeral: nil, components: nil, &block)
  @interaction.send_message(content: content, embeds: embeds, tts: tts, allowed_mentions: allowed_mentions, flags: flags, ephemeral: ephemeral, components: components, &block)
end

#update_message(content: nil, tts: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: nil, wait: false, components: nil) {|builder, view| ... } ⇒ Object

Respond to the creation of this interaction. An interaction must be responded to or deferred, The response may be modified with Interaction#edit_response or deleted with Interaction#delete_response. Further messages can be sent with Interaction#send_message.

Yield Parameters:

  • builder (Webhooks::Builder)

    An optional message builder. Arguments passed to the method overwrite builder data.

  • view (Webhooks::View)

    A builder for creating interaction components.



51
52
53
54
55
56
# File 'lib/discordrb/events/interactions.rb', line 51

def update_message(content: nil, tts: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: nil, wait: false, components: nil, &block)
  @interaction.update_message(
    content: content, tts: tts, embeds: embeds, allowed_mentions: allowed_mentions,
    flags: flags, ephemeral: ephemeral, wait: wait, components: components, &block
  )
end