mirror of
https://github.com/Xevion/banner.git
synced 2025-12-17 06:11:14 -06:00
Return rather than panic in command registration step
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
@@ -76,7 +77,7 @@ func Register() ([]*discordgo.ApplicationCommand, error) {
|
|||||||
// Register the command
|
// Register the command
|
||||||
cmdInstance, err := session.ApplicationCommandCreate(session.State.User.ID, "", cmdDefinition)
|
cmdInstance, err := session.ApplicationCommandCreate(session.State.User.ID, "", cmdDefinition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic().Err(err).Str("name", cmdDefinition.Name).Str("key", key).Msg("Cannot register command")
|
return nil, errors.Join(err, fmt.Errorf("cannot register command %s", cmdDefinition.Name))
|
||||||
}
|
}
|
||||||
registeredCommands[i] = cmdInstance
|
registeredCommands[i] = cmdInstance
|
||||||
log.Info().Str("name", cmdDefinition.Name).Str("key", key).Msg("Registered command")
|
log.Info().Str("name", cmdDefinition.Name).Str("key", key).Msg("Registered command")
|
||||||
|
|||||||
Reference in New Issue
Block a user