Explicit connection configuration, passed as the first argument to every call.
client = Noizu.Discord.Client.new(token: System.fetch_env!("DISCORD_BOT_TOKEN"))
{:ok, me} = Noizu.Discord.Users.me(client)Token precedence
opts[:token] -> Application.get_env(:noizu_discord, :client)[:token] ->
the DISCORD_BOT_TOKEN environment variable. The token is sent as
Authorization: Bot <token>. It may be nil at construction; requests that need
it fail with {:error, %Noizu.Discord.Error{tag: :config}}.
Other options follow the same opts -> app env -> default precedence.
Options
:token— bot token (without theBotprefix).:base_url— API root. Default:https://discord.com/api/v10.:user_agent—User-Agentheader. Default (per Discord's UA rule):DiscordBot (https://github.com/noizu-labs-sdks/elixir-discord, 0.1.0).:req_options— keyword options merged into everyReq.request/1call (e.g.plug:,receive_timeout:). The library's own method/url/auth options win.:retry— keyword::max_attempts(total attempts, default3;1disables retrying),:base_backoff_ms(default500, used when the server sends no delay hint),:max_delay_ms(clamp for server-supplied delays, default30_000),:sleep_fn(default&Process.sleep/1; test hook).
The Inspect implementation redacts the token.
Summary
Functions
Default API root (https://discord.com/api/v10).
Default User-Agent header value.
Builds a client struct. See the module doc for option details.