disgo

package module
v0.0.0-...-625dfb0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

disgo : a discordgo helper library

Overview GoDoc Go Report Card Sourcegraph

disgo is a small discordgo helper library providing useful helper functions.

Also included is a commander library for an easy way to implement commands.

Install

go get gitlab.com/paars/discord/disgo

Contributing

Guidelines

Contributors

Sorted alphabetically

Author

By CKing / Kura, @kura@niu.moe

License

Apache 2.0

Documentation

Index

Constants

View Source
const (
	PermissionCreateInstantInvite Permission = 0x00000001
	PermissionKickMembers                    = 0x00000002
	PermissionBanMembers                     = 0x00000004
	PermissionAdministrator                  = 0x00000008
	PermissionManageChannels                 = 0x00000010
	PermissionManageGuild                    = 0x00000020
	PermissionAddReactions                   = 0x00000040
	PermissionViewAuditLog                   = 0x00000080
	PermissionViewChannel                    = 0x00000400
	PermissionSendMessages                   = 0x00000800
	PermissionSendTTSMessages                = 0x00001000
	PermissionManageMessages                 = 0x00002000
	PermissionEmbedLinks                     = 0x00004000
	PermissionAttachFiles                    = 0x00008000
	PermissionReadMessageHistory             = 0x00010000
	PermissionMentionEveryone                = 0x00020000
	PermissionUseExternalEmojis              = 0x00040000
	PermissionConnect                        = 0x00100000
	PermissionSpeak                          = 0x00200000
	PermissionMuteMembers                    = 0x00400000
	PermissionDeafenMembers                  = 0x00800000
	PermissionMoveMembers                    = 0x01000000
	PermissionUseVAD                         = 0x02000000
	PermissionChangeNickname                 = 0x04000000
	PermissionManageNicknames                = 0x08000000
	PermissionManageRoles                    = 0x10000000
	PermissionManageWebhooks                 = 0x20000000
	PermissionManageEmojis                   = 0x40000000
)

Variables

This section is empty.

Functions

func Channel

func Channel(c *discordgo.Channel) string

func EscapeEveryoneMention

func EscapeEveryoneMention(in string) string

func GetAllGuildMembers

func GetAllGuildMembers(session *discordgo.Session, guildID string) ([]*discordgo.Member, error)

func GetRole

func GetRole(rID string, roles []*discordgo.Role) *discordgo.Role

func GetRoleByName

func GetRoleByName(roles []*discordgo.Role, name string) *discordgo.Role

func GetUser

func GetUser(uID string, users []*discordgo.User) *discordgo.User

func Guild

func Guild(g *discordgo.Guild) string

func HasPermission

func HasPermission(requestedPermission Permission, flags int) bool

func HasRole

func HasRole(member *discordgo.Member, roleID string) bool

func HasRoleByName

func HasRoleByName(member *discordgo.Member, roles []*discordgo.Role, name string) bool

func IsChannelAbove

func IsChannelAbove(a, b *discordgo.Channel) bool

func IsMemberAllowed

func IsMemberAllowed(s *discordgo.Session, u *discordgo.User, g *discordgo.Guild, perm Permission) bool

TODO: channel specific overrides

func IsRoleAbove

func IsRoleAbove(a, b *discordgo.Role) bool

func Mention

func Mention(u *discordgo.User) string

func NewEmbedField

func NewEmbedField(key string, value interface{}) *discordgo.MessageEmbedField

func NewEmbedMessage

func NewEmbedMessage(embed *discordgo.MessageEmbed) []*discordgo.MessageSend

func NewInlineEmbedField

func NewInlineEmbedField(key string, value interface{}) *discordgo.MessageEmbedField

func QuoteMarkdown

func QuoteMarkdown(msg string) string

func RuneByIndex

func RuneByIndex(s string, runePos int) (rune, int)

RuneByIndex returns the string index from the rune position Panics if utf8.RuneCountInString(s) <= runeIndex or runePos < 0

func SplitSendMessage

func SplitSendMessage(message string) []*discordgo.MessageSend

SplitSendMessage is a helper for sending potentially long messages If the message is longer than 2k characters it will split at Last newline before 2k or last whitespace before 2k or if that fails (no whitespace) just split at 2k

func SplitSendMessagePS

func SplitSendMessagePS(message string, prefix, suffix string, prefixStart, suffixEnd bool) []*discordgo.MessageSend

SplitSendMessagePS is a helper for sending potentially long messages If the message is longer than 2k characters it will split at Last newline before 2k or last whitespace before 2k or if that fails (no whitespace) just split at 2k Prefix is added to the start of each message sent (usefull for codeblocks), Prefix is not not added to the first one if prefixStart is false Suffix is added to the end of each message, and not the last message if suffixend is false Cancel the context to stop this process

func StrSplit

func StrSplit(s string, runeCount int) (split, rest string)

StrSplit will split "s" before runecount at last possible newline, whitespace or just at "runecount" if there is no whitespace If the runecount in "s" is less than "runeCount" then "last" will be zero

func User

func User(u *discordgo.User) string

Types

type Channels

type Channels []*discordgo.Channel

func (Channels) Len

func (r Channels) Len() int

func (Channels) Less

func (r Channels) Less(i, j int) bool

func (Channels) Swap

func (r Channels) Swap(i, j int)

type ManagedMessage

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

func NewManagedMessage

func NewManagedMessage(s *discordgo.Session, chID string, color int, headline string) (m *ManagedMessage, err error)

func (*ManagedMessage) UpdateChannel

func (m *ManagedMessage) UpdateChannel(channel string) (err error)

func (*ManagedMessage) UpdateMessage

func (m *ManagedMessage) UpdateMessage(embed *discordgo.MessageEmbed) (err error)

type Permission

type Permission int

type Roles

type Roles []*discordgo.Role

func (Roles) Len

func (r Roles) Len() int

func (Roles) Less

func (r Roles) Less(i, j int) bool

func (Roles) Swap

func (r Roles) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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