Class: OnyxCord::Interactions::Metadata

Inherits:
Object
  • Object
show all
Includes:
OnyxCord::IDObject
Defined in:
lib/onyxcord/interactions/internal/metadata.rb

Overview

Supplemental metadata about an interaction.

Instance Attribute Summary collapse

Attributes included from OnyxCord::IDObject

#id

Instance Method Summary collapse

Methods included from OnyxCord::IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#interacted_message_idInteger? (readonly)

Returns the ID of the message that contained the interactive message component.

Returns:

  • (Integer, nil)

    the ID of the message that contained the interactive message component.



27
28
29
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 27

def interacted_message_id
  @interacted_message_id
end

#original_response_message_idInteger? (readonly)

Returns the ID the original response message; only present on follow-up messages.

Returns:

  • (Integer, nil)

    the ID the original response message; only present on follow-up messages.



30
31
32
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 30

def original_response_message_id
  @original_response_message_id
end

#target_message_idInteger? (readonly)

Returns the ID of the message the command was ran on.

Returns:

  • (Integer, nil)

    the ID of the message the command was ran on.



21
22
23
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 21

def target_message_id
  @target_message_id
end

#target_userUser? (readonly)

Returns the user that the command was ran on.

Returns:

  • (User, nil)

    the user that the command was ran on.



18
19
20
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 18

def target_user
  @target_user
end

#triggering_metadataMetadata? (readonly)

Returns the metadata for the interaction that opened the modal.

Returns:

  • (Metadata, nil)

    the metadata for the interaction that opened the modal.



24
25
26
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 24

def 
  @triggering_metadata
end

#typeInteger (readonly)

Returns the type of the interaction.

Returns:

  • (Integer)

    the type of the interaction.



12
13
14
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 12

def type
  @type
end

#userUser (readonly)

Returns the user that initiated the interaction.

Returns:

  • (User)

    the user that initiated the interaction.



15
16
17
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 15

def user
  @user
end

Instance Method Details

#command?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 91

def command?
  @type == 1
end

#component?true, false

Returns whether or not the interaction metadata is for a message component.

Returns:

  • (true, false)

    whether or not the interaction metadata is for a message component.



91
92
93
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 91

def command?
  @type == 1
end

#interacted_messageMessage?

Attempt to fetch the message that contained the interatctive component.

Returns:

  • (Message, nil)

    the interacted message with the component, or nil if it couldn't be found.



71
72
73
74
75
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 71

def interacted_message
  return unless @interacted_message_id

  @interacted_message ||= @message.channel.message(@interacted_message_id)
end

Returns whether or not the interaction metadata is for a modal submission.

Returns:

  • (true, false)

    whether or not the interaction metadata is for a modal submission.



91
92
93
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 91

def command?
  @type == 1
end

#original_response_messageMessage?

Attempt to fetch the original response message of the interaction.

Returns:

  • (Message, nil)

    the original response message of the interaction, or nil if it couldn't be found.



79
80
81
82
83
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 79

def original_response_message
  return unless @original_response_message_id

  @original_response_message ||= @message.channel.message(@original_response_message_id)
end

#server_integration?true, false

Check if the interaction was triggered by a server by installed the application.

Returns:

  • (true, false)

    whether or not the application was installed by the server where this interaction originates from.



57
58
59
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 57

def server_integration?
  @integration_owners[0] == @message.server.id
end

#target_messageMessage?

Attempt to fetch the target message of the interaction.

Returns:

  • (Message, nil)

    the target message of the interaction, or nil if it couldn't be found.



63
64
65
66
67
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 63

def target_message
  return unless @target_message_id

  @target_message ||= @message.channel.message(@target_message_id)
end

#user_integration?true, false

Check if the interaction was triggered by a user by installed the application.

Returns:

  • (true, false)

    whether or not the application was installed by the user who initiated this interaction.



50
51
52
# File 'lib/onyxcord/interactions/internal/metadata.rb', line 50

def user_integration?
  @integration_owners[1] == @user.id
end