Skip to content

Commit f90839f

Browse files
committed
don't store token in module attribute, fix dep ref
Module attributes are evaluated at compile time. If a user builds the Nostrum dependency before setting up their config.exs file, they'll run into issues with the :nostrum config options. Additionally, if a user wants to change their token they would also have to recompile the app. There's no reason to store it in the module attribute, so lets get it directly from the app env to prevent all of this.
1 parent 5debd3a commit f90839f

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121
Stable documentation can be found [here](https://hexdocs.pm/nostrum/)
2222
```elixir
2323
def deps do
24-
[{:nostrum, "~> 0.1"]
24+
[{:nostrum, "~> 0.1"}]
2525
end
2626
```
2727

docs/static/Intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ end
6565
*Stable*
6666
```Elixir
6767
def deps do
68-
[{:nostrum, "~> 1.0"]
68+
[{:nostrum, "~> 1.0"}]
6969
end
7070
```
7171

lib/nostrum/api/base.ex

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ defmodule Nostrum.Api.Base do
22
@moduledoc false
33

44
@version Nostrum.Mixfile.project[:version]
5-
@token Application.get_env(:nostrum, :token)
65

76
use HTTPoison.Base
87

@@ -23,7 +22,7 @@ defmodule Nostrum.Api.Base do
2322

2423
defp process_request_headers(headers) do
2524
user_agent = [{"User-Agent", "DiscordBot (https://github.com/kraigie/nostrum, #{@version})"} | headers]
26-
auth = [{"Authorization", "Bot #{@token}"} | user_agent]
25+
auth = [{"Authorization", "Bot #{Application.get_env(:nostrum, :token)}"} | user_agent]
2726
auth
2827
end
2928

0 commit comments

Comments
 (0)