Class: Discordrb::Interactions::Metadata

Inherits:
Object
  • Object
show all
Includes:
Discordrb::IDObject
Defined in:
lib/discordrb/data/interaction.rb

Overview

Supplemental metadata about an interaction.

Instance Attribute Summary collapse

Attributes included from Discordrb::IDObject

#id

Instance Method Summary collapse

Methods included from Discordrb::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.



1051
1052
1053
# File 'lib/discordrb/data/interaction.rb', line 1051

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.



1054
1055
1056
# File 'lib/discordrb/data/interaction.rb', line 1054

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.



1045
1046
1047
# File 'lib/discordrb/data/interaction.rb', line 1045

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.



1042
1043
1044
# File 'lib/discordrb/data/interaction.rb', line 1042

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.



1048
1049
1050
# File 'lib/discordrb/data/interaction.rb', line 1048

def 
  @triggering_metadata
end

#typeInteger (readonly)

Returns the type of the interaction.

Returns:

  • (Integer)

    the type of the interaction.



1036
1037
1038
# File 'lib/discordrb/data/interaction.rb', line 1036

def type
  @type
end

#userUser (readonly)

Returns the user that initiated the interaction.

Returns:

  • (User)

    the user that initiated the interaction.



1039
1040
1041
# File 'lib/discordrb/data/interaction.rb', line 1039

def user
  @user
end

Instance Method Details

#command?true, false

Returns whether or not the interaction metadata is for an application command.

Returns:

  • (true, false)

    whether or not the interaction metadata is for an application command.



1115
1116
1117
1118
1119
# File 'lib/discordrb/data/interaction.rb', line 1115

Interaction::TYPES.each do |name, value|
  define_method("#{name}?") do
    @type == value
  end
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.



1115
1116
1117
1118
1119
# File 'lib/discordrb/data/interaction.rb', line 1115

Interaction::TYPES.each do |name, value|
  define_method("#{name}?") do
    @type == value
  end
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.



1095
1096
1097
1098
1099
# File 'lib/discordrb/data/interaction.rb', line 1095

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.



1115
1116
1117
1118
1119
# File 'lib/discordrb/data/interaction.rb', line 1115

Interaction::TYPES.each do |name, value|
  define_method("#{name}?") do
    @type == value
  end
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.



1103
1104
1105
1106
1107
# File 'lib/discordrb/data/interaction.rb', line 1103

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.



1081
1082
1083
# File 'lib/discordrb/data/interaction.rb', line 1081

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.



1087
1088
1089
1090
1091
# File 'lib/discordrb/data/interaction.rb', line 1087

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.



1074
1075
1076
# File 'lib/discordrb/data/interaction.rb', line 1074

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