discord

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnilistColor   = 0x02a9ff
	AnilistIconURL = "https://anilist.co/img/icons/favicon-32x32.png"
)

Variables

This section is empty.

Functions

func DropEmbed

func DropEmbed(ctx context.Context, char MediaCharacter) (corde.Message, func())

func New

func New(b *Bot) *corde.Mux

New runs the bot

Types

type AnimeSearcher

type AnimeSearcher interface {
	Anime(context.Context, string) ([]Media, error)
}

type Bot

type Bot struct {
	Store             Store
	AnimeService      TrackingService
	Inter             Interacter
	AppID             corde.Snowflake
	GuildID           *corde.Snowflake
	BotToken          string
	PublicKey         string
	RollCooldown      time.Duration
	InteractionNeeded int64
	TokensNeeded      int32
	// contains filtered or unexported fields
}

Bot holds the bot state

func (*Bot) RegisterCommands

func (b *Bot) RegisterCommands() error

This init is called when ran with the build tag.

func (*Bot) RemoveUnknownCommands

func (b *Bot) RemoveUnknownCommands(ctx context.Context, r corde.ResponseWriter, i *corde.Interaction[corde.JsonRaw])

type CharSearcher

type CharSearcher interface {
	Character(context.Context, string) ([]MediaCharacter, error)
}

type Character

type Character struct {
	Date   time.Time       `json:"date"`
	Image  string          `json:"image"`
	Name   string          `json:"name"`
	Type   string          `json:"type"`
	UserID corde.Snowflake `json:"user_id"`
	ID     int64           `json:"id"`
}

type Interacter

type Interacter interface {
	GetInteractionCount(ctx context.Context, channelID corde.Snowflake) (int64, error)
	ResetInteractionCount(ctx context.Context, channelID corde.Snowflake) error
	IncrementInteractionCount(ctx context.Context, channelID corde.Snowflake) error

	SetChannelChar(ctx context.Context, channelID corde.Snowflake, char MediaCharacter) error
	GetChannelChar(ctx context.Context, channelID corde.Snowflake) (MediaCharacter, error)
	RemoveChannelChar(ctx context.Context, channelID corde.Snowflake) error
}

Interacter

type MangaSearcher

type MangaSearcher interface {
	Manga(context.Context, string) ([]Media, error)
}

type Media

type Media struct {
	Title           string
	URL             string
	CoverImageURL   string
	BannerImageURL  string
	CoverImageColor uint32
	Description     string
}

Media represents an anime or manga.

type MediaCharacter

type MediaCharacter struct {
	ID          int64
	Name        string
	ImageURL    string
	URL         string
	Description string
	MediaTitle  string
}

type Profile

type Profile struct {
	User
	CharacterCount int
	Favorite       Character
}

type RandomCharer

type RandomCharer interface {
	RandomChar(ctx context.Context, notIn ...int64) (MediaCharacter, error)
}

type Store

Store is the database

type TrackerUser

type TrackerUser struct {
	Name     string
	URL      string
	ImageURL string
	About    string
}

TrackerUser represents an anime tracker user.

type TrackingService

TrackingService is the interface for the anilist service

type User

type User struct {
	Date       time.Time       `json:"date"`
	Quote      string          `json:"quote"`
	Favorite   uint64          `json:"favorite"`
	UserID     corde.Snowflake `json:"user_id"`
	AnilistURL string          `json:"anilist_url,omitempty"`
	Tokens     int32           `json:"tokens"`
}

type UserSearcher

type UserSearcher interface {
	User(context.Context, string) ([]TrackerUser, error)
}

Jump to

Keyboard shortcuts

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