dgohelper

package module
v0.0.0-...-1c02d25 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

discordgohelper

Helper functions for DiscordGo to make coding less work.

Installing
go get github.com/JurrijnP/discordgohelper
Usage

Import the package into your project.

import "github.com/JurrijnP/discordgohelper"

Note: The name during usage is dgohelper.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentWithMentionsRemoved

func ContentWithMentionsRemoved(m *discordgo.Message) (content string)

ContentWithMentionsRemoved returns the content with all user mentions removed. m : discordgo.Message struct.

func GetChannelMention

func GetChannelMention(s *discordgo.Session, msg, channelID string) *discordgo.Channel

GetChannelMention searches for a specific channel mention in the message content, returns discordgo.Channel if channel is found. s : discordgo.Session struct. channelID : The ChannelID of the channel you want. msg : content of the message.

func GetChannelMentions

func GetChannelMentions(s *discordgo.Session, msg string) (cm []*discordgo.Channel)

GetChannelMentions searches for all channel mention in the message content, returns slice of discordgo.Channel for channels found. s : discordgo.Session struct. msg : content of the message.

func GetHighestRole

func GetHighestRole(guildroles []*discordgo.Role, uroles []string) (hp int)

GetHighestRole returns an integer based on the highest role of a user. guildroles : Slice of the roles in a guild. uroles : Slice of IDs of the roles from a user.

func GetMembersFromContent

func GetMembersFromContent(s *discordgo.Session, guildID, content string) (ms []*discordgo.Member)

GetMembersFromContent searches for all user snowflakes in the message content, returns slice of discordgo.Member. s : discordgo.Session struct. guildid : The guildID. msg : content of the message.

func GetPermissionInt

func GetPermissionInt(arg string) int

GetPermissionInt returns an integer from a permission based on a string. arg : The a permission name.

func GetPermissionIntAll

func GetPermissionIntAll(perms []string) (apermissions int)

GetPermissionIntAll returns an integer consisting of (multiple) permissions based on a slice of strings. perms : Slice of strings of permission names.

func GetPermissionSlice

func GetPermissionSlice(perms, mode int) (apermissions []string)

GetPermissionSlice returns a slice of strings based on an integer consisting of (multiple) permissions. perms : Slice of strings of permission names. mode : Determines the string to return in some cases.

(e.g. Manage Roles <> Manage Permissions)

func GetPermissionString

func GetPermissionString(perm, mode int) string

GetPermissionString returns a name from a permission based on a integer. perm : Integer of the permission. mode : Determines the string to return in some cases.

(e.g. Manage Roles <> Manage Permissions)

func GetRoleByID

func GetRoleByID(guildroles []*discordgo.Role, roleID string) (r *discordgo.Role)

GetRoleByID returns a discordgo.Role struct based on an id, returns nil if not found. guildroles : Slice of the roles in a guild. roleID : ID of the role you want.

func GetRoleByName

func GetRoleByName(guildroles []*discordgo.Role, rolename string) (r *discordgo.Role)

GetRoleByName returns a discordgo.Role struct based on a name, returns nil if not found. guildroles : Slice of the roles in a guild. rolename : Name of the role you want.

func GetRoleByPosition

func GetRoleByPosition(guildroles []*discordgo.Role, position int) (r *discordgo.Role)

GetRoleByName returns a discordgo.Role struct based on a position, returns nil if not found. guildroles : Slice of the roles in a guild. position : Position of the role you want to be returned.

func GetRoleByProperty

func GetRoleByProperty(guildRoles []*discordgo.Role, property RoleProperty, value interface{}) (r *discordgo.Role)

func GetUserIDsFromMessage

func GetUserIDsFromMessage(s *discordgo.Session, m *discordgo.Message, guildID string) (u []string)

func GetUsersFromMessage

func GetUsersFromMessage(s *discordgo.Session, m *discordgo.Message, guildID string) (u []*discordgo.User)

func MemberHasPermission

func MemberHasPermission(guildRoles []*discordgo.Role, member *discordgo.Member, perm int) bool

MemberHasPermission checks if a member has the permission(s) from their roles. guildRoles : Slice of guild roles. member : discordgo.Member struct of the member. perm : Permission(s) you want to check.

func MemberHasRole

func MemberHasRole(userRoles []string, roleID string) bool

MemberHasRole checks if a user has a role. userRoles : Slice of role IDs. roleID : ID of the role you want to check.

Types

type RoleProperty

type RoleProperty int
const (
	RolePropertyName RoleProperty = 1 << iota
	RolePropertyID
	RolePropertyPosition
)

Jump to

Keyboard shortcuts

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