Documentation ¶
Index ¶
- Variables
- func EmojiApiAsConfig(e *discord.APIEmoji, animated bool) string
- func EmojiApiFormatted(e *discord.APIEmoji, animated bool) (string, error)
- func EmojiConfigAsApi(e string) (discord.APIEmoji, error)
- func EmojiConfigFormatted(e string) (string, error)
- func GuildContext(c discord.GuildID, g guildOperation)
- func LoadActivityStatus()
- func LoadConfig()
- func LoadPluginConfig()
- func SaveConfig()
- func SavePluginConfig()
- func SetPrefix(fnName string, id discord.GuildID, prefix string) (string, error)
- func SetupConfigSaving()
- type ActiveTopicVote
- type Command
- type CommandInfo
- type Config
- type Error
- type GuildConfig
- type HandlerInfo
- type JobInfo
- type PermissionGroups
- type PluginConfig
- type Response
- type ResponseInfo
- type StarboardConfig
- type StarboardMessage
Constants ¶
This section is empty.
Variables ¶
var ( C Config P PluginConfig DefaultPrefix = "." DefaultPlugins = []string{"base", "base-extra", "base-fun", "bookmarker", "leave-join-msg", "message-roles", "role-menu", "spotifytoyoutube", "starboard", "remindme", "sys-stats", "suggest-topic", "tenor-delete"} FileMode = os.FileMode(0700) )
var ( Commands = make([]CommandInfo, 0) Responses = make([]ResponseInfo, 0) Handlers = make([]HandlerInfo, 0) Jobs = make([]JobInfo, 0) Mutex = sync.Mutex{} HttpClient = http.Client{Timeout: 5 * time.Second} Client state.State Ctx = context.Background() User *discord.User PermissionsHex = 278404582480 // this is currently only used in base.go, but it is in shared.go because it is bot-level and should be set by the person maintaining the bot code Scheduler = gocron.NewScheduler(getTimeZone()) SuccessColor discord.Color = 0x3cde5a ErrorColor discord.Color = 0xde413c WarnColor discord.Color = 0xde953c DefaultColor discord.Color = 0x493cde WhiteColor discord.Color = 0xfefefe BlueColor discord.Color = 0x0099FF )
Functions ¶
func EmojiApiAsConfig ¶
EmojiApiAsConfig will convert a discord.APIEmoji to our own config format, to preserve the animated attribute
func EmojiApiFormatted ¶
EmojiApiFormatted will format a discord.APIEmoji for display in a message
func EmojiConfigAsApi ¶
EmojiConfigAsApi will convert our own emoji format back to a discord.APIEmoji
func EmojiConfigFormatted ¶
EmojiConfigFormatted will format a taro config emoji for display in a message
func GuildContext ¶
GuildContext will modify a GuildConfig non-concurrently. Avoid using inside a network or hang-able context whenever possible. TODO: Having one "context" per command would be nice to have.
func LoadActivityStatus ¶
func LoadActivityStatus()
LoadActivityStatus will load the activity information from the config. Using USER_ID, USER_TAG and USER_USERNAME as replacements for the discord.Activity name are all supported. Setting URL is only useful for a Twitch or YouTube discord.StreamingActivity. The activity type uint8 is derived from its position in the list, eg, 0 == discord.GameActivity and 2 == discord.ListeningActivity.
func LoadConfig ¶
func LoadConfig()
func LoadPluginConfig ¶
func LoadPluginConfig()
func SaveConfig ¶
func SaveConfig()
func SavePluginConfig ¶
func SavePluginConfig()
func SetupConfigSaving ¶
func SetupConfigSaving()
SetupConfigSaving will run SaveConfig and SavePluginConfig every 5 minutes with a ticker
Types ¶
type ActiveTopicVote ¶
type ActiveTopicVote struct { Message int64 `json:"message"` Author int64 `json:"author"` Topic string `json:"topic"` }
ActiveTopicVote is used by suggest-topic.go
type Command ¶
type Command struct { E *gateway.MessageCreateEvent FnName string Name string Args []string }
Command is passed to CommandInfo.Fn's arguments when a Command is executed.
type CommandInfo ¶
type CommandInfo struct { Fn func(Command) error FnName string Name string Description string Aliases []string GuildOnly bool }
CommandInfo is the info a command provides to register itself. Fn is the function that is executed to complete the Command. The Name and Aliases are used to call the command via Discord.
func (CommandInfo) MarkdownString ¶
func (i CommandInfo) MarkdownString() string
func (CommandInfo) String ¶
func (i CommandInfo) String() string
type Config ¶
type Config struct { Mutex sync.Mutex `json:"-"` // not saved in DB PrefixCache map[int64]string `json:"-"` // not saved in DB // [guild id]prefix BotToken string `json:"bot_token"` FohToken string `json:"foh_token"` FohPublicUrl string `json:"foh_public_url,omitempty"` // See LoadConfig FohPublicDir string `json:"foh_public_dir,omitempty"` // See LoadConfig FohPrivateUrl string `json:"foh_private_url,omitempty"` // See LoadConfig FohPrivateDir string `json:"foh_private_dir,omitempty"` // See LoadConfig ActivityName string `json:"activity_name,omitempty"` // See LoadActivityStatus ActivityUrl string `json:"activity_url,omitempty"` // See LoadActivityStatus ActivityType uint8 `json:"activity_type,omitempty"` // See LoadActivityStatus OperatorChannel int64 `json:"operator_channel,omitempty"` OperatorIDs []int64 `json:"operator_ids,omitempty"` OperatorAliases map[string][]string `json:"operator_aliases,omitempty"` GuildConfigs []GuildConfig `json:"guild_configs,omitempty"` }
type GuildConfig ¶
type GuildConfig struct { ID int64 `json:"id"` Prefix string `json:"prefix,omitempty"` Permissions PermissionGroups `json:"permissions,omitempty"` ArchiveRole int64 `json:"archive_role,omitempty"` // TODO: Migrate ArchiveCategory int64 `json:"archive_category,omitempty"` // TODO: Migrate EnabledTopicChannels []int64 `json:"enabled_topic_channels,omitempty"` // TODO: Migrate ActiveTopicVotes []ActiveTopicVote `json:"active_topic_votes,omitempty"` // TODO: Migrate TopicVoteThreshold int64 `json:"topic_vote_threshold,omitempty"` // TODO: Migrate TopicVoteEmoji string `json:"topic_vote_emoji,omitempty"` // TODO: Migrate Starboard StarboardConfig `json:"starboard_config"` // TODO: Migrate }
type HandlerInfo ¶
HandlerInfo is used by features in order to register a gateway handler
func (HandlerInfo) String ¶
func (i HandlerInfo) String() string
type JobInfo ¶
JobInfo is used by features in order to easily return a job, and allow the bot to handle the errors
type PermissionGroups ¶
type PermissionGroups struct { ManageChannels []int64 `json:"manage_channels,omitempty"` ManagePermissions []int64 `json:"manage_permissions,omitempty"` Moderation []int64 `json:"moderation,omitempty"` }
PermissionGroups is collection of "permissions". Each permission is a list of user IDs that have said permission. Switching this to a list of {Name, Users} would maybe be better code-wise.
type PluginConfig ¶
type Response ¶
type Response struct {
E *gateway.MessageCreateEvent
}
Response is passed to Response.Fn's arguments when a Response is executed.
type ResponseInfo ¶
type ResponseInfo struct { Fn func(Response) `json:"fn"` Regexes []string `json:"regexes"` MatchMin int `json:"match_min"` LockChannels []int64 `json:"lock_channels,omitempty"` LockUsers []int64 `json:"lock_users,omitempty"` }
ResponseInfo is the info a response provides to register itself. Fn is the function that is executed to complete the Response. The Regexes are used to call the response via Discord.
func (ResponseInfo) String ¶
func (i ResponseInfo) String() string
type StarboardConfig ¶
type StarboardConfig struct { Channel int64 `json:"channel,omitempty"` // channel post ID NsfwChannel int64 `json:"nsfw_channel,omitempty"` // nsfw post channel ID Messages []StarboardMessage `json:"messages,omitempty"` Threshold int64 `json:"threshold,omitempty"` }
StarboardConfig is used by commands.go and starboard.go
type StarboardMessage ¶
type StarboardMessage struct { Author int64 `json:"author"` // the original author ID CID int64 `json:"channel_id"` // the original channel ID ID int64 `json:"id"` // the original message ID PostID int64 `json:"message"` // the starboard post message ID IsNsfw bool `json:"nsfw"` // if the original message was made in an NSFW channel Stars []int64 `json:"stars"` // list of added user IDs }
StarboardMessage is used by starboard.go