Module: Rubycord::AttachmentAttributes

Included in:
Attachment
Defined in:
lib/rubycord/data/attachment.rb

Overview

Mixin for the attributes attachments should have

Constant Summary collapse

FLAGS =

Types of attachment's flags mapped to their API value. List of flags available here: https://discord.com/developers/docs/resources/message#attachment-object-attachment-flags

{
  remix: 1 << 2,  # IS_REMIX : this attachment has been edited using the remix feature on mobile
  spoiler: 1 << 3 #          : this attachment has been set to spoiler mode (not officially listed in doc, but seems to be the case after several tests)
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flagsInteger (readonly)

Returns attachment flags combined as a bitfield.

Returns:

  • (Integer)

    attachment flags combined as a bitfield.



12
13
14
# File 'lib/rubycord/data/attachment.rb', line 12

def flags
  @flags
end

Instance Method Details

#remix?true, false

Returns whether this file has flag IS_REMIX.

Returns:

  • (true, false)

    whether this file has flag IS_REMIX.



19
20
21
22
23
# File 'lib/rubycord/data/attachment.rb', line 19

FLAGS.each do |name, value|
  define_method(:"#{name}?") do
    (@flags & value).positive?
  end
end

#spoiler?true, false

Note:

Unofficial flag

Returns whether this file has flag IS_SPOILER.

Returns:

  • (true, false)

    whether this file has flag IS_SPOILER.



19
20
21
22
23
# File 'lib/rubycord/data/attachment.rb', line 19

FLAGS.each do |name, value|
  define_method(:"#{name}?") do
    (@flags & value).positive?
  end
end