Skip to content

Commit

Permalink
fix backend build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Jul 21, 2022
1 parent 4f8a673 commit 3946899
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 3 additions & 10 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,11 @@ func (b *Backend) SetupScheduler() error {
return nil
}

func (b *Backend) LoadCommands(modules []dbot.Module) {
func (b *Backend) LoadCommands(commands ...dbot.Command) {
b.Logger.Info("Loading commands...")

for _, module := range modules {
if mod, ok := module.(dbot.CommandsModule); ok {
commands := mod.Commands()
cmds := make([]discord.ApplicationCommandCreate, len(commands))
for i, cmd := range commands {
cmds[i] = cmd.Create
}
b.Commands = append(b.Commands, cmds...)
}
for _, command := range commands {
b.Commands = append(b.Commands, command.Create)
}

b.Logger.Infof("Loaded %d commands", len(b.Commands))
Expand Down
2 changes: 1 addition & 1 deletion backend/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (b *Backend) VoteTask(ctx context.Context) {
return
}
for _, voter := range voters {
if err = b.Rest.RemoveMemberRole(b.Config.SupportGuildID, snowflake.ID(voter.UserID), b.Config.BotLists.VoterRoleID); err != nil {
if err = b.Rest.RemoveMemberRole(b.Config.SupportGuildID, snowflake.MustParse(voter.UserID), b.Config.BotLists.VoterRoleID); err != nil {
b.Logger.Error("failed to remove voter role: ", err)
}
}
Expand Down
25 changes: 23 additions & 2 deletions cmd/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/KittyBot-Org/KittyBotGo/backend/routes"
"github.com/KittyBot-Org/KittyBotGo/config"
"github.com/KittyBot-Org/KittyBotGo/db"
"github.com/KittyBot-Org/KittyBotGo/dbot/modules"
"github.com/KittyBot-Org/KittyBotGo/dbot/commands"
"github.com/disgoorg/log"
_ "github.com/lib/pq"
)
Expand Down Expand Up @@ -57,7 +57,28 @@ func main() {
os.Exit(0)
}

b.LoadCommands(modules.Modules)
b.LoadCommands(
commands.BassBoost,
commands.ClearQueue,
commands.History,
commands.LikedSongs,
commands.Loop,
commands.Next,
commands.NowPlaying,
commands.Pause,
commands.Play,
commands.Previous,
commands.Queue,
commands.Remove,
commands.Seek,
commands.Shuffle,
commands.Stop,
commands.Tag,
commands.Tags,
commands.Volume,
commands.Report,
commands.Settings,
)
b.SetupRestServices()
if err = b.SetupPrometheusAPI(); err != nil {
b.Logger.Fatal("Failed to setup prometheus api: ", err)
Expand Down

0 comments on commit 3946899

Please sign in to comment.