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:



623
624
625
# File 'lib/discordrb/data/interaction.rb', line 623

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



620
621
622
# File 'lib/discordrb/data/interaction.rb', line 620

def author
  @author
end

#channel_idInteger (readonly)

Returns:



635
636
637
# File 'lib/discordrb/data/interaction.rb', line 635

def channel_id
  @channel_id
end

#componentsArray<Component> (readonly)

Returns:

  • (Array<Component>)


641
642
643
# File 'lib/discordrb/data/interaction.rb', line 641

def components
  @components
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



599
600
601
# File 'lib/discordrb/data/interaction.rb', line 599

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


614
615
616
# File 'lib/discordrb/data/interaction.rb', line 614

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


611
612
613
# File 'lib/discordrb/data/interaction.rb', line 611

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



626
627
628
# File 'lib/discordrb/data/interaction.rb', line 626

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



632
633
634
# File 'lib/discordrb/data/interaction.rb', line 632

def flags
  @flags
end

#idInteger (readonly)

Returns:



617
618
619
# File 'lib/discordrb/data/interaction.rb', line 617

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



596
597
598
# File 'lib/discordrb/data/interaction.rb', line 596

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



629
630
631
# File 'lib/discordrb/data/interaction.rb', line 629

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


638
639
640
# File 'lib/discordrb/data/interaction.rb', line 638

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.



602
603
604
# File 'lib/discordrb/data/interaction.rb', line 602

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


608
609
610
# File 'lib/discordrb/data/interaction.rb', line 608

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


605
606
607
# File 'lib/discordrb/data/interaction.rb', line 605

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



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

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



709
710
711
# File 'lib/discordrb/data/interaction.rb', line 709

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.



718
719
720
# File 'lib/discordrb/data/interaction.rb', line 718

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.



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

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.



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

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.



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

def server
  @bot.server(@server_id)
end