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.



1058
1059
1060
# File 'lib/discordrb/data/interaction.rb', line 1058

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.



1061
1062
1063
# File 'lib/discordrb/data/interaction.rb', line 1061

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.



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

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.



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

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.



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

def 
  @triggering_metadata
end

#typeInteger (readonly)

Returns the type of the interaction.

Returns:

  • (Integer)

    the type of the interaction.



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

def type
  @type
end

#userUser (readonly)

Returns the user that initiated the interaction.

Returns:

  • (User)

    the user that initiated the interaction.



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

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.



1122
1123
1124
1125
1126
# File 'lib/discordrb/data/interaction.rb', line 1122

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.



1122
1123
1124
1125
1126
# File 'lib/discordrb/data/interaction.rb', line 1122

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.



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

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.



1122
1123
1124
1125
1126
# File 'lib/discordrb/data/interaction.rb', line 1122

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.



1110
1111
1112
1113
1114
# File 'lib/discordrb/data/interaction.rb', line 1110

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.



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

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.



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

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.



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

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