What is the proper way to pass something into slash command handler? #1113
-
I'm interacting with mongodb inside handlers and need pointer to collection inside database. |
Beta Was this translation helpful? Give feedback.
Answered by
FedorLap2006
Feb 26, 2022
Replies: 1 comment 3 replies
-
I think dependency injection is what you need. type MyAppOrModule struct {
Client *Something
}
func (m *MyAppOrModule) HandleSlash(s *discordgo.Session, i *discordgo.InteractionCreate) {
m.Client.DoSomething(...)
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
telephrag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think dependency injection is what you need.
In Go you can implement it using structs and methods. Like that: