discord

package
v0.0.0-...-ab145b9 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 17 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessageLink   = errors.New("invalid message link")
	ErrMessageOnWrongServer = errors.New("message on wrong server")
)
View Source
var (
	ErrNoDMChannel = errors.New("no DMs channel found, DMs might be disabled")
)

Functions

func CalculateEmbedLength

func CalculateEmbedLength(embed *discordgo.MessageEmbed) int

CalculateEmbedLength calculates the total length of embed

func CheckBlockDMChannel

func CheckBlockDMChannel(redisClient *redis.Client, session *Session, userID string, err error) error

func ColorCodeToHex

func ColorCodeToHex(colour int) (hex string)

ColorCodeToHex converts a Discord Color Code into a hex string

func DMChannel

func DMChannel(
	redisClient *redis.Client,
	session *Session,
	userID string,
) (string, error)

func Delete

func Delete(
	redis *redis.Client,
	session *Session,
	channelID string,
	messageID string,
	dm bool,
) error

func DeleteBulk

func DeleteBulk(
	redis *redis.Client,
	session *Session,
	channelID string,
	messageIDs []string,
	dm bool,
) error

func DeleteSmart

func DeleteSmart(
	redis *redis.Client,
	session *Session,
	channelID string,
	messages []*discordgo.Message,
	dm bool,
) error

func EditComplexWithVars

func EditComplexWithVars(
	redis *redis.Client,
	session *Session,
	localizations []interfaces.Localization,
	edit *discordgo.MessageEdit,
	dm bool,
	values ...interface{},
) (*discordgo.Message, error)

func EscapeDiscordLax

func EscapeDiscordLax(text string) (output string)

EscapeDiscordLax escapes @ everyone, and @ here

func EscapeDiscordStrict

func EscapeDiscordStrict(text string) string

EscapeDiscordStrict escapes all discord formatting options

func FindMessage

func FindMessage(
	state *state.State,
	discord *Session,
	channelID string,
	messageID string,
) (
	*discordgo.Message,
	error,
)

func HexToColorCode

func HexToColorCode(hex string) int

ColorCodeToHex converts a hex string into a Discord Color Code

func Invite

func Invite(
	redisClient *redis.Client,
	session *Session,
	inviteCode string,
) (*discordgo.Invite, error)
func LookupMessageLink(state *state.State, discord *Session, link string) (*discordgo.Message, error)

func MessageCodeFromMessage

func MessageCodeFromMessage(message *discordgo.Message) string

func MessageCodeToMessage

func MessageCodeToMessage(embedText string) *discordgo.MessageSend

func Pagify

func Pagify(text string) []string

Pagify splits the given text into pages

func React

func React(
	redis *redis.Client,
	session *Session,
	channelID string,
	messageID string,
	dm bool,
	emojiID string, emojiIDs ...string,
) error

func RemoveReact

func RemoveReact(
	redis *redis.Client,
	session *Session,
	channelID string,
	messageID string,
	userID string,
	dm bool,
	emojiID string,
) error

func SendComplexWithVars

func SendComplexWithVars(
	session *Session,
	localizations []interfaces.Localization,
	channelID string,
	send *discordgo.MessageSend,
	values ...interface{},
) ([]*discordgo.Message, error)

SendComplexWithVars sends a message to a given channelID using a given discord session it performs various on the actions: - pagifies the message content - trims the embed - escapes @ everyone, and @ here

func SetAPIBase

func SetAPIBase(apiBase string)

func TimeFromID

func TimeFromID(id string) (*time.Time, error)

TimeFromID extracts a time from a Snowflake ID, used at the Discord API

func Timestamp

func Timestamp(when time.Time) string

func TranslateEmbed

func TranslateEmbed(
	localizations []interfaces.Localization,
	embed *discordgo.MessageEmbed,
	values ...interface{},
) *discordgo.MessageEmbed

TODO: replace emoji

func TranslateMessageEdit

func TranslateMessageEdit(
	localizations []interfaces.Localization,
	edit *discordgo.MessageEdit,
	values ...interface{},
) *discordgo.MessageEdit

func TranslateMessageSend

func TranslateMessageSend(
	localizations []interfaces.Localization,
	send *discordgo.MessageSend,
	values ...interface{},
) *discordgo.MessageSend

func TrimEmbed

func TrimEmbed(embed *discordgo.MessageEmbed) *discordgo.MessageEmbed

TrimEmbed enforces Embed Limits to the given Embed Source: https://discordapp.com/developers/docs/resources/channel#embed-limits

func UserHasPermission

func UserHasPermission(
	state interfaces.State, userID, channelID string, firstPermission int64, permissions ...int64,
) bool

UserHasPermission returns true if the User has all of th egiven permissions in the given channel

func UserHasPermissionOr

func UserHasPermissionOr(
	state *state.State, userID, channelID string, firstPermission int64, permissions ...int64,
) bool

UserHasPermissionOr returns true if the User has any of the given permissions in the given channel

Types

type Session

type Session struct {
	Client *discordgo.Session
	BotID  string
}

func NewSession

func NewSession(tokens map[string]string, botID string) (*Session, error)

NewSession creates a new DiscordGo Client for the given BotID from the tokens map (key: BotID, value: token)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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