github.com/diamondburned/arikawa/v2@v2.1.0/gateway/intents.go (about)

     1  package gateway
     2  
     3  import "github.com/diamondburned/arikawa/v2/discord"
     4  
     5  // Intents for the new Discord API feature, documented at
     6  // https://discord.com/developers/docs/topics/gateway#gateway-intents.
     7  type Intents uint32
     8  
     9  const (
    10  	IntentGuilds Intents = 1 << iota
    11  	IntentGuildMembers
    12  	IntentGuildBans
    13  	IntentGuildEmojis
    14  	IntentGuildIntegrations
    15  	IntentGuildWebhooks
    16  	IntentGuildInvites
    17  	IntentGuildVoiceStates
    18  	IntentGuildPresences
    19  	IntentGuildMessages
    20  	IntentGuildMessageReactions
    21  	IntentGuildMessageTyping
    22  	IntentDirectMessages
    23  	IntentDirectMessageReactions
    24  	IntentDirectMessageTyping
    25  )
    26  
    27  // PrivilegedIntents contains a list of privileged intents that Discord requires
    28  // bots to have these intents explicitly enabled in the Developer Portal.
    29  var PrivilegedIntents = []Intents{
    30  	IntentGuildPresences,
    31  	IntentGuildMembers,
    32  }
    33  
    34  // Has returns true if i has the given intents.
    35  func (i Intents) Has(intents Intents) bool {
    36  	return discord.HasFlag(uint64(i), uint64(intents))
    37  }
    38  
    39  // IsPrivileged returns true for each of the boolean that indicates the type of
    40  // the privilege.
    41  func (i Intents) IsPrivileged() (presences, member bool) {
    42  	// Keep this in sync with PrivilegedIntents.
    43  	return i.Has(IntentGuildPresences), i.Has(IntentGuildMembers)
    44  }