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

#attachments ⇒ Attachment (readonly)

Returns:



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

def attachments
  @attachments
end

#author ⇒ User (readonly)

Returns The user of the application.

Returns:

  • (User) —

    The user of the application.



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

def author
  @author
end

#channel_id ⇒ Integer (readonly)

Returns:



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

def channel_id
  @channel_id
end

#components ⇒ Array<Component> (readonly)

Returns:

  • (Array<Component>)


943
944
945
# File 'lib/discordrb/data/interaction.rb', line 943

def components
  @components
end

#content ⇒ String? (readonly)

Returns The content of the message.

Returns:

  • (String, nil) —

    The content of the message.



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

def content
  @content
end

#edited ⇒ true, false (readonly)

Returns:

  • (true, false)


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

def edited
  @edited
end

#edited_timestamp ⇒ Time? (readonly)

Returns:

  • (Time, nil)


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

def edited_timestamp
  @edited_timestamp
end

#embeds ⇒ Array<Embed> (readonly)

Returns:



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

def embeds
  @embeds
end

#flags ⇒ Integer (readonly)

Returns:



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

def flags
  @flags
end

#id ⇒ Integer (readonly)

Returns:



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

def id
  @id
end

#interaction ⇒ Interaction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction) —

    The interaction that created this message.



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

def interaction
  @interaction
end

#mentions ⇒ Array<User> (readonly)

Returns:



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

def mentions
  @mentions
end

#message_reference ⇒ Hash? (readonly)

Returns:

  • (Hash, nil)


940
941
942
# File 'lib/discordrb/data/interaction.rb', line 940

def message_reference
  @message_reference
end

#pinned ⇒ true, 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.



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

def pinned
  @pinned
end

#timestamp ⇒ Time (readonly)

Returns:

  • (Time)


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

def timestamp
  @timestamp
end

#tts ⇒ true, false (readonly)

Returns:

  • (true, false)


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

def tts
  @tts
end

Instance Method Details

#channel ⇒ Channel

Returns The channel the interaction originates from.

Returns:

  • (Channel) —

    The channel the interaction originates from.

Raises:



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

def channel
  @bot.channel(@channel_id)
end

#delete ⇒ Object

Delete this message.



1012
1013
1014
# File 'lib/discordrb/data/interaction.rb', line 1012

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.



1021
1022
1023
# File 'lib/discordrb/data/interaction.rb', line 1021

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

#member ⇒ Member?

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.



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

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 sending content, polls, and embeds.

  • poll (Hash, Poll::Builder, Poll, nil) —

    The poll that should be attached to this message.

Yield Parameters:

  • builder (Webhooks::Builder) —

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



1007
1008
1009
# File 'lib/discordrb/data/interaction.rb', line 1007

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

#server ⇒ Server?

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.



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

def server
  @bot.server(@server_id)
end

#to_message ⇒ Discordrb::Message Also known as: message

Returns:



1026
1027
1028
# File 'lib/discordrb/data/interaction.rb', line 1026

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