Documentation ¶
Index ¶
- Variables
- func Contains(arr []discordgo.Guild, id string) bool
- func DeferReply(sess *discordgo.Session, i *discordgo.Interaction) error
- func DeleteAllMessages(sess *discordgo.Session, i *discordgo.InteractionCreate, ...)
- func EditErrorMessage(sess *discordgo.Session, i *discordgo.InteractionCreate, err string)
- func GetMembersWithRole(sess *discordgo.Session, guildID, roleID string) ([]*discordgo.Member, error)
- func ParseUserOptions(sess *discordgo.Session, i *discordgo.InteractionCreate) map[string]*discordgo.ApplicationCommandInteractionDataOption
- func RegisterCommands(sess *discordgo.Session, commands []*discordgo.ApplicationCommand, ...)
- func RemoveCommands(sess *discordgo.Session, registeredCommands []*discordgo.ApplicationCommand)
- func SendErrorMessage(sess *discordgo.Session, i *discordgo.InteractionCreate, err string)
- func ShrinkFontSize(fontSize int, userInput string, maxCharacterSize int) int
- type Config
Constants ¶
This section is empty.
Variables ¶
var AppFs = afero.NewOsFs()
Functions ¶
func Contains ¶
Contains checks if an array contains an element. arr : the array to check. elem: the element to check for. returns true if the array contains the element, false otherwise.
func DeferReply ¶
func DeferReply(sess *discordgo.Session, i *discordgo.Interaction) error
DeferReply defers a reply.
func DeleteAllMessages ¶
func DeleteAllMessages(sess *discordgo.Session, i *discordgo.InteractionCreate, messages []*discordgo.Message)
DeleteAllMessages Delete all messages in a channel. sess : the discord session. i : discord interaction. messages: array of discord messages to delete.
func EditErrorMessage ¶ added in v1.5.0
func EditErrorMessage(sess *discordgo.Session, i *discordgo.InteractionCreate, err string)
EditErrorMessage edits the previous interaction response with an error message notifying the user something went wrong with the slash command. With an optional error message.
Since the error message is not empheral, it will be deleted after 5 seconds
func GetMembersWithRole ¶
func GetMembersWithRole(sess *discordgo.Session, guildID, roleID string) ([]*discordgo.Member, error)
GetMembersWithRole get all members from a guild with a specif role. guildID: the guild ID to fetch members from. roleID : the role ID to fetch. return: an array of members with the role, and any errors that arise
func ParseUserOptions ¶
func ParseUserOptions(sess *discordgo.Session, i *discordgo.InteractionCreate) map[string]*discordgo.ApplicationCommandInteractionDataOption
ParseUserOptions parses the user option passed to a command. sess: discord session. return: a map of input name : input value
func RegisterCommands ¶
func RegisterCommands(sess *discordgo.Session, commands []*discordgo.ApplicationCommand, registeredCommands []*discordgo.ApplicationCommand)
RegisterCommands register an array of commands to a discord session. sess: discord session. commands: array of discord commands to register. registeredCommands: array of commands to keep track of registered commands. this function will panic if registration of a command fails.
func RemoveCommands ¶
func RemoveCommands(sess *discordgo.Session, registeredCommands []*discordgo.ApplicationCommand)
RemoveCommands will delete all registered commands in all servers the discord bot is currently in. sess: discord session. registeredCommands: array of commands to remove.
func SendErrorMessage ¶
func SendErrorMessage(sess *discordgo.Session, i *discordgo.InteractionCreate, err string)
SendErrorMessage send an empheral interaction response message notifying the user something went wrong with the slash command. With an optional error message.
func ShrinkFontSize ¶
ShrinkFontSize shrink the font size passed in based on the length of user input and the max length of character. fontSize: the initial font size. maxCharacterSize: the max length of character. Returns the new font size.
Types ¶
type Config ¶
type Config struct { Token string `json:"-"` TokenDev string `json:"-"` RedditUserName string `json:"-"` RedditClientId string `json:"-"` RedditSecret string `json:"-"` RedditPassword string `json:"-"` LogLevel string `json:"logLevel"` Development bool `json:"-"` RapidAPIKey string `json:"-"` // ID of the bot owner BotOwner string `json:"botOwner"` // path to the local db DbPath string `json:"dbPath"` Emotes []struct { // name of emote Name string `json:"name"` // url to emote URL string `json:"url"` } `json:"emotes"` // config for new member greetings NewMemberGreeting struct { Config []struct { ServerName string `json:"serverName"` RoleID string `json:"roleID"` ServerID string `json:"serverID"` ChannelID string `json:"channelID"` Enable bool `json:"enable"` } `json:"config"` } `json:"newMemberGreeting"` Ivan struct { Emotes []struct { Name string `json:"name"` FileLocation string `json:"fileLocation"` } `json:"emotes"` } `json:"ivan"` SubForCarmen struct { // toggle this feature on and off On bool `json:"on"` // id of carmen user to track messages of CarmenID string `json:"carmenId"` // cool down, defined in minutes CoolDown int `json:"coolDown"` // the guild to keep track of carmen messages GuildID string `json:"guildID"` // number of messages before a notification is triggered MessageLimit int `json:"messageLimit"` SubscribersRoleID string `json:"subscribersRoleID"` // channels to ignore IgnoredChannels []string `json:"ignoredChannels"` } `json:"subForCarmen"` }
config object as defined in config.json. do not json martial sensitive fields such as discord token