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:



687
688
689
# File 'lib/discordrb/data/interaction.rb', line 687

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



684
685
686
# File 'lib/discordrb/data/interaction.rb', line 684

def author
  @author
end

#channel_idInteger (readonly)

Returns:



699
700
701
# File 'lib/discordrb/data/interaction.rb', line 699

def channel_id
  @channel_id
end

#componentsArray<Component> (readonly)

Returns:

  • (Array<Component>)


705
706
707
# File 'lib/discordrb/data/interaction.rb', line 705

def components
  @components
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



663
664
665
# File 'lib/discordrb/data/interaction.rb', line 663

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


678
679
680
# File 'lib/discordrb/data/interaction.rb', line 678

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


675
676
677
# File 'lib/discordrb/data/interaction.rb', line 675

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



690
691
692
# File 'lib/discordrb/data/interaction.rb', line 690

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



696
697
698
# File 'lib/discordrb/data/interaction.rb', line 696

def flags
  @flags
end

#idInteger (readonly)

Returns:



681
682
683
# File 'lib/discordrb/data/interaction.rb', line 681

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



660
661
662
# File 'lib/discordrb/data/interaction.rb', line 660

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



693
694
695
# File 'lib/discordrb/data/interaction.rb', line 693

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


702
703
704
# File 'lib/discordrb/data/interaction.rb', line 702

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.



666
667
668
# File 'lib/discordrb/data/interaction.rb', line 666

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


672
673
674
# File 'lib/discordrb/data/interaction.rb', line 672

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


669
670
671
# File 'lib/discordrb/data/interaction.rb', line 669

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



762
763
764
# File 'lib/discordrb/data/interaction.rb', line 762

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



774
775
776
# File 'lib/discordrb/data/interaction.rb', line 774

def delete
  @interaction.delete_message(@id)
end

#edit(content: nil, embeds: nil, allowed_mentions: nil, components: 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.



783
784
785
# File 'lib/discordrb/data/interaction.rb', line 783

def edit(content: nil, embeds: nil, allowed_mentions: nil, components: nil, &block)
  @interaction.edit_message(@id, content: content, embeds: embeds, allowed_mentions: allowed_mentions, components: components, &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.



750
751
752
# File 'lib/discordrb/data/interaction.rb', line 750

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

#respond(content: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: true, components: 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.

Yield Parameters:

  • builder (Webhooks::Builder)

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



769
770
771
# File 'lib/discordrb/data/interaction.rb', line 769

def respond(content: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: true, components: nil, &block)
  @interaction.send_message(content: content, embeds: embeds, allowed_mentions: allowed_mentions, flags: flags, ephemeral: ephemeral, components: components, &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.



756
757
758
# File 'lib/discordrb/data/interaction.rb', line 756

def server
  @bot.server(@server_id)
end

#to_messageDiscordrb::Message Also known as: message

Returns:



788
789
790
# File 'lib/discordrb/data/interaction.rb', line 788

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