# frozen_string_literal: true module DiscordConstants class UserFlags attr_reader :flag, :title def initialize(flag, title) @flag = flag @title = title end def include?(flag) (@flag & flag) == @flag end STAFF = new(1 << 0, "Discord Employee") PARTNER = new(1 << 1, "Discord Partner") HYPESQUAD = new(1 << 2, "Hypesquad Events") BUG_HUNTER_LEVEL_1 = new(1 << 3, "Bug Hunter Level 1") MFA_SMS = new(1 << 4, "2FA SMS") PREMIUM_PROMO_DISMISSED = new(1 << 5, "Premium Promotion Dismissed") HYPESQUAD_BRAVERY = new(1 << 6, "House of Bravery") HYPESQUAD_BRILLIANCE = new(1 << 7, "House of Brilliance") HYPESQUAD_BALANCE = new(1 << 8, "House of Balance") EARLY_SUPPORTER = new(1 << 9, "Early Supporter") PSEUDO_TEAM_USER = new(1 << 10, "Team User") INTERNAL_APPLICATION = new(1 << 11, "Internal Application") SYSTEM = new(1 << 12, "System") HAS_UNREAD_URGENT_MESSAGES = new(1 << 13, "Has Unread Urgent Messages") BUG_HUNTER_LEVEL_2 = new(1 << 14, "Bug Hunter Level 2") # 15 VERIFIED_BOT = new(1 << 16, "Verified Bot") VERIFIED_DEVELOPER = new(1 << 17, "Early Verified Bot Developer") CERTIFIED_MODERATOR = new(1 << 18, "Certified Moderator") BOT_HTTP_INTERACTIONS = new(1 << 19, "Bot HTTP Interactions") SPAMMER = new(1 << 20, "Spammer") # 21 ACTIVE_DEVELOPER = new(1 << 22, "Active Developer") # 23-32 HIGH_GLOBAL_RATE_LIMIT = new(1 << 33, "High Global Rate Limit") DELETED = new(1 << 34, "Deleted") DISABLED_SUSPICIOUS_ACTIVITY = new(1 << 35, "Disabled Suspicious Activity") SELF_DELETED = new(1 << 36, "Self Deleted") PREMIUM_DISCRIMINATOR = new(1 << 37, "Premium Discriminator") USED_DESKTOP_CLIENT = new(1 << 38, "Used Desktop Client") USED_WEB_CLIENT = new(1 << 39, "Used Web Client") USED_MOBILE_CLIENT = new(1 << 40, "Used Mobile Client") DISABLED = new(1 << 41, "Disabled") # 42 VERIFIED_EMAIL = new(1 << 43, "Verified Email") QUARANTINED = new(1 << 44, "Quarantined") # 45-49 COLLABORATOR = new(1 << 50, "Collaborator") RESTRICTED_COLLABORATOR = new(1 << 51, "Restricted Collaborator") def self.parse_flags(flags) flags = flags.to_i return [] if flags == 0 constants.filter { |c| const_get(c).include?(flags) }.map { |c| const_get(c) } end end module InteractionTypes PING = 1 APPLICATION_COMMAND = 2 MESSAGE_COMPONENT = 3 APPLICATION_COMMAND_AUTOCOMPLETE = 4 MODAL_SUBMIT = 5 end module InteractionResponseTypes PONG = 1 CHANNEL_MESSAGE_WITH_SOURCE = 4 DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5 DEFERRED_UPDATE_MESSAGE = 6 UPDATE_MESSAGE = 7 APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8 MODAL = 9 PREMIUM_REQUIRED = 10 end module ApplicationCommandTypes CHAT_INPUT = 1 USER = 2 MESSAGE = 3 end module ApplicationCommandOptionTypes SUB_COMMAND = 1 SUB_COMMAND_GROUP = 2 STRING = 3 INTEGER = 4 BOOLEAN = 5 USER = 6 CHANNEL = 7 ROLE = 8 MENTIONABLE = 9 NUMBER = 10 ATTACHMENT = 11 end module MessageFlags 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 end module ComponentTypes ACTION_ROW = 1 BUTTON = 2 STRING_SELECT = 3 TEXT_INPUT = 4 USER_SELECT = 5 ROLE_SELECT = 6 MENTIONABLE_SELECT = 7 CHANNEL_SELECT = 8 end module ButtonStyles PRIMARY = 1 # Blurple SECONDARY = 2 # Grey SUCCESS = 3 # Green DANGER = 4 # Red LINK = 5 # Grey (Link) end module TextInputStyles SHORT = 1 PARAGRAPH = 2 end end