botutil

package
v0.0.0-...-4dc768e Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHelp

func BuildHelp(feature Feature) (embed *dg.MessageEmbed)

BuildHelp makes a help message embed.

func FilterTag

func FilterTag(tag string) string

FilterTag takes intakes a ID formatted by the Discord client ie <#ID>, <:ID>, or <#ID> and returns ID.

func HasRole

func HasRole(has []string, required []string) bool

HasRole Check if a user has a role

func Mention

func Mention(s *dg.Session, userID string, channelID string, context string) (*dg.Message, error)

Mention mentions a given user in a channel.

func Reply

func Reply(s *dg.Session, msg *dg.Message, context string) (*dg.Message, error)

Reply sends a response in the same channel to the same user who sent the message. The sent message and possible error is returned.

func VerifyEmbed

func VerifyEmbed(e *dg.MessageEmbed) error

Types

type Command

type Command struct {
	// Name is the command name that is callable by a Discord user
	// ie. "request"
	Name string
	// Description describes your command's usage
	// ie. "This is for request a new nickname"
	Description string
	// Example is example usage of the command
	// ie. [".nick", "request", "new nickname"]
	Example []string
}

Command are all the possible commands that exist.

type ControlEmojis

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

ControlEmojis contains the structure and default structure for pagination emojis

type Embed

type Embed struct {
	*dg.MessageEmbed
}

Embed structure

func NewEmbed

func NewEmbed() *Embed

NewEmbed returns a new embed object

func (*Embed) AddField

func (e *Embed) AddField(Name string, Value string, Inline bool)

AddField takes <Name string> <Value string> <Inline bool> Returns an embed with embed field set <Name> <Value> <Inline>

func (*Embed) ChannelMessageEditEmbed

func (e *Embed) ChannelMessageEditEmbed(s *dg.Session, channelID string, messageID string) (*dg.Message, error)

ChannelMessageEditEmbed takes <s *dg.Session>, <channelID string>, <messageID string> Verifies embed and edits message with new embed Returns message and error

func (*Embed) InlineAllFields

func (e *Embed) InlineAllFields() *Embed

InlineAllFields sets all fields in the embed to be inline

func (*Embed) SendToChannel

func (e *Embed) SendToChannel(s *dg.Session, channelID string) (*dg.Message, error)

SendToChannel takes <s *dg.Session>, <channelID string> Verifies embed and sends embed to channel Returns message and error

func (*Embed) SendToWebhook

func (e *Embed) SendToWebhook(Webhook string) error

SendToWebhook takes <Webhook string> Sends embed to webhook Returns error if invalid embed or error posting to webhook

func (*Embed) SetAuthor

func (e *Embed) SetAuthor(Name string, IconURL string, URL string)

SetAuthor takes <Name string> <IconURL string> <URL string> Returns embed with author set <Name> <IconURL> <URL>

func (*Embed) SetColor

func (e *Embed) SetColor(ColorByte int)

SetColor takes <Color string> Sets color of embed to <Color> Returns error

func (*Embed) SetDescription

func (e *Embed) SetDescription(Description string)

SetDescription takes <Description string> Sets embed with description set <Description>

func (*Embed) SetFooter

func (e *Embed) SetFooter(IconURL string, Text string)

SetFooter takes <IconURL string> <Text string> Sets embed with embed footer set <Iconurl> <Text>

func (*Embed) SetImage

func (e *Embed) SetImage(URL string)

SetImage takes <URL string> Sets embed image <URL>

func (*Embed) SetThumbnail

func (e *Embed) SetThumbnail(URL string)

SetThumbnail takes <URL string> Sets embed thumbnail to <URL>

func (*Embed) SetTitle

func (e *Embed) SetTitle(Title string)

SetTitle takes <Title string> Sets embed with title set <Title>

func (*Embed) SetURL

func (e *Embed) SetURL(URL string)

SetURL takes <URL string> Sets embed url <URL>

func (*Embed) Truncate

func (e *Embed) Truncate() *Embed

Truncate truncates the number of embed fields over the character limit.

type Feature

type Feature struct {
	// Name of your feature ie. "Nickname Manager"
	Name string
	// Description for describing your feature "Moderates nicknames"
	Description string
	// Commands are all the possible commands that exist, optionally empty.
	Commands []*Command
	// Prefix is the prefix for your bot.
	Prefix string
}

Feature represents your bot.

type Paginator

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

Paginator contains the structure for the paginator.

func NewPaginator

func NewPaginator(s *dg.Session, channelID string, user *dg.User, controlEmojis ControlEmojis,
	timeOut time.Duration, infoMessages bool) *Paginator

NewPaginator takes <s *dg.Session>, <channelID string>, <user *dg.User> Returns standard *Paginator

func (*Paginator) Add

func (p *Paginator) Add(e *dg.MessageEmbed) error

Add takes <e *dg.MessageEmbed> Verifies embed and adds embed to the paginator pages returns error

func (*Paginator) Run

func (p *Paginator) Run() error

Run runs the paginator

Jump to

Keyboard shortcuts

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