Pass session to plugin init function
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Elara 2024-10-27 12:26:04 -07:00
parent 4f533eac6b
commit b059438179
2 changed files with 3 additions and 3 deletions

View File

@ -102,7 +102,7 @@ func Init(s *discordgo.Session) error {
}
// Load recursively loads plugins from the given directory.
func Load(dir string) error {
func Load(dir string, sess *discordgo.Session) error {
return filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
@ -167,7 +167,7 @@ func Load(dir string) error {
return nil
}
_, err = callableInit(vm.ToValue(api), vm.ToValue(prev))
_, err = callableInit(vm.ToValue(api), vm.ToValue(prev), vm.ToValue(sess))
if err != nil {
return fmt.Errorf("%s init: %w", api.PluginInfo.Name, err)
}

View File

@ -86,7 +86,7 @@ func main() {
}
}
err = plugins.Load(cfg.PluginDir)
err = plugins.Load(cfg.PluginDir, s)
if err != nil {
log.Error("Error running plugin file").Err(err).Send()
}