events

package
v0.0.0-...-ab45ee7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotExists = errors.Sentinel("webhook not found in cache")
	ErrInvalid   = errors.Sentinel("invalid cache value")
)

Errors for the webhook cache

Variables

This section is empty.

Functions

func Init

func Init(bot *bot.Bot) (clearCacheFunc func(discord.GuildID, ...discord.ChannelID), memberFunc func() int64, guildPermFunc func(discord.GuildID, discord.UserID) (discord.Guild, discord.Permissions, error), joinedFunc func(discord.GuildID) bool)

Init ...

func IsThread

func IsThread(ch *discord.Channel) bool

Types

type Bot

type Bot struct {
	*bot.Bot

	SentryEnricher *handler.SentryHandler

	ProxiedTriggers        *concurrent.Set[discord.MessageID]
	HandledMessages        *concurrent.Set[discord.MessageID]
	UnauthorizedErrorsSent *concurrent.Map[discord.ChannelID, time.Time]
	Queues                 *concurrent.Map[discord.WebhookID, *Queue]
	WebhookClients         *concurrent.Map[discord.WebhookID, *webhook.Client]

	BotJoinLeaveLog discord.ChannelID

	Start time.Time

	EventHandler *handler.Handler
	// contains filtered or unexported fields
}

Bot ...

func (*Bot) GetWebhook

func (bot *Bot) GetWebhook(id discord.ChannelID) (*Webhook, error)

GetWebhook gets a cached webhook from redis

func (*Bot) HandleCache

func (bot *Bot) HandleCache(iface interface{})

func (*Bot) Invites

func (bot *Bot) Invites(guildID discord.GuildID) ([]discord.Invite, error)

func (*Bot) Member

func (bot *Bot) Member(guildID discord.GuildID, userID discord.UserID) (discord.Member, error)

func (*Bot) MemberContext

func (bot *Bot) MemberContext(ctx context.Context, guildID discord.GuildID, userID discord.UserID) (discord.Member, error)

func (*Bot) Queue

func (bot *Bot) Queue(wh *discord.Webhook, event string, embed discord.Embed)

Queue queues an embed.

func (*Bot) ResetCache

func (bot *Bot) ResetCache(id discord.GuildID, channels ...discord.ChannelID)

ResetCache ...

func (*Bot) RootChannel

func (bot *Bot) RootChannel(guildID discord.GuildID, id discord.ChannelID) (*discord.Channel, error)

RootChannel returns the given channel's root channel--either the channel itself, or the parent channel if it's a thread.

func (*Bot) Send

func (bot *Bot) Send(wh *discord.Webhook, event string, embeds ...discord.Embed)

Send either sends a slice of embeds immediately, or queues a single embed

func (*Bot) SetInvites

func (bot *Bot) SetInvites(guildID discord.GuildID, is []discord.Invite) error

func (*Bot) SetWebhook

func (bot *Bot) SetWebhook(channelID discord.ChannelID, w *Webhook) error

SetWebhook ...

func (*Bot) State

func (bot *Bot) State(id discord.GuildID) *state.State

State gets a state.State for the guild

func (*Bot) WebhookClient

func (bot *Bot) WebhookClient(wh *discord.Webhook) *webhook.Client

WebhookClient gets a client for the given webhook.

type GuildKeyRoleUpdateEvent

type GuildKeyRoleUpdateEvent struct {
	*gateway.GuildMemberUpdateEvent

	ChannelID    discord.ChannelID
	AddedRoles   []discord.RoleID
	RemovedRoles []discord.RoleID
}

GuildKeyRoleUpdateEvent ...

type MemberKickEvent

type MemberKickEvent struct {
	ChannelID discord.ChannelID

	Entry     discord.AuditLogEntry
	User      discord.User
	Moderator *discord.User
}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a webhook embed queue.

func NewQueue

func NewQueue() *Queue

NewQueue returns a new Queue

func (*Queue) TotalLength

func (q *Queue) TotalLength() (length int)

TotalLength returns the total length of all embeds in this Queue.

type Webhook

type Webhook struct {
	ID    discord.WebhookID
	Token string
}

Webhook ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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