discord

package
v0.0.0-...-50e0f8f Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommandNotImplemented                   = errors.New("command not implemented")
	ErrInvalidCommand                          = errors.New("input did not satisfy a command interface")
	ErrNotApplicationCommandInteractionHandler = errors.New("command does not implement the application command interaction handler interface")
	ErrNotMessageComponentInteractionHandler   = errors.New("command does not implement the message component interaction handler interface")
	ErrNotMessageHandler                       = errors.New("command does not implement the message handler interface")
)

Functions

func RequestOptions

func RequestOptions(ctx context.Context, reason ...string) discordgo.RequestOption

Types

type ApplicationCommandMetadata

type ApplicationCommandMetadata interface {
	ApplicationCommand() *discordgo.ApplicationCommand
}

type Bot

type Bot struct {
	BotOptions
	Session  *discordgo.Session
	Commands map[string]any
}

func NewBot

func NewBot(opts BotOptions) (*Bot, error)

func (*Bot) Close

func (b *Bot) Close() error

func (*Bot) GetEmoji

func (b *Bot) GetEmoji(name string) *discordgo.Emoji

func (*Bot) GetEmojiForMessage

func (b *Bot) GetEmojiForMessage(name, fallback string) string

func (*Bot) GetEmojiForReaction

func (b *Bot) GetEmojiForReaction(name, fallback string) string

func (*Bot) GetGuild

func (b *Bot) GetGuild(ctx context.Context, id string) (*discordgo.Guild, error)

func (*Bot) GetUserVoiceChannel

func (b *Bot) GetUserVoiceChannel(userID string) (guildID, channelID string)

func (*Bot) Health

func (b *Bot) Health(ctx context.Context) (any, error)

func (*Bot) JoinUserVoiceChannel

func (b *Bot) JoinUserVoiceChannel(userID string) (*discordgo.VoiceConnection, error)

func (*Bot) LeaveUserVoiceChannel

func (b *Bot) LeaveUserVoiceChannel(userID string) error

func (*Bot) Open

func (b *Bot) Open(ctx context.Context, deadline time.Duration) error

func (*Bot) Ready

func (b *Bot) Ready(ctx context.Context) bool

func (*Bot) RegisterCommand

func (b *Bot) RegisterCommand(ctx context.Context, cmd any) error

func (*Bot) RegisterInteractions

func (b *Bot) RegisterInteractions(ctx context.Context) error

func (*Bot) SendInteractionDeferral

func (b *Bot) SendInteractionDeferral(ctx context.Context, interaction *discordgo.Interaction) error

func (*Bot) SendInteractionEdit

func (b *Bot) SendInteractionEdit(ctx context.Context, interaction *discordgo.Interaction, edit *discordgo.WebhookEdit) error

func (*Bot) SendInteractionMessageReply

func (b *Bot) SendInteractionMessageReply(ctx context.Context, interaction *discordgo.Interaction, content string) error

func (*Bot) SendInteractionReply

func (b *Bot) SendInteractionReply(ctx context.Context, interaction *discordgo.Interaction, response *discordgo.InteractionResponse) error

func (*Bot) SendMessageReaction

func (b *Bot) SendMessageReaction(ctx context.Context, message *discordgo.Message, emoji, emojiFallback string) error

func (*Bot) SendMessageReply

func (b *Bot) SendMessageReply(ctx context.Context, message *discordgo.Message, content string) error

type BotOptions

type BotOptions struct {
	AppID         string
	BotToken      string
	MessagePrefix string
}

type CommandMetadata

type CommandMetadata interface {
	Name() string
	Description() string
}

type Guild

type Guild struct{ *discordgo.Guild }

func GuildFromContext

func GuildFromContext(ctx context.Context) *Guild

func (*Guild) GetEmoji

func (g *Guild) GetEmoji(id string) *discordgo.Emoji

func (*Guild) InContext

func (g *Guild) InContext(ctx context.Context) context.Context

type MessageEmbed

type MessageEmbed discordgo.MessageEmbed

func NewMessageEmbed

func NewMessageEmbed() *MessageEmbed

func (*MessageEmbed) AddField

func (e *MessageEmbed) AddField(name, value string, isInline ...bool) *MessageEmbed

func (*MessageEmbed) Embed

func (e *MessageEmbed) Embed() *discordgo.MessageEmbed

func (*MessageEmbed) SetTitle

func (e *MessageEmbed) SetTitle(title string) *MessageEmbed

func (*MessageEmbed) SetType

func (e *MessageEmbed) SetType(embedType discordgo.EmbedType) *MessageEmbed

func (*MessageEmbed) SetURL

func (e *MessageEmbed) SetURL(url string) *MessageEmbed

type MessageHandler

type MessageHandler interface {
	CommandMetadata
	OnMessage(context.Context, *Bot, *discordgo.MessageCreate, []string)
}

Jump to

Keyboard shortcuts

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