bot

package
v0.0.0-...-2970e9b Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package bot contains the bot's core functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	*bcrbot.Bot

	Sugar  *zap.SugaredLogger
	Config *structs.BotConfig
	DB     *db.Db

	Sentry    *sentry.Hub
	UseSentry bool
}

Bot is the main bot struct

func New

func New(
	bot *bcrbot.Bot,
	s *zap.SugaredLogger,
	config *structs.BotConfig,
	db *db.Db, hub *sentry.Hub) *Bot

New creates a new instance of Bot

func (*Bot) Add

func (bot *Bot) Add(f func(*Bot) (string, []*bcr.Command))

Add adds a module to the bot

func (*Bot) GuildCreate

func (bot *Bot) GuildCreate(g *gateway.GuildCreateEvent)

GuildCreate logs the bot joining a server, and creates a database entry if one doesn't exist

func (*Bot) GuildDelete

func (bot *Bot) GuildDelete(g *gateway.GuildDeleteEvent)

GuildDelete logs the bot leaving a server and deletes the database entry

func (*Bot) MessageCreate

func (bot *Bot) MessageCreate(m *gateway.MessageCreateEvent)

MessageCreate is run when a message is created and handles commands

func (*Bot) Report

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

Report reports an exception to Sentry if that's used, and the error is "our problem"

func (*Bot) UpdateStatus

func (bot *Bot) UpdateStatus(name string, s gateway.Status) (err error)

UpdateStatus sets the bot's status to the given string

type Module

type Module interface {
	String() string
	Commands() []*bcr.Command
}

Module is a single module/category of commands

Jump to

Keyboard shortcuts

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