Documentation ¶
Overview ¶
Package discord implements a Discord bot that can join and run in guilds.
Index ¶
- type Arg
- type Bot
- type Command
- type CommandError
- type DGCommand
- type Handler
- func CancelBet(ctx context.Context, client bettorClient) Handler
- func GetBet(ctx context.Context, client bettorClient) Handler
- func GetBettor(ctx context.Context, client bettorClient) Handler
- func GetBettors(ctx context.Context, client bettorClient) Handler
- func JoinBet(ctx context.Context, client bettorClient) Handler
- func LockBet(ctx context.Context, client bettorClient) Handler
- func SettleBet(ctx context.Context, client bettorClient) Handler
- func StartBet(ctx context.Context, client bettorClient) Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg func(o *discordArgs)
Arg is an argument for constructing a Discord bot.
func WithBettorClient ¶
func WithBettorClient(c bettorv1alphaconnect.BettorServiceClient) Arg
WithBettorClient provides a Bettor client to the Discord bot.
func WithCleanUp ¶
func WithCleanUp() Arg
WithCleanUp configured Discord bot to clean up registered commands on shutdown.
func WithLogger ¶
WithLogger provides a logger to the Discord bot.
type Bot ¶
type Bot struct { Ctx context.Context D *discordgo.Session Client bettorClient Logger log.Logger CleanUp bool Commands map[string]*DGCommand // keep track of all guilds we have joined so we can clean up commands on termination. GuildIDs []string // contains filtered or unexported fields }
Bot is a Discord Bot for Bettor. Only one instance can be running.
type Command ¶
type Command struct { Def *discordgo.ApplicationCommand Handler Handler }
Command is a helper struct for an discordgo ApplicationCommand and its handler function. This contains a internal Handler type which is nice for generic instrumentation and error handling.
type CommandError ¶
type CommandError struct { UserMsg string // user-facing error message. will be sent back as feedback via Discord interaction response Err error // wrapped error. internal }
CommandError represents an error handling a Discord command.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
Error returns error string for CommandError.
type DGCommand ¶
type DGCommand struct { Def *discordgo.ApplicationCommand Handler func(*discordgo.Session, *discordgo.InteractionCreate) }
DGCommand is a helper struct for an discordgo ApplicationCommand and its handler function. This contains types ready to be used with a discordgo.Session.
type Handler ¶
type Handler func(*discordgo.Session, *discordgo.InteractionCreate) (*discordgo.InteractionResponseData, error)
Handler is an InteractionCreate handler. It returns a InteractionResponseData which will serve as our universal interface for generic handling.
func GetBettors ¶
GetBettors is the handler for the /get-bet command.