Skip to content

Commit

Permalink
breaking: Mux#SetRoute -> Mux#Mount
Browse files Browse the repository at this point in the history
  • Loading branch information
Karitham committed Dec 24, 2021
1 parent e917c27 commit 3e69c1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion _example/bongo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
}

m := corde.NewMux(pk, appID, token)
m.SetRoute(corde.SlashCommand("bongo"), bongoHandler)
m.Mount(corde.SlashCommand("bongo"), bongoHandler)

g := corde.GuildOpt(corde.SnowflakeFromString(os.Getenv("DISCORD_GUILD_ID")))
if err := m.RegisterCommand(command, g); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions _example/moderate-myself/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func main() {
selectedID := 0

m := corde.NewMux(pk, appID, token)
m.SetRoute(corde.SlashCommand("cmd/list"), list(m, g))
m.SetRoute(corde.SlashCommand("cmd/remove"), rm(m, g))
m.SetRoute(corde.ButtonInteraction("btn-cmd/list/next"), btnNext(m, g, mu, &selectedID))
m.SetRoute(corde.ButtonInteraction("btn-cmd/list/remove"), btnRemove(m, g, mu, &selectedID))
m.Mount(corde.SlashCommand("cmd/list"), list(m, g))
m.Mount(corde.SlashCommand("cmd/remove"), rm(m, g))
m.Mount(corde.ButtonInteraction("btn-cmd/list/next"), btnNext(m, g, mu, &selectedID))
m.Mount(corde.ButtonInteraction("btn-cmd/list/remove"), btnRemove(m, g, mu, &selectedID))

if err := m.RegisterCommand(command, g); err != nil {
log.Fatalln("error registering command: ", err)
Expand Down
6 changes: 3 additions & 3 deletions _example/todo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func main() {
}

m := corde.NewMux(pk, appID, token)
m.SetRoute(corde.SlashCommand("todo/add"), t.addHandler)
m.SetRoute(corde.SlashCommand("todo/rm"), t.removeHandler)
m.SetRoute(corde.SlashCommand("todo/list"), t.listHandler)
m.Mount(corde.SlashCommand("todo/add"), t.addHandler)
m.Mount(corde.SlashCommand("todo/rm"), t.removeHandler)
m.Mount(corde.SlashCommand("todo/list"), t.listHandler)

g := corde.GuildOpt(corde.SnowflakeFromString(os.Getenv("DISCORD_GUILD_ID")))
m.BulkRegisterCommand(commands, g)
Expand Down
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *Mux) Unlock() {
m.rMu.Unlock()
}

func (m *Mux) SetRoute(command InteractionCommand, handler Handler) {
func (m *Mux) Mount(command InteractionCommand, handler Handler) {
m.rMu.Lock()
defer m.rMu.Unlock()
m.routes[command] = handler
Expand Down

0 comments on commit 3e69c1c

Please sign in to comment.