Return errors to main
This commit is contained in:
parent
211f963b87
commit
6bd4744745
@ -1,6 +1,7 @@
|
|||||||
package bot
|
package bot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -84,12 +85,12 @@ func Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if C.DiscordToken == "" {
|
if C.DiscordToken == "" {
|
||||||
log.Fatalf("Discord token is not set")
|
return errors.New("discord token not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
dg, err := discordgo.New(fmt.Sprintf("Bot %s", C.DiscordToken))
|
dg, err := discordgo.New(fmt.Sprintf("Bot %s", C.DiscordToken))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error creating Discord session: %v\n", err)
|
return fmt.Errorf("error creating discord session: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
b := NewBot(dg, C)
|
b := NewBot(dg, C)
|
||||||
@ -99,7 +100,7 @@ func Run() error {
|
|||||||
dg.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsDirectMessages
|
dg.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsDirectMessages
|
||||||
|
|
||||||
if err = dg.Open(); err != nil {
|
if err = dg.Open(); err != nil {
|
||||||
log.Fatalf("error opening connection: %v\n", err)
|
return fmt.Errorf("error opening connection: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("The bot is now running. Press CTRL-C to exit.")
|
log.Info("The bot is now running. Press CTRL-C to exit.")
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
|
|
||||||
"git.kill0.net/chill9/beepboop/bot"
|
"git.kill0.net/chill9/beepboop/bot"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := bot.Run(); err != nil {
|
if err := bot.Run(); err != nil {
|
||||||
os.Exit(1)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user