bot

package
v0.0.0-...-a139185 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: AGPL-3.0 Imports: 30 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
	Config common.Config
	DB     *db.DB

	Sentry    *sentry.Hub
	UseSentry bool

	Guilds   map[discord.GuildID]discord.Guild
	GuildsMu sync.Mutex

	Stats *StatsClient

	Helper       *helper.Helper
	StartStopLog *webhook.Client
	// contains filtered or unexported fields
}

Bot is the main bot struct

func New

func New(
	bot *bcrbot.Bot,
	config common.Config,
	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) InteractionCreate

func (bot *Bot) InteractionCreate(ic *gateway.InteractionCreateEvent)

InteractionCreate is called when an interaction create event is received.

func (*Bot) MessageCreate

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

MessageCreate is run when a message is created and handles commands

func (*Bot) Prefixer

func (bot *Bot) Prefixer(m discord.Message) (n int)

Prefixer ...

func (*Bot) PrefixesFor

func (bot *Bot) PrefixesFor(id discord.GuildID) (s []string)

PrefixesFor returns the prefixes for the given server

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"

type StatsClient

type StatsClient struct {
	Client api.WriteAPI
	// contains filtered or unexported fields
}

StatsClient is an InfluxDB client

func (*StatsClient) IncAPICall

func (c *StatsClient) IncAPICall()

IncAPICall increments the API call count by one

func (*StatsClient) IncCommand

func (c *StatsClient) IncCommand()

IncCommand increments the command count by one

func (*StatsClient) IncQuery

func (c *StatsClient) IncQuery()

IncQuery increments the query count by one

Directories

Path Synopsis
Package cc contains types and functions for generating static commands from JSON files.
Package cc contains types and functions for generating static commands from JSON files.

Jump to

Keyboard shortcuts

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