bot

package
v0.0.0-...-e364c34 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const Colour = 0x2A52BE

Colour is the embed colour used throughout the bot

View Source
const ErrUnknownEvent = errors.Sentinel("unknown event type")

Intents are the bot's gateway intents

View Source
const Reschedule = errors.Sentinel("reschedule event")

Return Reschedule if the event should be rescheduled (offset by the duration returned from Offset)

Variables

This section is empty.

Functions

func IsThread

func IsThread(ch *discord.Channel) bool

Types

type Bot

type Bot struct {
	*bot.Bot

	Colour discord.Color

	Interactions *bcr2.Router
	State        *state.State
	DB           *db.DB
	Scheduler    *Scheduler
	Checker      *Checker
	PK           *pkgo.Session
}

Bot ...

func New

func New(conf common.BotConfig) (b *Bot, err error)

New ...

func (*Bot) CheckIfReady

func (bot *Bot) CheckIfReady()

CheckIfReady ...

func (*Bot) Prefix

func (bot *Bot) Prefix() string

Prefix only exists because i'm lazy

func (*Bot) Ready

func (bot *Bot) Ready(*gateway.ReadyEvent)

Ready ...

func (*Bot) Report

func (bot *Bot) Report(ctx *bcr.Context, err error) error

Report sends an error message to the log channel.

func (*Bot) RootChannel

func (bot *Bot) RootChannel(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) SendError

func (bot *Bot) SendError(tmpl string, args ...interface{})

SendError ...

func (*Bot) SendLog

func (bot *Bot) SendLog(tmpl string, args ...interface{})

SendLog ...

func (*Bot) WaitForGuild

func (bot *Bot) WaitForGuild(ev *gateway.GuildCreateEvent)

WaitForGuild ...

type Checker

type Checker struct {
	*db.DB
	*Bot
}

Checker ...

func (*Checker) Check

func (c *Checker) Check(ctx bcr.Contexter) (bool, error)

Check checks permissions!

func (Checker) String

func (c Checker) String(ctx bcr.Contexter) string

type Event

type Event interface {
	Execute(ctx context.Context, id int64, bot *Bot) error
	Offset() time.Duration
}

Event is any event that can be scheduled. Execute is called when the event is due to fire, Offset is called to determine how much to move the event.

type Scheduler

type Scheduler struct {
	*Bot
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(bot *Bot) *Scheduler

func (*Scheduler) Add

func (s *Scheduler) Add(t time.Time, v Event) (id int64, err error)

func (*Scheduler) AddType

func (s *Scheduler) AddType(events ...Event)

AddType adds event types. These should be *pointers*, anything else will panic, even if it implements Event!

func (*Scheduler) Remove

func (s *Scheduler) Remove(id int64) error

func (*Scheduler) Reschedule

func (s *Scheduler) Reschedule(id int64, dur time.Duration) error

func (*Scheduler) Start

func (s *Scheduler) Start()

Start starts the scheduler. *This function is blocking!*

Jump to

Keyboard shortcuts

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