discord

package
v0.0.0-...-51943a4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHandlerTimeout = 120 * time.Second
View Source
const HandlerTimeout = 120 * time.Second

Variables

View Source
var DevConfig = Config{
	GuildID:             "1058090773582721214",
	QMRoleID:            "1058092621475614751",
	QMChannelID:         "1058092560926646282",
	HangingOutChannelID: "1058090774488678532",
	MoreEyesChannelID:   "1058092531688157266",
}
View Source
var EndpointOAuth2Session = discordgo.EndpointOAuth2 + "@me"
View Source
var ProdConfig = Config{
	GuildID:             "793599987694436374",
	QMRoleID:            "793618399322046515",
	QMChannelID:         "795780814846689321",
	HangingOutChannelID: "793599987694436377",
	MoreEyesChannelID:   "793607709022748683",
}

Functions

func ErrCode

func ErrCode(err error) int

func WrapHandler

func WrapHandler[Action any](
	main context.Context,
	name string,
	handle func(context.Context, Action) error,
) func(*discordgo.Session, Action)

Types

type Bot

type Bot interface {
	Register() (cmd *discordgo.ApplicationCommand, async bool)
	Handle(context.Context, *CommandInput) (string, error)
	HandleScheduledEvent(context.Context, *discordgo.GuildScheduledEventUpdate) error
}

type ChannelOrder

type ChannelOrder struct {
	ID       string
	Position int
}

type Client

type Client struct {
	Guild               *discordgo.Guild
	Application         *discordgo.Application
	QMChannel           *discordgo.Channel // for puzzle maintenance
	HangingOutChannel   *discordgo.Channel // for solves, to celebrate
	MoreEyesChannel     *discordgo.Channel // for verbose puzzle updates
	DefaultVoiceChannel *discordgo.Channel // for placeholder events
	QMRole              *discordgo.Role    // so QMs show up in the sidebar
	// contains filtered or unexported fields
}

func Connect

func Connect(ctx context.Context, prod bool, state *state.Client) *Client

func (*Client) ChannelSend

func (c *Client) ChannelSend(ch *discordgo.Channel, msg string) (string, error)

func (*Client) ChannelSendComponents

func (c *Client) ChannelSendComponents(ch *discordgo.Channel, msg string,
	components []discordgo.MessageComponent) (string, error)

func (*Client) ChannelSendRawID

func (c *Client) ChannelSendRawID(chID, msg string) error

func (*Client) CheckRateLimit

func (c *Client) CheckRateLimit(url string) *time.Time

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateCategory

func (c *Client) CreateCategory(name string, position int) (*discordgo.Channel, error)

func (*Client) CreateChannel

func (c *Client) CreateChannel(name string, category string, position int) (*discordgo.Channel, error)

func (*Client) CreateScheduledEvent

func (c *Client) CreateScheduledEvent(
	params *discordgo.GuildScheduledEventParams,
) (*discordgo.GuildScheduledEvent, error)

func (*Client) CreateUpdatePin

func (c *Client) CreateUpdatePin(chanID, header string, embed *discordgo.MessageEmbed) error

Set the pinned status message, by posting one or editing the existing one. No-op if the status was already set.

func (*Client) DeleteScheduledEvent

func (c *Client) DeleteScheduledEvent(event *discordgo.GuildScheduledEvent) error

func (*Client) GetChannel

func (c *Client) GetChannel(id string) (*discordgo.Channel, bool)

func (*Client) GetGuildMember

func (c *Client) GetGuildMember(user *discordgo.User) (*discordgo.Member, error)

func (*Client) GetMessage

func (c *Client) GetMessage(ch *discordgo.Channel, messageID string) (*discordgo.Message, error)

func (*Client) GetOAuth2Session

func (c *Client) GetOAuth2Session(ctx context.Context, token string) (*OAuth2Session, error)

func (*Client) GetScheduledEvent

func (c *Client) GetScheduledEvent(id string) (*discordgo.GuildScheduledEvent, error)

func (*Client) GetTopReaction

func (c *Client) GetTopReaction(channel *discordgo.Channel, messageID string) (string, error)

func (*Client) ListCategoriesByName

func (c *Client) ListCategoriesByName() map[string]*discordgo.Channel

func (*Client) ListChannelsByID

func (c *Client) ListChannelsByID() map[string]*discordgo.Channel

func (*Client) ListScheduledEvents

func (c *Client) ListScheduledEvents() (map[string]*discordgo.GuildScheduledEvent, error)

func (*Client) ListVoiceChannels

func (c *Client) ListVoiceChannels() map[string]string

func (*Client) MakeQM

func (c *Client) MakeQM(user *discordgo.User) error

func (*Client) RegisterBots

func (c *Client) RegisterBots(bots ...Bot)

func (*Client) SetChannelCategory

func (c *Client) SetChannelCategory(channel string, category string, position int) error

func (*Client) SetChannelName

func (c *Client) SetChannelName(chID, name string, position int) error

func (*Client) SortChannels

func (c *Client) SortChannels(order []ChannelOrder) error

func (*Client) UnMakeQM

func (c *Client) UnMakeQM(user *discordgo.User) error

func (*Client) UpdateStatus

func (c *Client) UpdateStatus(data discordgo.UpdateStatusData) error

type CommandInput

type CommandInput struct {
	IC         *discordgo.InteractionCreate
	User       *discordgo.User
	Command    string
	Subcommand string
	Options    map[string]*discordgo.ApplicationCommandInteractionDataOption
	// contains filtered or unexported fields
}

func (CommandInput) EditMessage

func (i CommandInput) EditMessage(msg string) error

type Config

type Config struct {
	GuildID             string
	QMRoleID            string
	QMChannelID         string
	HangingOutChannelID string
	MoreEyesChannelID   string
}

type OAuth2Session

type OAuth2Session struct {
	Application discordgo.Application `json:"application"`
	Expires     time.Time             `json:"expires"`
	Scopes      []string              `json:"scopes"`
	User        discordgo.User        `json:"user"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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