permcalc

package
v2.3.4+incompatible Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: GPL-3.0 Imports: 2 Imported by: 0

README

PermCalc

This is a sub-package of DiscordConsole you can use in your own applications!
It's a simple Discord permission calculator.

It's simple to use:

perm, err := permcalc.Show()

perm is the permission as an integer. For example 8 for admin.
err is any error encountered during the process.

You can also pre-set permissions...

pm := permcalc.PermCalc{
	Perm: 8,
}
err := pm.Show()
perm := pm.Perm // Updated by Show()

... or even make it read-only!

pm := permcalc.PermCalc{
	ReadOnly: true,
}
err := pm.Show()

Documentation

Index

Constants

View Source
const (
	PermCreateInstantInvite = 1 << iota
	PermKickMembers
	PermBanMembers
	PermAdministrator
	PermManageChannels
	PermManageServer
	PermAddReactions
	PermViewAuditLogs
)

First few permission constants (All permission constants are from discordgo)

View Source
const (
	PermChangeNickname = 1 << (iota + 26)
	PermManageNicknames
	PermManageRoles
	PermManageWebhooks
	PermManageEmojis
)

Second batch of permission constants

View Source
const (
	PermReadMessages = 1 << (iota + 10)
	PermSendMessages
	PermSendTTSMessages
	PermManageMessages
	PermEmbedLinks
	PermAttachFiles
	PermReadMessageHistory
	PermMentionEveryone
	PermUseExternalEmojis
)

Third batch of permission constants

View Source
const (
	PermConnect = 1 << (iota + 20)
	PermSpeak
	PermMuteMembers
	PermDeafenMembers
	PermMoveMembers
	PermUseVoiceActivity
)

Last few permission constants

Variables

View Source
var ErrAlreadyRunning = errors.New("permcalc prompt already running")

ErrAlreadyRunning is thrown when you attempt to show a prompt when there already is one displayed.

PermOrder is all permissions, sorted by order.

View Source
var PermStrings = map[int]string{

	PermAdministrator:       "Administrator",
	PermViewAuditLogs:       "View Audit Logs",
	PermManageRoles:         "Manage Roles",
	PermKickMembers:         "Kick Members",
	PermCreateInstantInvite: "Create Instant Invite",
	PermManageNicknames:     "Manage Nicknames",
	PermManageWebhooks:      "Manage Webhooks",

	PermManageServer:   "Manage Server",
	PermManageChannels: "Manage Channels",
	PermBanMembers:     "Ban Members",
	PermChangeNickname: "Change Nickname",
	PermManageEmojis:   "Manage Emojis",

	PermReadMessages:       "Read Messages",
	PermSendTTSMessages:    "Send TTS Messages",
	PermEmbedLinks:         "Embed Links",
	PermReadMessageHistory: "Read Message History",
	PermUseExternalEmojis:  "Use External Emojis",

	PermSendMessages:    "Send Messages",
	PermManageMessages:  "Manage Messages",
	PermAttachFiles:     "Attach Files",
	PermMentionEveryone: "Mention Everyone",
	PermAddReactions:    "Add Reactions",

	PermConnect:     "Connect",
	PermMuteMembers: "Mute Members",
	PermMoveMembers: "Move Members",

	PermSpeak:            "Speak",
	PermDeafenMembers:    "Deafen Members",
	PermUseVoiceActivity: "Use Voice Activity",
}

PermStrings the name for all permissions.

Functions

func PromptPerm

func PromptPerm() (int, error)

PromptPerm shows the permission calculator and returns whatever the user checked.

Types

type PermCalc

type PermCalc struct {
	Perm     int
	ReadOnly bool
}

PermCalc is a permission calculator object. It stores data and similar

func (*PermCalc) Show

func (pm *PermCalc) Show() error

Show shows the permission calculator according to the PermCalc object.

Jump to

Keyboard shortcuts

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