Class: DiscordRDA::MessageFlags

Inherits:
Object
  • Object
show all
Defined in:
lib/discord_rda/entity/support.rb

Overview

Represents message flags

Constant Summary collapse

FLAGS =

Flag bits

{
  crossposted: 1 << 0,
  is_crosspost: 1 << 1,
  suppress_embeds: 1 << 2,
  source_message_deleted: 1 << 3,
  urgent: 1 << 4,
  has_thread: 1 << 5,
  ephemeral: 1 << 6,
  loading: 1 << 7,
  failed_to_mention_some_roles_in_thread: 1 << 8,
  suppress_notifications: 1 << 12,
  is_voice_message: 1 << 13
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = 0) ⇒ MessageFlags

Initialize flags

Parameters:

  • value (Integer) (defaults to: 0)

    Flag value



100
101
102
# File 'lib/discord_rda/entity/support.rb', line 100

def initialize(value = 0)
  @value = value.to_i
end

Instance Attribute Details

#valueInteger (readonly)

Returns Flag value.

Returns:

  • (Integer)

    Flag value



96
97
98
# File 'lib/discord_rda/entity/support.rb', line 96

def value
  @value
end

Instance Method Details

#has?(flag) ⇒ Boolean

Check if a flag is set

Parameters:

  • flag (Symbol)

    Flag name

Returns:

  • (Boolean)

    True if set



107
108
109
110
111
112
# File 'lib/discord_rda/entity/support.rb', line 107

def has?(flag)
  bit = FLAGS[flag.to_sym]
  return false unless bit

  (@value & bit) == bit
end