discordfx

package
v0.0.0-...-6b7fec4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationKey = "discord"

Variables

Functions

func GenerateOAuthURL

func GenerateOAuthURL(id string) string

func ParseToken

func ParseToken(t string) (string, error)

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
	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 BotConfig

type BotConfig struct {
	Token  string
	Intent discordgo.Intent
}

type Channel

type Channel string

Channel represents a Channel ID or Channel URL in the config.

func (*Channel) UnmarshalYAML

func (c *Channel) UnmarshalYAML(unmarshal func(interface{}) error) 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

func (g *Guild) UnmarshalYAML(unmarshal func(interface{}) error) error

type HandlerFunc

type HandlerFunc func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate)

type InteractionHelper

type InteractionHelper interface {
	GetInteraction() *discordgo.InteractionCreate
	Respond() (<-chan *discordgo.WebhookEdit, error)
	RespondWebhook() (<-chan *discordgo.WebhookEdit, error)
}

type NewSessionParams

type NewSessionParams struct {
	fx.In
	Log       *zap.Logger
	Config    config.Provider
	Lifecycle fx.Lifecycle
}

type NewSessionResult

type NewSessionResult struct {
	fx.Out
	Session *discordgo.Session
}

func NewDiscordSession

func NewDiscordSession(p NewSessionParams) (NewSessionResult, error)

type RegisterCommandsParams

type RegisterCommandsParams struct {
	fx.In
	Session   *discordgo.Session
	Commands  []*ApplicationCommandWithHandler `group:"command""`
	Log       *zap.Logger
	Lifecycle fx.Lifecycle
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL