utils

package
v0.0.0-...-f692fd6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Flags = map[string]string{
	"EN": ":flag_us:",
	"PT": ":flag_br:",
	"ES": ":flag_es:",
	"FR": ":flag_fr:",
}

Flags maps language codes to a emoji strings representing the flags of the countries

Functions

func AskMember

func AskMember(s *discordgo.Session, member string, message *discordgo.MessageEmbed) error

AskMember function is used to send a private message to a guild member

func CheckPermissions

func CheckPermissions(s *discordgo.Session, channelID string, userID string, permission int64) bool

CheckPermissions checks the permission for a User in a chennel

Inputs:

s *discordgo.Session : the Bot doing the check
channelID string : the ID of the channel to check
userID string : the ID of the user to check
permission int : the permission Integer ( ex discordgo.PermissionVoiceMoveMembers)

Outputs: True/False

func DetectPowerups

func DetectPowerups(guildID string, servants []*discordgo.Session, rchan chan []*discordgo.Session)

DetectPowerups will retrieve all bots logged in to the discord server with the provided ID.

This function in ment to be used cuncurently.

Inputs:

guildID string : the Discord Guild ID
sseravnts []*discordgo.Session : all logged in Bot Sessions
rchan chan []*discordgo.Session : the return channel

Output is sent in the rchan channel

func FormatNumberWithSeparators

func FormatNumberWithSeparators(n int64) string

FormatNumberWithSeparators takes a positive number and ads commas in the appropriate separator places

func GetChannel

func GetChannel(channs []*discordgo.Channel, channelNameOrID string) (string, error)

GetChannel retrieves the channel ID by the name or position ID

Inputs:

channs []*discordgo.Channel : list of all channels in the server
channelNameOrID string : the channel name or position integer

Outputs: channel ID string, error

func GetUserCurrentChannel

func GetUserCurrentChannel(s *discordgo.Session, userID string, guild *discordgo.Guild) string

GetUserCurrentChannel find the voice channel id for a connected user. Returns "" in case the user cant be found.

Inputs:

s *discordgo.Session : a bot session in the guild
userID : the ID of the user
guild *discordgo.Guild : the guild where to operate this function

Outputs: channel ID string, error

func HaveIAskedMember

func HaveIAskedMember(s *discordgo.Session, member string) bool

HaveIAskedMember function is used to send a private message to a guild member

This function will return false in case of error and if the user received any message from a bot. It checks the 10 last messages in the chat.

func ListChannelsForHelpMessage

func ListChannelsForHelpMessage(channels []*discordgo.Channel) string

ListChannelsForHelpMessage creates a message with the channels in a server

Inputs:

voiceChannels []*discordgo.Channel : list of all channels in the server (used to list the numbers)
prefix string: prefix used to call the bot (used to print in the message)

Outputs: message string

func SelectLang

func SelectLang(choice string) string

SelectLang selects a language code based on number or string code

Input:

choice string

Output:

language string

Types

type Message

type Message struct {
	Messages           map[string]map[string]string
	FormaterDirectives map[string]map[string]int
}

Message structure stores the messages and the amount of Formatting directives for each one of them ...

func (*Message) BotNoPermission

func (m *Message) BotNoPermission(lang string) *discordgo.MessageEmbed

BotNoPermission produces an error message for when the bot was denied permission on some action

func (*Message) CantFindChannel

func (m *Message) CantFindChannel(lang, insertions string) *discordgo.MessageEmbed

CantFindChannel produces an error message for when a channel cant be found

func (*Message) CantFindUser

func (m *Message) CantFindUser(lang, prefix, mension string) *discordgo.MessageEmbed

CantFindUser produces an error message for when a user cant be found

func (*Message) CantMoveSomeUsers

func (m *Message) CantMoveSomeUsers(lang string) *discordgo.MessageEmbed

CantMoveSomeUsers produces an error message for when some user cant be moved

func (*Message) GeneralHelp

func (m *Message) GeneralHelp(lang, prefix, mension string) *discordgo.MessageEmbed

GeneralHelp produces a message pointing to the help command

func (*Message) HelpMessage

func (m *Message) HelpMessage(lang, insertions string) *discordgo.MessageEmbed

HelpMessage produces a message with the existing commands for the bot

func (*Message) JustMoved

func (m *Message) JustMoved(lang, insertions string) *discordgo.MessageEmbed

JustMoved produces a message with the results of the move action

func (*Message) LangSet

func (m *Message) LangSet(lang string) *discordgo.MessageEmbed

LangSet produces the message reporting the new language set

func (*Message) LangSetupMessage

func (m *Message) LangSetupMessage(insertions string) *discordgo.MessageEmbed

LangSetupMessage produces the message for language setup

func (*Message) MoveHelper

func (m *Message) MoveHelper(lang, prefix, rooms string) *discordgo.MessageEmbed

MoveHelper produces a help message for the move command

func (*Message) NoPermissionsDestination

func (m *Message) NoPermissionsDestination(lang string) *discordgo.MessageEmbed

NoPermissionsDestination produces an error message for when the user has no permission on the destination channel

func (*Message) NoPermissionsOrigin

func (m *Message) NoPermissionsOrigin(lang string) *discordgo.MessageEmbed

NoPermissionsOrigin produces an error message for when the user has no permission on the origin channel

func (*Message) NotInGuild

func (m *Message) NotInGuild(lang, insertions string) *discordgo.MessageEmbed

NotInGuild produces an error message was sent outside a guild

func (*Message) SorryBut

func (m *Message) SorryBut(lang, insertions string) *discordgo.MessageEmbed

SorryBut produces a error message for unnatural situations

func (*Message) SummonHelp

func (m *Message) SummonHelp(lang, prefix, rooms string) *discordgo.MessageEmbed

SummonHelp produces a help message dor the summon command

func (*Message) WelcomeAndLang

func (m *Message) WelcomeAndLang(insertions string) *discordgo.MessageEmbed

WelcomeAndLang function produces the Welcome message

Jump to

Keyboard shortcuts

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