Class: Discordrb::Events::InteractionCreateEvent
- Defined in:
- lib/discordrb/events/interactions.rb
Overview
Generic subclass for interaction events
Direct Known Subclasses
Instance Attribute Summary collapse
- #channel ⇒ Channel readonly
- #channel_id ⇒ Integer readonly
-
#interaction ⇒ Interaction
readonly
The interaction for this event.
- #server ⇒ Server? readonly
- #server_id ⇒ Integer readonly
- #type ⇒ Integer readonly
- #user ⇒ User readonly
Attributes inherited from Event
Instance Method Summary collapse
-
#defer(flags: 0, ephemeral: true) ⇒ Object
Defer an interaction, setting a temporary response that can be later overriden by Interaction#send_message.
-
#defer_update ⇒ Object
Defer an update to an interaction.
- #delete_message(message) ⇒ Object
-
#delete_response ⇒ Object
Delete the original interaction response.
- #edit_message(message, content: nil, embeds: nil, allowed_mentions: nil) {|builder| ... } ⇒ Object
-
#edit_response(content: nil, embeds: nil, allowed_mentions: nil, components: nil) {|builder| ... } ⇒ InteractionMessage
Edit the original response to this interaction.
- #get_component(custom_id) ⇒ TextInput, ...
-
#initialize(data, bot) ⇒ InteractionCreateEvent
constructor
A new instance of InteractionCreateEvent.
-
#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.
- #send_message(content: nil, embeds: nil, tts: false, allowed_mentions: nil, flags: 0, ephemeral: nil, components: nil) {|builder| ... } ⇒ Object
-
#show_modal(title:, custom_id:, components: nil) {|A| ... } ⇒ Object
Create a modal as a response.
-
#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.
Constructor Details
#initialize(data, bot) ⇒ InteractionCreateEvent
Returns a new instance of 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
#channel ⇒ Channel (readonly)
30 |
# File 'lib/discordrb/events/interactions.rb', line 30 delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction |
#channel_id ⇒ Integer (readonly)
30 |
# File 'lib/discordrb/events/interactions.rb', line 30 delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction |
#interaction ⇒ Interaction (readonly)
Returns The interaction for this event.
10 11 12 |
# File 'lib/discordrb/events/interactions.rb', line 10 def interaction @interaction end |
#server ⇒ Server? (readonly)
30 |
# File 'lib/discordrb/events/interactions.rb', line 30 delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction |
#server_id ⇒ Integer (readonly)
30 |
# File 'lib/discordrb/events/interactions.rb', line 30 delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction |
#type ⇒ Integer (readonly)
30 |
# File 'lib/discordrb/events/interactions.rb', line 30 delegate :type, :server, :server_id, :channel, :channel_id, :user, to: :interaction |
#user ⇒ User (readonly)
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_update ⇒ Object
Defer an update to an interaction. This is can only currently used by Button interactions.
89 90 91 |
# File 'lib/discordrb/events/interactions.rb', line 89 def defer_update @interaction.defer_update end |
#delete_message(message) ⇒ Object
84 85 86 |
# File 'lib/discordrb/events/interactions.rb', line 84 def () @interaction.() end |
#delete_response ⇒ Object
Delete the original interaction response.
69 70 71 |
# File 'lib/discordrb/events/interactions.rb', line 69 def delete_response @interaction.delete_response end |
#edit_message(message, content: nil, embeds: nil, allowed_mentions: nil) {|builder| ... } ⇒ Object
79 80 81 |
# File 'lib/discordrb/events/interactions.rb', line 79 def (, content: nil, embeds: nil, allowed_mentions: nil, &block) @interaction.(, content: content, 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.
64 65 66 |
# File 'lib/discordrb/events/interactions.rb', line 64 def edit_response(content: nil, embeds: nil, allowed_mentions: nil, components: nil, &block) @interaction.edit_response(content: content, embeds: , allowed_mentions: allowed_mentions, components: components, &block) end |
#get_component(custom_id) ⇒ TextInput, ...
94 95 96 |
# File 'lib/discordrb/events/interactions.rb', line 94 def get_component(custom_id) @interaction.get_component(custom_id) 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.
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: , 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
74 75 76 |
# File 'lib/discordrb/events/interactions.rb', line 74 def (content: nil, embeds: nil, tts: false, allowed_mentions: nil, flags: 0, ephemeral: nil, components: nil, &block) @interaction.(content: content, embeds: , tts: tts, allowed_mentions: allowed_mentions, flags: flags, ephemeral: ephemeral, components: components, &block) end |
#show_modal(title:, custom_id:, components: nil) {|A| ... } ⇒ Object
Create a modal as a response.
59 60 61 |
# File 'lib/discordrb/events/interactions.rb', line 59 def show_modal(title:, custom_id:, components: nil, &block) @interaction.show_modal(title: title, custom_id: custom_id, 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.
51 52 53 54 55 56 |
# File 'lib/discordrb/events/interactions.rb', line 51 def (content: nil, tts: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: nil, wait: false, components: nil, &block) @interaction.( content: content, tts: tts, embeds: , allowed_mentions: allowed_mentions, flags: flags, ephemeral: ephemeral, wait: wait, components: components, &block ) end |