-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should get things working again, at least on the unsafe branch!
- Loading branch information
Showing
18 changed files
with
383 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"discordtidal" | ||
"github.com/unickorn/discordtidal" | ||
) | ||
|
||
func main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package discord | ||
|
||
import ( | ||
"github.com/pelletier/go-toml" | ||
"github.com/unickorn/discordtidal/log" | ||
"io/ioutil" | ||
) | ||
|
||
var config *Config | ||
|
||
// Config is a struct that holds the configuration for discordtidal. | ||
type Config struct { | ||
ApplicationId string | ||
Token string | ||
UserAgent string | ||
LogLevel string | ||
} | ||
|
||
// LoadConfig loads the config. | ||
func LoadConfig() { | ||
c := Config{} | ||
|
||
b, err := ioutil.ReadFile("config.toml") | ||
if err != nil { | ||
log.Log().Infoln("Config not found, creating new") | ||
data, err := toml.Marshal(c) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if err := ioutil.WriteFile("config.toml", data, 0644); err != nil { | ||
panic(err) | ||
} | ||
return | ||
} | ||
if err := toml.Unmarshal(b, &c); err != nil { | ||
panic(err) | ||
} | ||
if c.LogLevel == "" { | ||
c.LogLevel = "info" | ||
} | ||
log.SetLevel(c.LogLevel) | ||
log.Log().Infoln("Config loaded!") | ||
config = &c | ||
} | ||
|
||
// GetConfig returns the config. | ||
func GetConfig() *Config { | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,7 @@ | ||
package discord | ||
|
||
import ( | ||
"discordtidal/log" | ||
"github.com/pelletier/go-toml" | ||
"io/ioutil" | ||
) | ||
|
||
const ( | ||
editApplicationData = "https://discord.com/api/v9/applications/%s" | ||
assets = "https://discord.com/api/v9/oauth2/applications/%s/assets" | ||
deleteAsset = "https://discord.com/api/v9/oauth2/applications/%s/assets/%s" | ||
endpointEditApplicationData = "https://discord.com/api/v9/applications/%s" | ||
endpointAssets = "https://discord.com/api/v9/oauth2/applications/%s/assets" | ||
endpointDeleteAsset = "https://discord.com/api/v9/oauth2/applications/%s/assets/%s" | ||
) | ||
|
||
type Config struct { | ||
ApplicationId string | ||
Token string | ||
UserAgent string | ||
} | ||
|
||
var config Config | ||
|
||
func LoadConfig() { | ||
config = Config{ | ||
ApplicationId: "", | ||
Token: "", | ||
UserAgent: "", | ||
} | ||
|
||
b, err := ioutil.ReadFile("config.toml") | ||
if err != nil { | ||
log.Log().Info("config not found, creating new") | ||
data, err := toml.Marshal(config) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if err := ioutil.WriteFile("config.toml", data, 0644); err != nil { | ||
panic(err) | ||
} | ||
return | ||
} | ||
if err := toml.Unmarshal(b, &config); err != nil { | ||
panic(err) | ||
} | ||
log.Log().Infof("config loaded!") | ||
} | ||
|
||
func GetConfig() *Config { | ||
return &config | ||
} |
Oops, something went wrong.