Documentation
¶
Index ¶
- Variables
- func GetArgument[T any](ctx *SlashExecutionContext, name string) (value T, found bool)
- func GetArgumentOr[T any](ctx *SlashExecutionContext, name string, def T) T
- func GetRequiredArgument[T any](ctx *SlashExecutionContext, name string) T
- func NewAttachmentArgument() *attachmentSlashCommandArgumentBuilder
- func NewBooleanArgument() *booleanArgumentBuilder
- func NewChannelArgument() *channelSlashCommandArgumentBuilder
- func NewIntegerArgument() *integerSlashCommandArgumentBuilder
- func NewIntegerAutocompleteArgument() *integerSlashCommandAutocompleteArgumentBuilder
- func NewIntegerChoicesArgument() *integerSlashCommandChoicesArgumentBuilder
- func NewMentionableArgument() *mentionableSlashCommandArgumentBuilder
- func NewNumberArgument() *numberSlashCommandArgumentBuilder
- func NewNumberAutocompleteArgument() *numberSlashCommandAutocompleteArgumentBuilder
- func NewNumberChoicesArgument() *numberSlashCommandChoicesArgumentBuilder
- func NewRoleArgument() *roleSlashCommandArgumentBuilder
- func NewStringArgument() *stringSlashCommandArgumentBuilder
- func NewStringAutocompleteArgument() *stringSlashCommandAutocompleteArgumentBuilder
- func NewStringChoicesArgument() *stringSlashCommandChoicesArgumentBuilder
- func NewUserArgument() *userSlashCommandArgumentBuilder
- type ArgumentChoice
- type ArgumentHasInvalidValueError
- type ArgumentHasNoValueError
- type ArgumentParsingInformation
- type AttachmentSlashCommandArgument
- type BooleanSlashCommandArgument
- type ChannelSlashCommandArgument
- type CommandBuilder
- type CommandMiddleware
- type DGCError
- type DGCommander
- type DefaultTimeProvider
- type IntegerSlashCommandArgument
- type IntegerSlashCommandAutocompleteArgumentHandler
- type InvokationInformation
- type MemberSlashCommandArgument
- type MentionableSlashCommandArgument
- type MessageCommandBuilder
- func (b *MessageCommandBuilder) AddMiddleware(middleware M) B
- func (b *MessageCommandBuilder) AllowEverywhere(allowed bool) B
- func (b *MessageCommandBuilder) AllowInBotDM(allowed bool) B
- func (b *MessageCommandBuilder) AllowInGuilds(allowed bool) B
- func (b *MessageCommandBuilder) AllowInPrivateChannel(allowed bool) B
- func (b *MessageCommandBuilder) ForGuild(guildId string) B
- func (b *MessageCommandBuilder) GuildInstallable(installable bool) B
- func (b *MessageCommandBuilder) Handler(handler MessageCommandHandler) *MessageCommandBuilder
- func (b *MessageCommandBuilder) Name() *util.Localizable[B]
- func (b *MessageCommandBuilder) Nsfw(nsfw bool) B
- func (b *MessageCommandBuilder) UserInstallable(installable bool) B
- type MessageCommandHandler
- type MessageExecutionContext
- type MessageMiddleware
- type MiddlewareCallChainError
- type MultiSlashCommandBuilder
- type NumberSlashCommandArgument
- type NumberSlashCommandAutocompleteArgumentHandler
- func (arg *NumberSlashCommandAutocompleteArgumentHandler) Autocomplete(ctx *SlashAutocompleteContext) error
- func (arg *NumberSlashCommandAutocompleteArgumentHandler) IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
- func (a *NumberSlashCommandAutocompleteArgumentHandler) Name() string
- type RespondingContext
- func (ctx *RespondingContext) AddFollowup(wait bool, data *discordgo.WebhookParams) (*discordgo.Message, error)
- func (ctx RespondingContext) EndTime() time.Time
- func (ctx RespondingContext) Finish()
- func (ctx *RespondingContext) RespondLatter() error
- func (ctx *RespondingContext) RespondWithMessage(message *discordgo.InteractionResponseData) error
- func (ctx *RespondingContext) RespondWithModal(modal *discordgo.InteractionResponseData) error
- type RoleSlashCommandArgument
- type SimpleSlashCommandBuilder
- func (b *SimpleSlashCommandBuilder) AddArgument(arg SlashCommandArgumentBuilder) B
- func (b *SimpleSlashCommandBuilder) AddArguments(args ...SlashCommandArgumentBuilder) B
- func (b *SimpleSlashCommandBuilder) Description() *util.Localizable[B]
- func (b *SimpleSlashCommandBuilder) Handler(handler SlashCommandHandler) *SimpleSlashCommandBuilder
- type SlashAutocompleteContext
- func (ctx *SlashAutocompleteContext) AddChoice(name string, value any) *SlashAutocompleteContext
- func (ctx *SlashAutocompleteContext) AddLocalizedChoice(name string, value any, localizations map[discordgo.Locale]string) *SlashAutocompleteContext
- func (ctx SlashAutocompleteContext) EndTime() time.Time
- func (ctx SlashAutocompleteContext) Finish()
- func (args *SlashAutocompleteContext) GetAttachment(name string) (value *discordgo.MessageAttachment, found bool)
- func (args *SlashAutocompleteContext) GetAttachmentOr(name string, def *discordgo.MessageAttachment) *discordgo.MessageAttachment
- func (args *SlashAutocompleteContext) GetBool(name string) (value bool, found bool)
- func (args *SlashAutocompleteContext) GetBoolOr(name string, def bool) bool
- func (args *SlashAutocompleteContext) GetChannel(name string) (value *discordgo.Channel, found bool)
- func (args *SlashAutocompleteContext) GetChannelOr(name string, def *discordgo.Channel) *discordgo.Channel
- func (args *SlashAutocompleteContext) GetInteger(name string) (value int64, found bool)
- func (args *SlashAutocompleteContext) GetIntegerOr(name string, def int64) int64
- func (args *SlashAutocompleteContext) GetMember(name string) (value *discordgo.Member, found bool)
- func (args *SlashAutocompleteContext) GetMemberOr(name string, def *discordgo.Member) *discordgo.Member
- func (args *SlashAutocompleteContext) GetNumber(name string) (value float64, found bool)
- func (args *SlashAutocompleteContext) GetNumberOr(name string, def float64) float64
- func (args *SlashAutocompleteContext) GetRequiredAttachment(name string) *discordgo.MessageAttachment
- func (args *SlashAutocompleteContext) GetRequiredBool(name string) bool
- func (args *SlashAutocompleteContext) GetRequiredChannel(name string) *discordgo.Channel
- func (args *SlashAutocompleteContext) GetRequiredInteger(name string) int64
- func (args *SlashAutocompleteContext) GetRequiredMember(name string) *discordgo.Member
- func (args *SlashAutocompleteContext) GetRequiredNumber(name string) float64
- func (args *SlashAutocompleteContext) GetRequiredRole(name string) *discordgo.Role
- func (args *SlashAutocompleteContext) GetRequiredString(name string) string
- func (args *SlashAutocompleteContext) GetRequiredUser(name string) *discordgo.User
- func (args *SlashAutocompleteContext) GetRole(name string) (value *discordgo.Role, found bool)
- func (args *SlashAutocompleteContext) GetRoleOr(name string, def *discordgo.Role) *discordgo.Role
- func (args *SlashAutocompleteContext) GetString(name string) (value string, found bool)
- func (args *SlashAutocompleteContext) GetStringOr(name string, def string) string
- func (args *SlashAutocompleteContext) GetUser(name string) (value *discordgo.User, found bool)
- func (args *SlashAutocompleteContext) GetUserOr(name string, def *discordgo.User) *discordgo.User
- type SlashCommandArgument
- type SlashCommandArgumentBuilder
- type SlashCommandAutocompleteArgument
- type SlashCommandAutocompleteArgumentHandler
- type SlashCommandHandler
- type SlashExecutionContext
- func (ctx SlashExecutionContext) EndTime() time.Time
- func (ctx SlashExecutionContext) Finish()
- func (args *SlashExecutionContext) GetAttachment(name string) (value *discordgo.MessageAttachment, found bool)
- func (args *SlashExecutionContext) GetAttachmentOr(name string, def *discordgo.MessageAttachment) *discordgo.MessageAttachment
- func (args *SlashExecutionContext) GetBool(name string) (value bool, found bool)
- func (args *SlashExecutionContext) GetBoolOr(name string, def bool) bool
- func (args *SlashExecutionContext) GetChannel(name string) (value *discordgo.Channel, found bool)
- func (args *SlashExecutionContext) GetChannelOr(name string, def *discordgo.Channel) *discordgo.Channel
- func (args *SlashExecutionContext) GetInteger(name string) (value int64, found bool)
- func (args *SlashExecutionContext) GetIntegerOr(name string, def int64) int64
- func (args *SlashExecutionContext) GetMember(name string) (value *discordgo.Member, found bool)
- func (args *SlashExecutionContext) GetMemberOr(name string, def *discordgo.Member) *discordgo.Member
- func (args *SlashExecutionContext) GetNumber(name string) (value float64, found bool)
- func (args *SlashExecutionContext) GetNumberOr(name string, def float64) float64
- func (args *SlashExecutionContext) GetRequiredAttachment(name string) *discordgo.MessageAttachment
- func (args *SlashExecutionContext) GetRequiredBool(name string) bool
- func (args *SlashExecutionContext) GetRequiredChannel(name string) *discordgo.Channel
- func (args *SlashExecutionContext) GetRequiredInteger(name string) int64
- func (args *SlashExecutionContext) GetRequiredMember(name string) *discordgo.Member
- func (args *SlashExecutionContext) GetRequiredNumber(name string) float64
- func (args *SlashExecutionContext) GetRequiredRole(name string) *discordgo.Role
- func (args *SlashExecutionContext) GetRequiredString(name string) string
- func (args *SlashExecutionContext) GetRequiredUser(name string) *discordgo.User
- func (args *SlashExecutionContext) GetRole(name string) (value *discordgo.Role, found bool)
- func (args *SlashExecutionContext) GetRoleOr(name string, def *discordgo.Role) *discordgo.Role
- func (args *SlashExecutionContext) GetString(name string) (value string, found bool)
- func (args *SlashExecutionContext) GetStringOr(name string, def string) string
- func (args *SlashExecutionContext) GetUser(name string) (value *discordgo.User, found bool)
- func (args *SlashExecutionContext) GetUserOr(name string, def *discordgo.User) *discordgo.User
- type SlashMultiMiddleware
- type SlashSimpleMiddleware
- type StringSlashCommandArgument
- type StringSlashCommandAutocompleteArgumentHandler
- func (arg *StringSlashCommandAutocompleteArgumentHandler) Autocomplete(ctx *SlashAutocompleteContext) error
- func (arg *StringSlashCommandAutocompleteArgumentHandler) IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
- func (a *StringSlashCommandAutocompleteArgumentHandler) Name() string
- type SubSlashCommandBuilder
- func (b *SubSlashCommandBuilder) AddArgument(arg SlashCommandArgumentBuilder) B
- func (b *SubSlashCommandBuilder) AddArguments(args ...SlashCommandArgumentBuilder) B
- func (b *SubSlashCommandBuilder) AddMiddleware(middleware SlashSimpleMiddleware) *SubSlashCommandBuilder
- func (b *SubSlashCommandBuilder) Description() *util.Localizable[*SubSlashCommandBuilder]
- func (b *SubSlashCommandBuilder) Handler(handler SlashCommandHandler) *SubSlashCommandBuilder
- func (b *SubSlashCommandBuilder) Name() *util.Localizable[*SubSlashCommandBuilder]
- type SubSlashCommandGroupBuilder
- func (b *SubSlashCommandGroupBuilder) AddMiddleware(middleware SlashMultiMiddleware) *SubSlashCommandGroupBuilder
- func (b *SubSlashCommandGroupBuilder) AddSubCommand(command *SubSlashCommandBuilder) *SubSlashCommandGroupBuilder
- func (b *SubSlashCommandGroupBuilder) AddSubCommands(commands ...*SubSlashCommandBuilder) *SubSlashCommandGroupBuilder
- func (b *SubSlashCommandGroupBuilder) Description() *util.Localizable[*SubSlashCommandGroupBuilder]
- func (b *SubSlashCommandGroupBuilder) Name() *util.Localizable[*SubSlashCommandGroupBuilder]
- type TimeProvider
- type UserCommandBuilder
- func (b *UserCommandBuilder) AddMiddleware(middleware M) B
- func (b *UserCommandBuilder) AllowEverywhere(allowed bool) B
- func (b *UserCommandBuilder) AllowInBotDM(allowed bool) B
- func (b *UserCommandBuilder) AllowInGuilds(allowed bool) B
- func (b *UserCommandBuilder) AllowInPrivateChannel(allowed bool) B
- func (b *UserCommandBuilder) ForGuild(guildId string) B
- func (b *UserCommandBuilder) GuildInstallable(installable bool) B
- func (b *UserCommandBuilder) Handler(handler UserCommandHandler) *UserCommandBuilder
- func (b *UserCommandBuilder) Name() *util.Localizable[B]
- func (b *UserCommandBuilder) Nsfw(nsfw bool) B
- func (b *UserCommandBuilder) UserInstallable(installable bool) B
- type UserCommandHandler
- type UserExecutionContext
- type UserMiddleware
- type UserSlashCommandArgument
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMissingRequiredArguments = makeError("required arguments without values: %+v") // arguments marked as required are not present after parsing all the arguments ErrMissingRequiredArgument = makeError("missing required %s argument %s, maybe you didn't mark it as required in the command definition?") // the handler requested as required a value that is not present ErrArgumentIsWrongType = makeError("required %s argument %s is of type %T (%+v), maybe you didn't use the correct type in the command definition?") // the handler requested a value as one type but it is another tpye ErrArgumentHasInvalidValue = ArgumentHasInvalidValueError{DGCError: makeError("the argument %s has a value of type %T (%#v) but the expected type was %s")} ErrArgumentHasNoValue = ArgumentHasNoValueError{DGCError: makeError("the %s has no value")} )
View Source
var ( ErrUnknownSlashCommand = makeError("unknwon command: %s") ErrInvalidAmountOfOptions = makeError("a command group or sub command is expected to only have one option present %d are present") ErrInvalidSubCommandType = makeError("the option %+v has not a valid type for a command group or sub command group") ErrNoFocusedArgument = makeError("there is no argument focused") ErrNoAutocompletingArgumentForOption = makeError("no autocomplete argument found for the option %+v") )
View Source
var (
ErrAlreadyResponded = errors.New("already responded, send a follow up")
)
View Source
var (
ErrMessageCommandHasNoMessage = errors.New("Message command was used but no message was given")
)
View Source
var (
ErrMiddlewareCallChain = MiddlewareCallChainError{DGCError: makeError("errors returned by the middlewares: %w")}
)
View Source
var (
ErrUserCommandHasNoUser = errors.New("User command was used but no user was given")
)
Functions ¶
func GetArgument ¶
func GetArgument[T any](ctx *SlashExecutionContext, name string) (value T, found bool)
func GetArgumentOr ¶
func GetArgumentOr[T any](ctx *SlashExecutionContext, name string, def T) T
func GetRequiredArgument ¶
func GetRequiredArgument[T any](ctx *SlashExecutionContext, name string) T
func NewAttachmentArgument ¶
func NewAttachmentArgument() *attachmentSlashCommandArgumentBuilder
func NewBooleanArgument ¶
func NewBooleanArgument() *booleanArgumentBuilder
func NewChannelArgument ¶
func NewChannelArgument() *channelSlashCommandArgumentBuilder
func NewIntegerArgument ¶
func NewIntegerArgument() *integerSlashCommandArgumentBuilder
func NewIntegerAutocompleteArgument ¶
func NewIntegerAutocompleteArgument() *integerSlashCommandAutocompleteArgumentBuilder
func NewIntegerChoicesArgument ¶
func NewIntegerChoicesArgument() *integerSlashCommandChoicesArgumentBuilder
func NewMentionableArgument ¶
func NewMentionableArgument() *mentionableSlashCommandArgumentBuilder
func NewNumberArgument ¶
func NewNumberArgument() *numberSlashCommandArgumentBuilder
func NewNumberAutocompleteArgument ¶
func NewNumberAutocompleteArgument() *numberSlashCommandAutocompleteArgumentBuilder
func NewNumberChoicesArgument ¶
func NewNumberChoicesArgument() *numberSlashCommandChoicesArgumentBuilder
func NewRoleArgument ¶
func NewRoleArgument() *roleSlashCommandArgumentBuilder
func NewStringArgument ¶
func NewStringArgument() *stringSlashCommandArgumentBuilder
func NewStringAutocompleteArgument ¶
func NewStringAutocompleteArgument() *stringSlashCommandAutocompleteArgumentBuilder
func NewStringChoicesArgument ¶
func NewStringChoicesArgument() *stringSlashCommandChoicesArgumentBuilder
func NewUserArgument ¶
func NewUserArgument() *userSlashCommandArgumentBuilder
Types ¶
type ArgumentChoice ¶
type ArgumentHasInvalidValueError ¶
type ArgumentHasInvalidValueError struct{ DGCError }
func (ArgumentHasInvalidValueError) Is ¶
func (e ArgumentHasInvalidValueError) Is(target error) bool
func (ArgumentHasInvalidValueError) New ¶
func (e ArgumentHasInvalidValueError) New(name string, foundValue any, expectedValueType string) ArgumentHasInvalidValueError
type ArgumentHasNoValueError ¶
type ArgumentHasNoValueError struct{ DGCError }
func (ArgumentHasNoValueError) Is ¶
func (e ArgumentHasNoValueError) Is(target error) bool
func (ArgumentHasNoValueError) New ¶
func (e ArgumentHasNoValueError) New(name string) ArgumentHasNoValueError
func (ArgumentHasNoValueError) Values ¶
func (e ArgumentHasNoValueError) Values() (name string)
type ArgumentParsingInformation ¶
type ArgumentParsingInformation struct {
Options []*discordgo.ApplicationCommandInteractionDataOption
Resolved *discordgo.ApplicationCommandInteractionDataResolved
Autocompleting bool
}
func (*ArgumentParsingInformation) FindOption ¶
func (api *ArgumentParsingInformation) FindOption(name string) *discordgo.ApplicationCommandInteractionDataOption
Searches for an option in the slice of options with the same name, returning the first one found, nil if not found
type AttachmentSlashCommandArgument ¶
type AttachmentSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*AttachmentSlashCommandArgument) Name ¶
func (a *AttachmentSlashCommandArgument) Name() string
func (*AttachmentSlashCommandArgument) Parse ¶
func (b *AttachmentSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type BooleanSlashCommandArgument ¶
type BooleanSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*BooleanSlashCommandArgument) Parse ¶
func (b *BooleanSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type ChannelSlashCommandArgument ¶
type ChannelSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*ChannelSlashCommandArgument) Parse ¶
func (b *ChannelSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type CommandBuilder ¶
type CommandBuilder interface {
// contains filtered or unexported methods
}
type CommandMiddleware ¶
type CommandMiddleware = func(ctx *RespondingContext, next func()) error
type DGCommander ¶
type DGCommander struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, log *slog.Logger, session *discordgo.Session, timeProvider TimeProvider) *DGCommander
func (*DGCommander) AddCommand ¶
func (c *DGCommander) AddCommand(b CommandBuilder) (*discordgo.ApplicationCommand, error)
func (*DGCommander) AddMiddleware ¶
func (c *DGCommander) AddMiddleware(middleware CommandMiddleware) *DGCommander
type DefaultTimeProvider ¶
type DefaultTimeProvider struct{}
func (DefaultTimeProvider) Now ¶
func (DefaultTimeProvider) Now() time.Time
type IntegerSlashCommandArgument ¶
type IntegerSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*IntegerSlashCommandArgument) Name ¶
func (a *IntegerSlashCommandArgument) Name() string
func (*IntegerSlashCommandArgument) Parse ¶
func (a *IntegerSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type IntegerSlashCommandAutocompleteArgumentHandler ¶
type IntegerSlashCommandAutocompleteArgumentHandler struct {
IntegerSlashCommandArgument
// contains filtered or unexported fields
}
func (*IntegerSlashCommandAutocompleteArgumentHandler) Autocomplete ¶
func (arg *IntegerSlashCommandAutocompleteArgumentHandler) Autocomplete(ctx *SlashAutocompleteContext) error
func (*IntegerSlashCommandAutocompleteArgumentHandler) IsForOption ¶
func (arg *IntegerSlashCommandAutocompleteArgumentHandler) IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
type InvokationInformation ¶
type InvokationInformation struct {
DGC *DGCommander
Session *discordgo.Session
Sender *discordgo.User
I *discordgo.InteractionCreate
ReceivedTime time.Time
// contains filtered or unexported fields
}
type MemberSlashCommandArgument ¶
type MemberSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*MemberSlashCommandArgument) Parse ¶
func (b *MemberSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type MentionableSlashCommandArgument ¶
type MentionableSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*MentionableSlashCommandArgument) Name ¶
func (a *MentionableSlashCommandArgument) Name() string
func (*MentionableSlashCommandArgument) Parse ¶
func (a *MentionableSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type MessageCommandBuilder ¶
type MessageCommandBuilder struct {
// contains filtered or unexported fields
}
func NewMessageCommand ¶
func NewMessageCommand() *MessageCommandBuilder
func (*MessageCommandBuilder) AddMiddleware ¶
func (b *MessageCommandBuilder) AddMiddleware(middleware M) B
func (*MessageCommandBuilder) AllowEverywhere ¶
func (b *MessageCommandBuilder) AllowEverywhere(allowed bool) B
func (*MessageCommandBuilder) AllowInBotDM ¶
func (b *MessageCommandBuilder) AllowInBotDM(allowed bool) B
func (*MessageCommandBuilder) AllowInGuilds ¶
func (b *MessageCommandBuilder) AllowInGuilds(allowed bool) B
func (*MessageCommandBuilder) AllowInPrivateChannel ¶
func (b *MessageCommandBuilder) AllowInPrivateChannel(allowed bool) B
func (*MessageCommandBuilder) GuildInstallable ¶
func (b *MessageCommandBuilder) GuildInstallable(installable bool) B
func (*MessageCommandBuilder) Handler ¶
func (b *MessageCommandBuilder) Handler(handler MessageCommandHandler) *MessageCommandBuilder
func (*MessageCommandBuilder) Name ¶
func (b *MessageCommandBuilder) Name() *util.Localizable[B]
func (*MessageCommandBuilder) UserInstallable ¶
func (b *MessageCommandBuilder) UserInstallable(installable bool) B
type MessageCommandHandler ¶
type MessageCommandHandler func(ctx *MessageExecutionContext) error
type MessageExecutionContext ¶
type MessageExecutionContext struct {
*RespondingContext
Message *discordgo.Message
}
type MessageMiddleware ¶
type MessageMiddleware = func(info *MessageExecutionContext, next func()) error
type MiddlewareCallChainError ¶
type MiddlewareCallChainError struct{ DGCError }
func (MiddlewareCallChainError) Is ¶
func (e MiddlewareCallChainError) Is(target error) bool
func (MiddlewareCallChainError) New ¶
func (e MiddlewareCallChainError) New(errs ...error) MiddlewareCallChainError
func (MiddlewareCallChainError) Values ¶
func (e MiddlewareCallChainError) Values() (errs []error)
type MultiSlashCommandBuilder ¶
type MultiSlashCommandBuilder struct {
// contains filtered or unexported fields
}
func NewMultiSlashCommandBuilder ¶
func NewMultiSlashCommandBuilder() *MultiSlashCommandBuilder
func (*MultiSlashCommandBuilder) AddSubCommand ¶
func (b *MultiSlashCommandBuilder) AddSubCommand(command *SubSlashCommandBuilder) *MultiSlashCommandBuilder
func (*MultiSlashCommandBuilder) AddSubCommandGroup ¶
func (b *MultiSlashCommandBuilder) AddSubCommandGroup(group *SubSlashCommandGroupBuilder) *MultiSlashCommandBuilder
func (*MultiSlashCommandBuilder) Description ¶
func (b *MultiSlashCommandBuilder) Description() *util.Localizable[B]
type NumberSlashCommandArgument ¶
type NumberSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*NumberSlashCommandArgument) Parse ¶
func (b *NumberSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type NumberSlashCommandAutocompleteArgumentHandler ¶
type NumberSlashCommandAutocompleteArgumentHandler struct {
NumberSlashCommandArgument
// contains filtered or unexported fields
}
func (*NumberSlashCommandAutocompleteArgumentHandler) Autocomplete ¶
func (arg *NumberSlashCommandAutocompleteArgumentHandler) Autocomplete(ctx *SlashAutocompleteContext) error
func (*NumberSlashCommandAutocompleteArgumentHandler) IsForOption ¶
func (arg *NumberSlashCommandAutocompleteArgumentHandler) IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
type RespondingContext ¶
type RespondingContext struct {
// contains filtered or unexported fields
}
func (*RespondingContext) AddFollowup ¶
func (ctx *RespondingContext) AddFollowup(wait bool, data *discordgo.WebhookParams) (*discordgo.Message, error)
func (*RespondingContext) RespondLatter ¶
func (ctx *RespondingContext) RespondLatter() error
func (*RespondingContext) RespondWithMessage ¶
func (ctx *RespondingContext) RespondWithMessage(message *discordgo.InteractionResponseData) error
func (*RespondingContext) RespondWithModal ¶
func (ctx *RespondingContext) RespondWithModal(modal *discordgo.InteractionResponseData) error
type RoleSlashCommandArgument ¶
type RoleSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*RoleSlashCommandArgument) Parse ¶
func (b *RoleSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type SimpleSlashCommandBuilder ¶
type SimpleSlashCommandBuilder struct {
// contains filtered or unexported fields
}
func NewSimpleSlashCommandBuilder ¶
func NewSimpleSlashCommandBuilder() *SimpleSlashCommandBuilder
func (*SimpleSlashCommandBuilder) AddArgument ¶
func (b *SimpleSlashCommandBuilder) AddArgument(arg SlashCommandArgumentBuilder) B
func (*SimpleSlashCommandBuilder) AddArguments ¶
func (b *SimpleSlashCommandBuilder) AddArguments(args ...SlashCommandArgumentBuilder) B
func (*SimpleSlashCommandBuilder) Description ¶
func (b *SimpleSlashCommandBuilder) Description() *util.Localizable[B]
func (*SimpleSlashCommandBuilder) Handler ¶
func (b *SimpleSlashCommandBuilder) Handler(handler SlashCommandHandler) *SimpleSlashCommandBuilder
type SlashAutocompleteContext ¶
type SlashAutocompleteContext struct {
// contains filtered or unexported fields
}
func (*SlashAutocompleteContext) AddChoice ¶
func (ctx *SlashAutocompleteContext) AddChoice(name string, value any) *SlashAutocompleteContext
func (*SlashAutocompleteContext) AddLocalizedChoice ¶
func (ctx *SlashAutocompleteContext) AddLocalizedChoice(name string, value any, localizations map[discordgo.Locale]string) *SlashAutocompleteContext
func (*SlashAutocompleteContext) GetAttachment ¶
func (args *SlashAutocompleteContext) GetAttachment(name string) (value *discordgo.MessageAttachment, found bool)
func (*SlashAutocompleteContext) GetAttachmentOr ¶
func (args *SlashAutocompleteContext) GetAttachmentOr(name string, def *discordgo.MessageAttachment) *discordgo.MessageAttachment
func (*SlashAutocompleteContext) GetChannel ¶
func (*SlashAutocompleteContext) GetChannelOr ¶
func (*SlashAutocompleteContext) GetInteger ¶
func (*SlashAutocompleteContext) GetIntegerOr ¶
func (*SlashAutocompleteContext) GetMemberOr ¶
func (*SlashAutocompleteContext) GetNumberOr ¶
func (*SlashAutocompleteContext) GetRequiredAttachment ¶
func (args *SlashAutocompleteContext) GetRequiredAttachment(name string) *discordgo.MessageAttachment
func (*SlashAutocompleteContext) GetRequiredBool ¶
func (*SlashAutocompleteContext) GetRequiredChannel ¶
func (*SlashAutocompleteContext) GetRequiredInteger ¶
func (*SlashAutocompleteContext) GetRequiredMember ¶
func (*SlashAutocompleteContext) GetRequiredNumber ¶
func (*SlashAutocompleteContext) GetRequiredRole ¶
func (*SlashAutocompleteContext) GetRequiredString ¶
func (*SlashAutocompleteContext) GetRequiredUser ¶
func (*SlashAutocompleteContext) GetStringOr ¶
type SlashCommandArgument ¶
type SlashCommandArgument interface {
// Parse extracts the value of this argument based on the provided parsing information.
//
// It returns:
// - valueName: the name associated with the parsed value.
// - value: the parsed value of this argument.
//
// Errors:
// - ErrArgumentHasNoValue: if the value of this argument is not present.
// - ErrArgumentHasInvalidValue: if the value of this argument has an invalid type.
Parse(info *ArgumentParsingInformation) (valueName string, value any, err error)
Name() string
}
SlashCommandArgument represents an argument in a slash command that can parse its value from provided argument parsing information.
type SlashCommandArgumentBuilder ¶
type SlashCommandArgumentBuilder interface {
DiscordDefineForCreation() *discordgo.ApplicationCommandOption
// If the returned requiredName is not nil, when the arguments of a given command are being parsed, a value associated
// to the returned requiredName must be present, if not, the handler of the command won't be invoked, returning an error
// ErrMissingRequiredArguments to the user who used the command
Create() (requiredName *string, argument SlashCommandArgument)
}
type SlashCommandAutocompleteArgument ¶
type SlashCommandAutocompleteArgument interface {
SlashCommandArgument
IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
Autocomplete(*SlashAutocompleteContext) error
}
type SlashCommandAutocompleteArgumentHandler ¶
type SlashCommandAutocompleteArgumentHandler func(*SlashAutocompleteContext) error
type SlashCommandHandler ¶
type SlashCommandHandler func(ctx *SlashExecutionContext) error
type SlashExecutionContext ¶
type SlashExecutionContext struct {
*RespondingContext
// contains filtered or unexported fields
}
func (*SlashExecutionContext) GetAttachment ¶
func (args *SlashExecutionContext) GetAttachment(name string) (value *discordgo.MessageAttachment, found bool)
func (*SlashExecutionContext) GetAttachmentOr ¶
func (args *SlashExecutionContext) GetAttachmentOr(name string, def *discordgo.MessageAttachment) *discordgo.MessageAttachment
func (*SlashExecutionContext) GetChannel ¶
func (*SlashExecutionContext) GetChannelOr ¶
func (*SlashExecutionContext) GetInteger ¶
func (*SlashExecutionContext) GetIntegerOr ¶
func (*SlashExecutionContext) GetMemberOr ¶
func (*SlashExecutionContext) GetNumberOr ¶
func (*SlashExecutionContext) GetRequiredAttachment ¶
func (args *SlashExecutionContext) GetRequiredAttachment(name string) *discordgo.MessageAttachment
func (*SlashExecutionContext) GetRequiredBool ¶
func (*SlashExecutionContext) GetRequiredChannel ¶
func (*SlashExecutionContext) GetRequiredInteger ¶
func (*SlashExecutionContext) GetRequiredMember ¶
func (*SlashExecutionContext) GetRequiredNumber ¶
func (*SlashExecutionContext) GetRequiredRole ¶
func (*SlashExecutionContext) GetRequiredString ¶
func (*SlashExecutionContext) GetRequiredUser ¶
func (*SlashExecutionContext) GetStringOr ¶
type SlashMultiMiddleware ¶
type SlashMultiMiddleware = func(ctx *RespondingContext, next func()) error
type SlashSimpleMiddleware ¶
type SlashSimpleMiddleware = func(ctx *SlashExecutionContext, next func()) error
type StringSlashCommandArgument ¶
type StringSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*StringSlashCommandArgument) Parse ¶
func (b *StringSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
type StringSlashCommandAutocompleteArgumentHandler ¶
type StringSlashCommandAutocompleteArgumentHandler struct {
StringSlashCommandArgument
// contains filtered or unexported fields
}
func (*StringSlashCommandAutocompleteArgumentHandler) Autocomplete ¶
func (arg *StringSlashCommandAutocompleteArgumentHandler) Autocomplete(ctx *SlashAutocompleteContext) error
func (*StringSlashCommandAutocompleteArgumentHandler) IsForOption ¶
func (arg *StringSlashCommandAutocompleteArgumentHandler) IsForOption(option *discordgo.ApplicationCommandInteractionDataOption) bool
type SubSlashCommandBuilder ¶
type SubSlashCommandBuilder struct {
// contains filtered or unexported fields
}
func NewSubCommand ¶
func NewSubCommand() *SubSlashCommandBuilder
func (*SubSlashCommandBuilder) AddArgument ¶
func (b *SubSlashCommandBuilder) AddArgument(arg SlashCommandArgumentBuilder) B
func (*SubSlashCommandBuilder) AddArguments ¶
func (b *SubSlashCommandBuilder) AddArguments(args ...SlashCommandArgumentBuilder) B
func (*SubSlashCommandBuilder) AddMiddleware ¶
func (b *SubSlashCommandBuilder) AddMiddleware(middleware SlashSimpleMiddleware) *SubSlashCommandBuilder
func (*SubSlashCommandBuilder) Description ¶
func (b *SubSlashCommandBuilder) Description() *util.Localizable[*SubSlashCommandBuilder]
func (*SubSlashCommandBuilder) Handler ¶
func (b *SubSlashCommandBuilder) Handler(handler SlashCommandHandler) *SubSlashCommandBuilder
func (*SubSlashCommandBuilder) Name ¶
func (b *SubSlashCommandBuilder) Name() *util.Localizable[*SubSlashCommandBuilder]
type SubSlashCommandGroupBuilder ¶
type SubSlashCommandGroupBuilder struct {
// contains filtered or unexported fields
}
func NewSubCommandGroup ¶
func NewSubCommandGroup() *SubSlashCommandGroupBuilder
func (*SubSlashCommandGroupBuilder) AddMiddleware ¶
func (b *SubSlashCommandGroupBuilder) AddMiddleware(middleware SlashMultiMiddleware) *SubSlashCommandGroupBuilder
func (*SubSlashCommandGroupBuilder) AddSubCommand ¶
func (b *SubSlashCommandGroupBuilder) AddSubCommand(command *SubSlashCommandBuilder) *SubSlashCommandGroupBuilder
func (*SubSlashCommandGroupBuilder) AddSubCommands ¶
func (b *SubSlashCommandGroupBuilder) AddSubCommands(commands ...*SubSlashCommandBuilder) *SubSlashCommandGroupBuilder
func (*SubSlashCommandGroupBuilder) Description ¶
func (b *SubSlashCommandGroupBuilder) Description() *util.Localizable[*SubSlashCommandGroupBuilder]
func (*SubSlashCommandGroupBuilder) Name ¶
func (b *SubSlashCommandGroupBuilder) Name() *util.Localizable[*SubSlashCommandGroupBuilder]
type TimeProvider ¶
type UserCommandBuilder ¶
type UserCommandBuilder struct {
// contains filtered or unexported fields
}
func NewUserCommand ¶
func NewUserCommand() *UserCommandBuilder
func (*UserCommandBuilder) AddMiddleware ¶
func (b *UserCommandBuilder) AddMiddleware(middleware M) B
func (*UserCommandBuilder) AllowEverywhere ¶
func (b *UserCommandBuilder) AllowEverywhere(allowed bool) B
func (*UserCommandBuilder) AllowInBotDM ¶
func (b *UserCommandBuilder) AllowInBotDM(allowed bool) B
func (*UserCommandBuilder) AllowInGuilds ¶
func (b *UserCommandBuilder) AllowInGuilds(allowed bool) B
func (*UserCommandBuilder) AllowInPrivateChannel ¶
func (b *UserCommandBuilder) AllowInPrivateChannel(allowed bool) B
func (*UserCommandBuilder) GuildInstallable ¶
func (b *UserCommandBuilder) GuildInstallable(installable bool) B
func (*UserCommandBuilder) Handler ¶
func (b *UserCommandBuilder) Handler(handler UserCommandHandler) *UserCommandBuilder
func (*UserCommandBuilder) Name ¶
func (b *UserCommandBuilder) Name() *util.Localizable[B]
func (*UserCommandBuilder) UserInstallable ¶
func (b *UserCommandBuilder) UserInstallable(installable bool) B
type UserCommandHandler ¶
type UserCommandHandler func(ctx *UserExecutionContext) error
type UserExecutionContext ¶
type UserExecutionContext struct {
*RespondingContext
User *discordgo.User
Member *discordgo.Member // Nil if not running on a guild
}
type UserMiddleware ¶
type UserMiddleware = func(ctx *UserExecutionContext, next func()) error
type UserSlashCommandArgument ¶
type UserSlashCommandArgument struct {
// contains filtered or unexported fields
}
func (*UserSlashCommandArgument) Parse ¶
func (b *UserSlashCommandArgument) Parse(info *ArgumentParsingInformation) (string, any, error)
Source Files
¶
- command_builder.go
- context.go
- dgcommander.go
- errors.go
- message_builder.go
- message_handler.go
- middleware.go
- slash_argument_builder.go
- slash_argument_builder_autocomplete.go
- slash_argument_builder_choices.go
- slash_argument_handler.go
- slash_argument_handler_autocomplete.go
- slash_argument_list_builder.go
- slash_argument_list_handler.go
- slash_argument_list_handler_errors.go
- slash_argument_list_handler_getters.go
- slash_builder.go
- slash_handler.go
- user_builder.go
- user_handler.go
- util.go
Click to show internal directories.
Click to hide internal directories.