bot

package
v0.0.0-...-9b2646f Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessageIDRe = regexp.MustCompile("https?://(?:canary\\.|ptb\\.)?discord\\.com/channels/[0-9]+/([0-9]+)/([0-9]+)")

Functions

This section is empty.

Types

type Bot

type Bot struct {
	*sharding.ShardManager

	ActionHandler *handler.ActionHandler
	ActionParser  *parser.ActionParser
	// contains filtered or unexported fields
}

func New

func New(token string, pg *postgres.PostgresStore) (*Bot, error)

func (*Bot) EditMessageInChannel

func (b *Bot) EditMessageInChannel(ctx context.Context, channelID string, messageID string, params *discordgo.WebhookEdit) (*discordgo.Message, error)

EditMessageInChannel edits a message in a channel, either sent by a webhook or by the configured custom bot.

func (*Bot) FindWebhookForChannel

func (b *Bot) FindWebhookForChannel(ctx context.Context, channelID string) (*discordgo.Webhook, error)

FindWebhookForChannel returns a webhook for the given channel that was created by the bot or the configured custom bot.

func (*Bot) GetSessionForGuild

func (b *Bot) GetSessionForGuild(ctx context.Context, guildId string) (*discordgo.Session, error)

GetSessionForGuild returns the session for the given guild. If a custom bot is configured for the guild, the token of the custom bot will be used to create the session.

func (*Bot) GetWebhookForChannel

func (b *Bot) GetWebhookForChannel(ctx context.Context, channelID string, webhookID string) (*discordgo.Webhook, error)

GetWebhookForChannel returns the webhook for the given channel if available.

func (*Bot) HandleEntitlementEvent

func (b *Bot) HandleEntitlementEvent(e *Entitlement)

func (*Bot) RegisterCommand

func (b *Bot) RegisterCommand() error

func (*Bot) SendMessageToChannel

func (b *Bot) SendMessageToChannel(ctx context.Context, channelID string, params *discordgo.WebhookParams) (*discordgo.Message, error)

SendMessageToChannel sends a message to a channel, either using a webhook or using the configured custom bot.

func (*Bot) Start

func (b *Bot) Start() error

type Entitlement

type Entitlement struct {
	ID       string    `json:"id"`
	UserID   string    `json:"user_id"`
	GuildID  string    `json:"guild_id"`
	SKUID    string    `json:"sku_id"`
	Deleted  bool      `json:"deleted"`
	StartsAt null.Time `json:"starts_at"`
	EndsAt   null.Time `json:"ends_at"`
	Consumed bool      `json:"consumed"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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