Skip to content

Commit 2b8d706

Browse files
authored
fix: faulty logic when handling environment variable config (#22)
1 parent eb1e521 commit 2b8d706

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,23 @@ func (c *Config) LoadEnv() {
184184
v = os.Getenv("DISCORD_RAW_INTENTS")
185185
if v != "" {
186186
i, err := strconv.ParseUint(v, 10, 32)
187-
if err != nil {
187+
if err == nil {
188188
c.RawIntents = uint(i)
189189
}
190190
}
191191

192192
v = os.Getenv("DISCORD_GATEWAY_VERSION")
193193
if v != "" {
194194
i, err := strconv.ParseUint(v, 10, 32)
195-
if err != nil {
195+
if err == nil {
196196
c.GatewayVersion = uint(i)
197197
}
198198
}
199199

200200
v = os.Getenv("DISCORD_SHARD_COUNT")
201201
if v != "" {
202202
i, err := strconv.ParseUint(v, 10, 32)
203-
if err != nil {
203+
if err == nil {
204204
c.Shards.Count = int(i)
205205
}
206206
}
@@ -211,7 +211,7 @@ func (c *Config) LoadEnv() {
211211
c.Shards.IDs = make([]int, len(ids))
212212
for i, id := range ids {
213213
convID, err := strconv.Atoi(id)
214-
if err != nil {
214+
if err == nil {
215215
c.Shards.IDs[i] = convID
216216
}
217217
}
@@ -221,7 +221,7 @@ func (c *Config) LoadEnv() {
221221
if v != "" {
222222
var presence types.StatusUpdate
223223
err := json.Unmarshal([]byte(v), &presence)
224-
if err != nil {
224+
if err == nil {
225225
c.Presence = presence
226226
}
227227
}
@@ -239,7 +239,7 @@ func (c *Config) LoadEnv() {
239239
v = os.Getenv("DISCORD_API_VERSION")
240240
if v != "" {
241241
version, err := strconv.ParseUint(v, 10, 8)
242-
if err != nil {
242+
if err == nil {
243243
c.API.Version = uint(version)
244244
}
245245
}
@@ -257,7 +257,7 @@ func (c *Config) LoadEnv() {
257257
v = os.Getenv("BROKER_MESSAGE_TIMEOUT")
258258
if v != "" {
259259
timeout, err := time.ParseDuration(v)
260-
if err != nil {
260+
if err == nil {
261261
c.Broker.MessageTimeout = duration{timeout}
262262
}
263263
}
@@ -296,7 +296,7 @@ func (c *Config) LoadEnv() {
296296
v = os.Getenv("REDIS_POOL_SIZE")
297297
if v != "" {
298298
i, err := strconv.Atoi(v)
299-
if err != nil {
299+
if err == nil {
300300
c.Redis.PoolSize = i
301301
}
302302
}

0 commit comments

Comments
 (0)