Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateOAuthURL(id string) string
- func LogSessionEvents(s *discordgo.Session)
- func NewDiscordSession(p NewSessionParams) (*discordgo.Session, error)
- func ParseToken(t string) (string, error)
- func RegisterCommands(p RegisterCommandsParams) error
- type ApplicationCommandWithHandler
- type Channel
- type ConfigParams
- type DiscordConfig
- type Guild
- type HandlerFunc
- type InteractionHelper
- type MessageHandler
- type MessageHandlerFunc
- type MessageInfo
- type NewSessionParams
- type RegisterCommandsParams
Constants ¶
View Source
const ConfigurationKey = "discord"
Variables ¶
View Source
var Module = fx.Options(fx.Provide(NewConfig, NewDiscordSession))
Functions ¶
func GenerateOAuthURL ¶
func LogSessionEvents ¶
func NewDiscordSession ¶
func NewDiscordSession(p NewSessionParams) (*discordgo.Session, error)
func ParseToken ¶
ParseToken parses the oauth id out of the bot token
func RegisterCommands ¶
func RegisterCommands(p RegisterCommandsParams) error
Types ¶
type ApplicationCommandWithHandler ¶
type ApplicationCommandWithHandler struct { Command discordgo.ApplicationCommand Handler HandlerFunc // TODO (cthompson) a bit of a hack right now, these should probably be their own type MessageComponent bool GuildID string }
ApplicationCommandWithHandler is a top level Command with a Handler function. Subcommands are TODO todo: define our own handler func? want to use channels to post back messages.
type Channel ¶
type Channel string
Channel represents a Channel ID or Channel URL in the config.
func (*Channel) UnmarshalYAML ¶
type DiscordConfig ¶
type DiscordConfig struct { ApplicationID string `yaml:"application_id"` Token string `yaml:"token"` Intent discordgo.Intent `yaml:"intent"` }
func NewConfig ¶
func NewConfig(p ConfigParams) (cfg DiscordConfig, err error)
type Guild ¶
type Guild string
Guild represents a Guild ID or Guild URL in the config. TODO Make this work properly. Currently requires the user to truncate the channel if they want URL notation.
func (*Guild) UnmarshalYAML ¶
type HandlerFunc ¶
type InteractionHelper ¶
type InteractionHelper interface { GetInteraction() *discordgo.InteractionCreate Respond() (<-chan *discordgo.WebhookEdit, error) RespondWebhook() (<-chan *discordgo.WebhookEdit, error) }
func NewInteractionHelper ¶
func NewInteractionHelper(i *discordgo.InteractionCreate) InteractionHelper
type MessageHandler ¶
type MessageHandler struct {
Handler MessageHandlerFunc
}
type MessageHandlerFunc ¶
type MessageHandlerFunc func(ctx context.Context, info MessageInfo, s *discordgo.Session, m *discordgo.MessageCreate)
type MessageInfo ¶
type MessageInfo struct {
IsBotCommand bool
}
type NewSessionParams ¶
type NewSessionParams struct { fx.In Config DiscordConfig }
type RegisterCommandsParams ¶
type RegisterCommandsParams struct { fx.In Config DiscordConfig Session *discordgo.Session Commands []*ApplicationCommandWithHandler `group:"command"` Handlers []*MessageHandler `group:"handler"` Lifecycle fx.Lifecycle }
Click to show internal directories.
Click to hide internal directories.