Class: OnyxCord::Interactions::Message

Inherits:
Object
  • Object
show all
Includes:
OnyxCord::IDObject
Defined in:
lib/onyxcord/interactions/internal/message.rb

Overview

A message partial for interactions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OnyxCord::IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#attachmentsAttachment (readonly)

Returns:



39
40
41
# File 'lib/onyxcord/interactions/internal/message.rb', line 39

def attachments
  @attachments
end

#authorUser (readonly)

Returns The user of the application.

Returns:

  • (User)

    The user of the application.



36
37
38
# File 'lib/onyxcord/interactions/internal/message.rb', line 36

def author
  @author
end

#channel_idInteger (readonly)

Returns:



51
52
53
# File 'lib/onyxcord/interactions/internal/message.rb', line 51

def channel_id
  @channel_id
end

#componentsArray<Component> (readonly)

Returns:

  • (Array<Component>)


57
58
59
# File 'lib/onyxcord/interactions/internal/message.rb', line 57

def components
  @components
end

#contentString? (readonly)

Returns The content of the message.

Returns:

  • (String, nil)

    The content of the message.



15
16
17
# File 'lib/onyxcord/interactions/internal/message.rb', line 15

def content
  @content
end

#editedtrue, false (readonly)

Returns:

  • (true, false)


30
31
32
# File 'lib/onyxcord/interactions/internal/message.rb', line 30

def edited
  @edited
end

#edited_timestampTime? (readonly)

Returns:

  • (Time, nil)


27
28
29
# File 'lib/onyxcord/interactions/internal/message.rb', line 27

def edited_timestamp
  @edited_timestamp
end

#embedsArray<Embed> (readonly)

Returns:



42
43
44
# File 'lib/onyxcord/interactions/internal/message.rb', line 42

def embeds
  @embeds
end

#flagsInteger (readonly)

Returns:



48
49
50
# File 'lib/onyxcord/interactions/internal/message.rb', line 48

def flags
  @flags
end

#idInteger (readonly)

Returns:



33
34
35
# File 'lib/onyxcord/interactions/internal/message.rb', line 33

def id
  @id
end

#interactionInteraction (readonly)

Returns The interaction that created this message.

Returns:

  • (Interaction)

    The interaction that created this message.



12
13
14
# File 'lib/onyxcord/interactions/internal/message.rb', line 12

def interaction
  @interaction
end

#mentionsArray<User> (readonly)

Returns:



45
46
47
# File 'lib/onyxcord/interactions/internal/message.rb', line 45

def mentions
  @mentions
end

#message_referenceHash? (readonly)

Returns:

  • (Hash, nil)


54
55
56
# File 'lib/onyxcord/interactions/internal/message.rb', line 54

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.



18
19
20
# File 'lib/onyxcord/interactions/internal/message.rb', line 18

def pinned
  @pinned
end

#timestampTime (readonly)

Returns:

  • (Time)


24
25
26
# File 'lib/onyxcord/interactions/internal/message.rb', line 24

def timestamp
  @timestamp
end

#ttstrue, false (readonly)

Returns:

  • (true, false)


21
22
23
# File 'lib/onyxcord/interactions/internal/message.rb', line 21

def tts
  @tts
end

Instance Method Details

#channelChannel

Returns The channel the interaction originates from.

Returns:

  • (Channel)

    The channel the interaction originates from.

Raises:



114
115
116
# File 'lib/onyxcord/interactions/internal/message.rb', line 114

def channel
  @bot.channel(@channel_id)
end

#deleteObject

Delete this message.



126
127
128
# File 'lib/onyxcord/interactions/internal/message.rb', line 126

def delete
  @interaction.delete_message(@id)
end

#edit(content: nil, embeds: nil, allowed_mentions: nil, components: nil, attachments: nil) {|builder, view| ... } ⇒ 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.

  • view (Webhooks::View)

    A builder for creating interaction components.



135
136
137
# File 'lib/onyxcord/interactions/internal/message.rb', line 135

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

#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.



102
103
104
# File 'lib/onyxcord/interactions/internal/message.rb', line 102

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

#respond(content: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: true, components: nil, attachments: nil) {|builder, view| ... } ⇒ Object Also known as: reply

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.

  • view (Webhooks::View)

    A builder for creating interaction components.



121
122
123
# File 'lib/onyxcord/interactions/internal/message.rb', line 121

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

#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.



108
109
110
# File 'lib/onyxcord/interactions/internal/message.rb', line 108

def server
  @bot.server(@server_id)
end

#to_messageOnyxCord::Message Also known as: message

Returns:



140
141
142
# File 'lib/onyxcord/interactions/internal/message.rb', line 140

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