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:



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

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



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

def author
  @author
end

#channel_idInteger (readonly)

Returns:



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

def channel_id
  @channel_id
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



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

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


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

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


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

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



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

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



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

def flags
  @flags
end

#idInteger (readonly)

Returns:



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

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



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

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



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

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


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

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.



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

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


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

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


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

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



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

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



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

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.



713
714
715
# File 'lib/discordrb/data/interaction.rb', line 713

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.



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

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.



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

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.



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

def server
  @bot.server(@server_id)
end