Class: Discordrb::Interactions::Message

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

Overview

A message partial for interactions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Discordrb::IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#attachmentsAttachment (readonly)

Returns:



918
919
920
# File 'lib/discordrb/data/interaction.rb', line 918

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



915
916
917
# File 'lib/discordrb/data/interaction.rb', line 915

def author
  @author
end

#channel_idInteger (readonly)

Returns:



930
931
932
# File 'lib/discordrb/data/interaction.rb', line 930

def channel_id
  @channel_id
end

#componentsArray<Component> (readonly)

Returns:

  • (Array<Component>)


936
937
938
# File 'lib/discordrb/data/interaction.rb', line 936

def components
  @components
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



894
895
896
# File 'lib/discordrb/data/interaction.rb', line 894

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


909
910
911
# File 'lib/discordrb/data/interaction.rb', line 909

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


906
907
908
# File 'lib/discordrb/data/interaction.rb', line 906

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



921
922
923
# File 'lib/discordrb/data/interaction.rb', line 921

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



927
928
929
# File 'lib/discordrb/data/interaction.rb', line 927

def flags
  @flags
end

#idInteger (readonly)

Returns:



912
913
914
# File 'lib/discordrb/data/interaction.rb', line 912

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



891
892
893
# File 'lib/discordrb/data/interaction.rb', line 891

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



924
925
926
# File 'lib/discordrb/data/interaction.rb', line 924

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


933
934
935
# File 'lib/discordrb/data/interaction.rb', line 933

def message_reference
  @message_reference
end

#pinnedtrue, false (readonly)

Returns Whether this message is pinned in the channel it belongs to.

Returns:

  • (true, false)

    Whether this message is pinned in the channel it belongs to.



897
898
899
# File 'lib/discordrb/data/interaction.rb', line 897

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


903
904
905
# File 'lib/discordrb/data/interaction.rb', line 903

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


900
901
902
# File 'lib/discordrb/data/interaction.rb', line 900

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



993
994
995
# File 'lib/discordrb/data/interaction.rb', line 993

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



1005
1006
1007
# File 'lib/discordrb/data/interaction.rb', line 1005

def delete
  @interaction.delete_message(@id)
end

#edit(content: nil, embeds: nil, allowed_mentions: nil, components: nil, attachments: nil) {|builder| ... } ⇒ Object

Edit this message's data.

Parameters:

  • content (String) (defaults to: nil)

    The content of the message.

  • embeds (Array<Hash, Webhooks::Embed>) (defaults to: nil)

    The embeds for the message.

  • allowed_mentions (Hash, AllowedMentions) (defaults to: nil)

    Mentions that can ping on this message.

Yield Parameters:

  • builder (Webhooks::Builder)

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



1014
1015
1016
# File 'lib/discordrb/data/interaction.rb', line 1014

def edit(content: nil, embeds: nil, allowed_mentions: nil, components: nil, attachments: nil, &block)
  @interaction.edit_message(@id, content: content, embeds: embeds, allowed_mentions: allowed_mentions, components: components, attachments: attachments, &block)
end

#memberMember?

Returns This will return nil if the bot does not have access to the server the interaction originated in.

Returns:

  • (Member, nil)

    This will return nil if the bot does not have access to the server the interaction originated in.



981
982
983
# File 'lib/discordrb/data/interaction.rb', line 981

def member
  server&.member(@user.id)
end

#respond(content: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: true, components: nil, attachments: nil) {|builder| ... } ⇒ Object

Respond to this message.

Parameters:

  • content (String) (defaults to: nil)

    The content of the message.

  • tts (true, false)
  • embeds (Array<Hash, Webhooks::Embed>) (defaults to: nil)

    The embeds for the message.

  • allowed_mentions (Hash, AllowedMentions) (defaults to: nil)

    Mentions that can ping on this message.

  • flags (Integer) (defaults to: 0)

    Message flags.

  • ephemeral (true, false) (defaults to: true)

    Whether this message should only be visible to the interaction initiator.

  • attachments (Array<File>) (defaults to: nil)

    Files that can be referenced in embeds and components via attachment://file.png.

  • has_components (true, false)

    Whether this message includes any V2 components. Enabling this disables content and embeds.

Yield Parameters:

  • builder (Webhooks::Builder)

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



1000
1001
1002
# File 'lib/discordrb/data/interaction.rb', line 1000

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

#serverServer?

Returns This will return nil if the bot does not have access to the server the interaction originated in.

Returns:

  • (Server, nil)

    This will return nil if the bot does not have access to the server the interaction originated in.



987
988
989
# File 'lib/discordrb/data/interaction.rb', line 987

def server
  @bot.server(@server_id)
end

#to_messageDiscordrb::Message Also known as: message

Returns:



1019
1020
1021
# File 'lib/discordrb/data/interaction.rb', line 1019

def to_message
  Discordrb::Message.new(@data, @bot)
end