Added interval to json config.

This commit is contained in:
Filip Strajnar 2024-06-10 22:36:35 +02:00
parent 2c4cd0c705
commit 855d7bfdb2

View file

@ -13,7 +13,7 @@ import (
const screenshot_path = "screenshot.png"
const config_path = "config.json"
func GetConfig() (string, string, error) {
func GetConfig() (string, string, string, error) {
configFile, err := os.ReadFile(config_path)
if err != nil {
@ -33,8 +33,9 @@ func GetConfig() (string, string, error) {
token := config["token"].(string)
channelId := config["channelId"].(string)
interval := config["interval"].(string)
return token, channelId, nil
return token, channelId, interval, nil
}
func SendScreenshots(discord *discordgo.Session, channelId string, sleepDuration time.Duration) {
@ -86,7 +87,7 @@ func SendScreenshots(discord *discordgo.Session, channelId string, sleepDuration
}
func main() {
token, channelId, err := GetConfig()
token, channelId, interval, err := GetConfig()
if err != nil {
panic(err)
@ -98,7 +99,7 @@ func main() {
panic(err)
}
sleepDuration, err := time.ParseDuration("3s")
sleepDuration, err := time.ParseDuration(interval)
if err != nil {
panic(err)