discord

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const WebhookName = "BirdBot"

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(guildEvent *discordgo.GuildScheduledEvent) common.Event

NewEvent converts a discordgo.GuildScheduledEvent to birdbot event

func NewUser

func NewUser(user *discordgo.User) common.User

NewUser creates a new user object from a discordgo.User object

Types

type ActionRow added in v0.3.0

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

func (*ActionRow) AddComponent added in v0.3.0

func (row *ActionRow) AddComponent(comp Component)

AddComponent adds a component to the action row

type Button added in v0.3.0

type Button struct {
	Label string
	ID    string

	Emoji *Emoji
	// contains filtered or unexported fields
}

func (*Button) OnClick added in v0.3.0

func (button *Button) OnClick(action func(user common.User))

OnClick registers an event when the button is clicked

type Component added in v0.3.0

type Component interface {
	// contains filtered or unexported methods
}

Component is an object that can be formatted as a discord component

type Discord

type Discord struct {
	mock.Mock
	// contains filtered or unexported fields
}

func New

func New(applicationID string, guildID string, token string, db persistence.Database) *Discord

New creates a new Discord session

func (*Discord) ArchiveChannel

func (discord *Discord) ArchiveChannel(channel *core.Channel) error

ArchiveChannel archives a channel

func (*Discord) AssignRole added in v0.3.0

func (discord *Discord) AssignRole(user common.User, role *Role) error

AssignRole adds a role to a user

func (*Discord) ClearCommands added in v0.4.2

func (discord *Discord) ClearCommands()

ClearCommands deregisters all commands from the discord API

func (*Discord) CreateEmoji added in v0.4.4

func (discord *Discord) CreateEmoji(name string, image image.Image) *Emoji

CreateEmoji creates a new emoji on Discord

func (*Discord) CreateEvent added in v0.2.0

func (discord *Discord) CreateEvent(event common.Event) error

CreateEvent creates a new discord event

func (*Discord) CreateMessageComponent added in v0.3.0

func (discord *Discord) CreateMessageComponent(channelID string, content string, components []Component) string

CreateMessageComponent creates a discord component

func (*Discord) DeleteChannel

func (discord *Discord) DeleteChannel(channel *core.Channel) (bool, error)

DeleteChannel deletes a channel

func (*Discord) GetAvatar added in v0.4.4

func (discord *Discord) GetAvatar(user common.User) image.Image

GetAvatar returns the users Avatar as a image.Image

func (*Discord) GetAvatarBase64 added in v0.4.4

func (discord *Discord) GetAvatarBase64(user common.User) string

GetAvatarBase64 returns the base64 encoded avatar of a user

func (*Discord) GetEmoji added in v0.4.4

func (discord *Discord) GetEmoji(name string) *Emoji

GetEmoji returns a emoji that exists on Discord

func (*Discord) GetRole added in v0.3.0

func (discord *Discord) GetRole(name string) *Role

GetRole returns a role that exists on Discord

func (*Discord) GetRoleAndCreate added in v0.3.0

func (discord *Discord) GetRoleAndCreate(name string) *Role

GetRoleAndCreate gets a role and creates it if it doesn't exist

func (*Discord) GetVerifiedChannel

func (discord *Discord) GetVerifiedChannel(channel *core.Channel) *core.Channel

GetVerifiedChannel looks up channel data and returns a verified objec

func (*Discord) HasAtLeastOneRole added in v0.3.0

func (discord *Discord) HasAtLeastOneRole(user common.User, roles []*Role) bool

HasAtLeastOneRole returns true when a user has at one role from a given array

func (*Discord) HasRole added in v0.3.0

func (discord *Discord) HasRole(user common.User, role *Role) bool

HasRole returns true when a user has a given role

func (*Discord) MoveChannelToCategory

func (discord *Discord) MoveChannelToCategory(channel *core.Channel, categoryID string) error

MoveChannelToCategory places a channel in a given category

func (*Discord) NewActionRow added in v0.3.0

func (discord *Discord) NewActionRow() *ActionRow

NewActionRow creates an empty action row component

func (*Discord) NewActionRowWith added in v0.3.0

func (discord *Discord) NewActionRowWith(comp []Component) *ActionRow

NewActionRowWith creates an action row with a set of components

func (*Discord) NewButton added in v0.3.0

func (discord *Discord) NewButton(id string, label string) *Button

NewButton creates a new button component

func (*Discord) NewButtonWithEmoji added in v0.4.4

func (discord *Discord) NewButtonWithEmoji(id string, label string, emoji *Emoji) *Button

NewButtonWithEmoji creates a new button component with a emoji

func (*Discord) NewChannelFromID

func (discord *Discord) NewChannelFromID(ID string) *core.Channel

NewChannelFromID creates a channel from a given ID

func (*Discord) NewChannelFromName

func (discord *Discord) NewChannelFromName(channel_name string) (*core.Channel, error)

NewChannelFromName creates a channel object with its name

func (*Discord) OnEventCreate

func (discord *Discord) OnEventCreate(handler func(*Discord, common.Event))

OnEventCreate registers a handler when a guild scheduled event is created

func (*Discord) OnEventDelete

func (discord *Discord) OnEventDelete(handler func(*Discord, common.Event))

OnEventDelete registers a handler when a guild scheduled event is deleted

func (*Discord) OnEventUpdate

func (discord *Discord) OnEventUpdate(handler func(*Discord, common.Event))

OnEventUpdate registers a handler when a guild scheduled event is updated

func (*Discord) OnMessageRecieved added in v0.4.2

func (discord *Discord) OnMessageRecieved(handler func(*Discord, string, common.User, string))

OnMessageRecieved registers a handler when a message is recieved

func (*Discord) OnReady

func (discord *Discord) OnReady(handler func(*Discord))

OnReady registers a handler for when the Discord session is ready

func (*Discord) RefreshWebhookState added in v0.4.4

func (discord *Discord) RefreshWebhookState()

RefreshWebhookState refreshes the state of all webhooks

func (*Discord) RegisterCommand added in v0.4.2

func (discord *Discord) RegisterCommand(name string, config common.ChatCommandConfiguration, handler func(common.User, map[string]any) string)

RegisterCommand creates an new command that can be used to interact with bird bot

func (*Discord) Run

func (discord *Discord) Run() error

Run opens the Discod session until exit

func (*Discord) SendMessage

func (discord *Discord) SendMessage(channel *core.Channel, message string) error

SendMessage sends a message to a given channel

func (*Discord) SetStatus added in v0.2.0

func (discord *Discord) SetStatus(status string)

func (*Discord) Stop

func (discord *Discord) Stop()

Stop tells the Discord session to exit

func (*Discord) UnassignRole added in v0.3.0

func (discord *Discord) UnassignRole(user common.User, role *Role) error

UnassignRole removes a role from a user

func (*Discord) UpdateMessageComponent added in v0.4.4

func (discord *Discord) UpdateMessageComponent(messageID string, channelID string, content string, components []Component) string

UpdateMessageComponent updates a discord component

func (*Discord) WebhookSendMessage added in v0.4.2

func (discord *Discord) WebhookSendMessage(channel *core.Channel, displayName string, message string)

WebhookSendMessage sends a message to a channel using a webhook

type Emoji added in v0.4.4

type Emoji struct {
	ID string

	Name  string
	Roles []string
	// contains filtered or unexported fields
}

func (*Emoji) Save added in v0.4.4

func (emoji *Emoji) Save()

Save updates the emoji on Discord

type Role added in v0.3.0

type Role struct {
	ID string

	Name  string
	Color color.Color
	// contains filtered or unexported fields
}

func (*Role) Save added in v0.3.0

func (role *Role) Save()

Save updates the role on Discord

Jump to

Keyboard shortcuts

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