cmd

package
v0.0.0-...-f587f52 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Permissions     = []Permission{PermUndefined, PermChannels, PermPermissions, PermModerate, PermOperator}
	PermissionCache = permissionCache{}
)
View Source
var (
	ImageExtensions = []string{".jpg", ".jpeg", ".png", ".gif", ".gifv"}
)
View Source
var (
	UrlRegex = regexp.MustCompile(`https?://(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}([.:])[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)`)
)

Functions

func CommandHandler

func CommandHandler(e *gateway.MessageCreateEvent)

CommandHandler will parse commands and run the appropriate command func

func CommandHandlerWithCommand

func CommandHandlerWithCommand(e *gateway.MessageCreateEvent, cmdName string, cmdArgs []string)

func CreateEmbedAuthor

func CreateEmbedAuthor(member discord.Member) *discord.EmbedAuthor

func CreateEmbedAuthorUser

func CreateEmbedAuthorUser(user discord.User) *discord.EmbedAuthor
func CreateMessageLink(guild int64, message *discord.Message, jump, dm bool) string

func CreateMessageLinkInt64

func CreateMessageLinkInt64(guild, message, channel int64, jump, dm bool) string

func FileExtMatches

func FileExtMatches(s []string, file string) bool

func GetEmbedAttachmentAndContent

func GetEmbedAttachmentAndContent(msg discord.Message) (string, *discord.EmbedImage)

func GivePermission

func GivePermission(c bot.Command, pStr string, id int64) error

GivePermission will return nil if the permission was successfully given to the user with a matching id

func HasAdminCached

func HasAdminCached(id discord.GuildID, memberRoles []discord.RoleID, user discord.User) bool

func HasPermission

func HasPermission(c bot.Command, p Permission) *bot.Error

HasPermission will return if the author of a command has said permission

func MakeEmbed

func MakeEmbed(title string, description string, color discord.Color) discord.Embed

func ParseAllArgs

func ParseAllArgs(a []string) (string, *bot.Error)

ParseAllArgs will return the combined existing args

func ParseBoolArg

func ParseBoolArg(a []string, pos int) (bool, *bot.Error)

ParseBoolArg will return a bool (True / true / 1), or false with an error

func ParseChannelArg

func ParseChannelArg(a []string, pos int) (int64, *bot.Error)

ParseChannelArg will return the ID of a mentioned channel, or -1 and an error

func ParseChannelSliceArg

func ParseChannelSliceArg(a []string, pos1 int, pos2 int) ([]int64, *bot.Error)

ParseChannelSliceArg will return the IDs of the mentioned channels, or nil and an error

func ParseDurationArg

func ParseDurationArg(a []string, pos int) (time.Duration, *bot.Error)

func ParseEmojiArg

func ParseEmojiArg(a []string, pos int, allowOmit bool) (*discord.APIEmoji, bool, *bot.Error)

ParseEmojiArg will return a discord.APIEmoji and the animated status, or nil, false and an error

func ParseEmojiIdArg

func ParseEmojiIdArg(a []string, pos int) (int64, *bot.Error)

ParseEmojiIdArg will return an emoji ID, or -1 and an error

func ParseEmojiUrlArg

func ParseEmojiUrlArg(a []string, pos int) (int64, *bot.Error)

ParseEmojiUrlArg will return an emoji ID, or -1 and an error

func ParseInt64Arg

func ParseInt64Arg(a []string, pos int) (int64, *bot.Error)

ParseInt64Arg will return an int64 from s, or -1 and an error

func ParseInt64SliceArg

func ParseInt64SliceArg(a []string, pos1 int, pos2 int) ([]int64, *bot.Error)

ParseInt64SliceArg will return an []int64, or nil and an error

func ParseStringArg

func ParseStringArg(a []string, pos int, toLower bool) (string, *bot.Error)

ParseStringArg will return the selected string, or "" with an error

func ParseStringSliceArg

func ParseStringSliceArg(a []string, pos1 int, pos2 int) ([]string, *bot.Error)

ParseStringSliceArg will return the strings in a range, or a nil and an error

func ParseUrlArg

func ParseUrlArg(a []string, pos int) (string, *bot.Error)

ParseUrlArg will return a URL, or "" and an error

func ParseUserArg

func ParseUserArg(a []string, pos int) (int64, *bot.Error)

ParseUserArg will return the ID of a mentioned user, or -1 and an error

func ResponseHandler

func ResponseHandler(e *gateway.MessageCreateEvent)

ResponseHandler will find a global response from the config and send it, if found

func SendCustomEmbed

func SendCustomEmbed(c discord.ChannelID, e ...discord.Embed) (*discord.Message, error)

func SendCustomMessage

func SendCustomMessage(c discord.ChannelID, content string) (*discord.Message, error)

func SendDirectMessage

func SendDirectMessage(userID discord.UserID, contents string) (*discord.Message, error)

func SendDirectMessageEmbedSafe

func SendDirectMessageEmbedSafe(id discord.UserID, content string, embed *discord.Embed) (*discord.Message, error)

func SendEmbed

func SendEmbed(e *gateway.MessageCreateEvent, title, description string, color discord.Color) (*discord.Message, error)

func SendEmbedFooter

func SendEmbedFooter(e *gateway.MessageCreateEvent, title, description, footer string, color discord.Color) (*discord.Message, error)

func SendErrorEmbed

func SendErrorEmbed(c bot.Command, err error)

func SendExternalErrorEmbed

func SendExternalErrorEmbed(c discord.ChannelID, cmdName string, err error) (*discord.Message, error)

func SendMessage

func SendMessage(e *gateway.MessageCreateEvent, content string) (*discord.Message, error)

func SendMessageEmbedSafe

func SendMessageEmbedSafe(c discord.ChannelID, content string, embed *discord.Embed) (*discord.Message, error)

func UpdateMemberCache

func UpdateMemberCache(e *gateway.GuildMemberUpdateEvent)

UpdateMemberCache will forcibly update the member cache

func UserHasPermission

func UserHasPermission(c bot.Command, p Permission, id int64) bool

UserHasPermission will return if the user with id has said permission

Types

type Permission

type Permission int64
const (
	PermUndefined Permission = iota
	PermChannels
	PermPermissions
	PermModerate
	PermOperator // "operator" is a special permission, managed by bot.C.OperatorIDs
)

func GetPermission

func GetPermission(pStr string) Permission

GetPermission will return a valid Permission type from a string

func (Permission) String

func (p Permission) String() string

Jump to

Keyboard shortcuts

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