Skip to content

What is the proper way to pass something into slash command handler? #1113

Answered by FedorLap2006
telephrag asked this question in Q&A
Discussion options

You must be logged in to vote

I think dependency injection is what you need.
In Go you can implement it using structs and methods. Like that:

type MyAppOrModule struct {
     Client *Something
}

func (m *MyAppOrModule) HandleSlash(s *discordgo.Session, i *discordgo.InteractionCreate) {
     m.Client.DoSomething(...)
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@telephrag
Comment options

@FedorLap2006
Comment options

@telephrag
Comment options

Answer selected by telephrag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants