util

package
v0.0.0-...-2edfbda Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOLD              = "**"
	CODEBLOCK         = "```"
	CODESTRING        = "`"
	CODESTRING_DOUBLE = "``"
	ESCAPE            = "\\"
	ITALICS           = "_"
	SPOILER           = "||"
	STRIKE            = "~~"
	UNDERLINE         = "__"
)
View Source
const (
	Green    = 0x00ff00
	Red      = 0xff0000
	Yellow   = 0xffff00
	Blue     = 0x0000ff
	Purple   = 0x7d00ff
	Pink     = 0xff00ff
	Magenta  = 0xff007d
	DDark    = 0x2b2d31
	DBlurple = 0x5865f2
)
View Source
const DEFAULT_CONTENT = `` /* 416-byte string literal not displayed */

Variables

View Source
var ComponentInteractionType = map[discord.ComponentType]string{
	discord.ComponentTypeActionRow:             `action_row`,
	discord.ComponentTypeButton:                `button`,
	discord.ComponentTypeStringSelectMenu:      `string_select_menu`,
	discord.ComponentTypeTextInput:             `text_input`,
	discord.ComponentTypeUserSelectMenu:        `user_select_menu`,
	discord.ComponentTypeRoleSelectMenu:        `role_select_menu`,
	discord.ComponentTypeMentionableSelectMenu: `mentionable_select_menu`,
	discord.ComponentTypeChannelSelectMenu:     `channel_select_menu`,
}

Debug purposes

Debug purposes

Functions

func WriteConfig

func WriteConfig(filename string) error

Types

type AutocompleteCtx

type AutocompleteCtx struct {
	events.AutocompleteInteractionCreate
	Log *log.Logger
}

type AutocompleteHandle

type AutocompleteHandle func(ctx *AutocompleteCtx) error

return the result?

type ComponentCtx

type ComponentCtx struct {
	events.ComponentInteractionCreate
	Log *log.Logger
}

type ComponentHandle

type ComponentHandle func(ctx *ComponentCtx) error

type Config

type Config struct {
	Bot struct {
		Token          string       `validate:"required"`
		GuildId        snowflake.ID `fig:"guild" default:"0"`
		SetupCommands  bool         `fig:"setup-commands"`
		GlobalCommands bool         `fig:"global-commands"`
		MobileOs       bool         `fig:"use-mobile-os"`
		DebugLog       bool         `fig:"debug-log"`
	}
	PresenceUpdater struct {
		Enabled   bool          `fig:"enabled"`
		Delay     time.Duration `fig:"delay" default:"10s"`
		Presences []Presence
	} `fig:"presence-updater"`
}

func LoadConfig

func LoadConfig(l *log.Logger, filename string, env string) (config Config)

type JAutocomplete

type JAutocomplete struct{}

type JCommand

type JCommand interface {
	discord.ApplicationCommandCreate
	Init(JHRegister)
	Run(ctx *JContext) error
	Error(ctx *JContext, err error)
}

type JComponent

type JComponent struct{}

type JContext

type JContext struct {
	events.ApplicationCommandInteractionCreate
	Log *log.Logger
}

func (*JContext) CreateFollowupMessage

func (e *JContext) CreateFollowupMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)

func (*JContext) DeleteFollowupMessage

func (e *JContext) DeleteFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error

func (*JContext) DeleteInteractionResponse

func (e *JContext) DeleteInteractionResponse(opts ...rest.RequestOpt) error

func (*JContext) GetFollowupMessage

func (e *JContext) GetFollowupMessage(messageID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)

func (*JContext) GetInteractionResponse

func (e *JContext) GetInteractionResponse(opts ...rest.RequestOpt) (*discord.Message, error)

func (*JContext) UpdateFollowupMessage

func (e *JContext) UpdateFollowupMessage(messageID snowflake.ID, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)

func (*JContext) UpdateInteractionResponse

func (e *JContext) UpdateInteractionResponse(messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)

type JHRegister

type JHRegister interface {
	Component(customID string, handle ComponentHandle)
	Modal(customID string, handle ModalHandle)
	Autocomplete(p string, handle AutocompleteHandle)
}

type JIHandler

type JIHandler struct {
	Log    *log.Logger
	Config Config
	// contains filtered or unexported fields
}

func NewIHandler

func NewIHandler() *JIHandler

func (*JIHandler) Autocomplete

func (h *JIHandler) Autocomplete(p string, handle AutocompleteHandle)

func (*JIHandler) Component

func (h *JIHandler) Component(customID string, handle ComponentHandle)

func (*JIHandler) Modal

func (h *JIHandler) Modal(customID string, handle ModalHandle)

func (*JIHandler) OnEvent

func (h *JIHandler) OnEvent(event bot.Event)

func (*JIHandler) SetupCommands

func (h *JIHandler) SetupCommands(client bot.Client, commands []JCommand)

func (*JIHandler) WithConfig

func (h *JIHandler) WithConfig(c Config) *JIHandler

func (*JIHandler) WithLogger

func (h *JIHandler) WithLogger(l *log.Logger) *JIHandler

type JModal

type JModal struct{}

type ModalCtx

type ModalCtx struct {
	events.ModalSubmitInteractionCreate
	Log *log.Logger
}

type ModalHandle

type ModalHandle func(ctx *ModalCtx) error

type PUpdater

type PUpdater struct {
	Config Config
	Log    *log.Logger
	// contains filtered or unexported fields
}

func (*PUpdater) Next

func (pu *PUpdater) Next() (data *gateway.MessageDataPresenceUpdate)

func (*PUpdater) Setup

func (pu *PUpdater) Setup(gc *gateway.Config)

func (*PUpdater) StartUpdater

func (pu *PUpdater) StartUpdater(c bot.Client)

type Presence

type Presence struct {
	Status discord.OnlineStatus
	Name   string
	Type   string
	URL    string
	State  string
}

Jump to

Keyboard shortcuts

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