Class: Rubycord::Interactions::Message

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

Overview

A message partial for interactions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rubycord::IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#attachmentsAttachment (readonly)

Returns:



685
686
687
# File 'lib/rubycord/data/interaction.rb', line 685

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



682
683
684
# File 'lib/rubycord/data/interaction.rb', line 682

def author
  @author
end

#channel_idInteger (readonly)

Returns:



697
698
699
# File 'lib/rubycord/data/interaction.rb', line 697

def channel_id
  @channel_id
end

#componentsArray<Component> (readonly)

Returns:

  • (Array<Component>)


703
704
705
# File 'lib/rubycord/data/interaction.rb', line 703

def components
  @components
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



661
662
663
# File 'lib/rubycord/data/interaction.rb', line 661

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


676
677
678
# File 'lib/rubycord/data/interaction.rb', line 676

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


673
674
675
# File 'lib/rubycord/data/interaction.rb', line 673

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



688
689
690
# File 'lib/rubycord/data/interaction.rb', line 688

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



694
695
696
# File 'lib/rubycord/data/interaction.rb', line 694

def flags
  @flags
end

#idInteger (readonly)

Returns:



679
680
681
# File 'lib/rubycord/data/interaction.rb', line 679

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



658
659
660
# File 'lib/rubycord/data/interaction.rb', line 658

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



691
692
693
# File 'lib/rubycord/data/interaction.rb', line 691

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


700
701
702
# File 'lib/rubycord/data/interaction.rb', line 700

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.



664
665
666
# File 'lib/rubycord/data/interaction.rb', line 664

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


670
671
672
# File 'lib/rubycord/data/interaction.rb', line 670

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


667
668
669
# File 'lib/rubycord/data/interaction.rb', line 667

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



760
761
762
# File 'lib/rubycord/data/interaction.rb', line 760

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



772
773
774
# File 'lib/rubycord/data/interaction.rb', line 772

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.



781
782
783
# File 'lib/rubycord/data/interaction.rb', line 781

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



748
749
750
# File 'lib/rubycord/data/interaction.rb', line 748

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.



767
768
769
# File 'lib/rubycord/data/interaction.rb', line 767

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



754
755
756
# File 'lib/rubycord/data/interaction.rb', line 754

def server
  @bot.server(@server_id)
end

#to_messageRubycord::Message Also known as: message

Returns:



786
787
788
# File 'lib/rubycord/data/interaction.rb', line 786

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