Current section

Files

Jump to
discord_gleam src discord_gleam@discord@intents.erl
Raw

src/discord_gleam@discord@intents.erl

-module(discord_gleam@discord@intents).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([intents_to_bitfield/1, default/0, all/0, none/0]).
-export_type([intents/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type intents() :: {intents, boolean(), boolean(), boolean(), boolean()}.
-file("src/discord_gleam/discord/intents.gleam", 13).
?DOC(" Calculate a bitfield from a set of intents.\n").
-spec intents_to_bitfield(intents()) -> integer().
intents_to_bitfield(Intents) ->
Bitfield = 0,
Bitfield@1 = case erlang:element(2, Intents) of
true ->
Bitfield + 512;
false ->
Bitfield
end,
Bitfield@2 = case erlang:element(4, Intents) of
true ->
Bitfield@1 + 4096;
false ->
Bitfield@1
end,
Bitfield@3 = case erlang:element(3, Intents) of
true ->
Bitfield@2 + 32768;
false ->
Bitfield@2
end,
Bitfield@4 = case erlang:element(5, Intents) of
true ->
Bitfield@3 + 1;
false ->
Bitfield@3
end,
Bitfield@4.
-file("src/discord_gleam/discord/intents.gleam", 44).
?DOC(" Enable a set of default intents, which are usually used by most bots.\n").
-spec default() -> intents().
default() ->
{intents, true, true, true, true}.
-file("src/discord_gleam/discord/intents.gleam", 54).
?DOC(" Enable all the intents, use this if you want to receive all supported events.\n").
-spec all() -> intents().
all() ->
{intents, true, true, true, true}.
-file("src/discord_gleam/discord/intents.gleam", 64).
?DOC(" Disable all the intents, use this if you want to receive no events.\n").
-spec none() -> intents().
none() ->
{intents, false, false, false, false}.