Fix bug where a missing scriptfolder prevented startup
MODIFY
internal/scripting/javascript.go
internal/scripting/javascript.go
@@ -28,6 +28,13 @@ func New() (engine *JavaScriptEngine) {
// LoadScripts implements Engine
func (engine *JavaScriptEngine) LoadScripts(dirname string) (err error) {
+ _, statError := os.Stat(dirname)
+ if os.IsNotExist(statError) {
+ return nil
+ } else if statError != nil {
+ return errors.Wrapf(statError, "Error loading scripts '%s'", statError.Error())
+ }
+
err = filepath.Walk(dirname, func(path string, fileInfo os.FileInfo, err error) error {
if fileInfo.IsDir() {
return nil

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -3,6 +3,7 @@ package ui
import (
"fmt"
"io"
+ "os"
"regexp"
"sort"
"strings"
@@ -87,8 +88,10 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
}
if err := window.scripting.LoadScripts(config.GetScriptDirectory()); err != nil {
+ if !os.IsNotExist(err) {
return nil, err
}
+ }
guilds, discordError := discord.UserGuilds(100, "", "")
if discordError != nil {

Fix bug where a missing scriptfolder prevented startup