Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Intents #283

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/discordrb/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ class Bot
# to Discord's gateway. `:none` will request that no payloads are received compressed (not recommended for
# production bots). `:large` will request that large payloads are received compressed. `:stream` will request
# that all data be received in a continuous compressed stream.
# @param intents [:all, :unprivileged, Array<Symbol>, :none] Gateway intents that this bot requires. `:all` will
# @param intents [:all, :unprivileged, Array<Symbol>, :none, Integer] Gateway intents that this bot requires. `:all` will
# request all intents. `:unprivileged` will request only intents that are not defined as "Privileged". `:none`
# will request no intents. An array of symbols will request only those intents specified.
# will request no intents. An array of symbols will request only those intents specified. An integer value will request
# exactly all the intents specified in the bitwise value.
# @see Discordrb::INTENTS
def initialize(
log_mode: :normal,
Expand Down Expand Up @@ -1712,6 +1713,8 @@ def handle_awaits(event)
end

def calculate_intents(intents)
intents = [intents] unless intents.is_a? Array

intents.reduce(0) do |sum, intent|
case intent
when Symbol
Expand Down
Loading