Documentation ¶
Overview ¶
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
SPDX-License-Identifier: AGPL-3.0-only
Index ¶
- Constants
- Variables
- func IsOurProblem(e error) bool
- type Bot
- func (bot *Bot) Add(fns ...func(*Bot) (string, []*bcr.Command))
- func (bot *Bot) CacheLen() int64
- func (bot *Bot) CheckAdmin(ctx *bcr.CommandContext) (err error)
- func (bot *Bot) CheckHelper(ctx *bcr.CommandContext) (err error)
- func (bot *Bot) CheckMod(ctx *bcr.CommandContext) (err error)
- func (bot *Bot) CheckPermissions(ctx *bcr.Context, routing bool) (name string, allowed bool, data api.SendMessageData)
- func (bot *Bot) CheckPrefix(m discord.Message) int
- func (bot *Bot) Commands() []api.CreateCommandData
- func (bot *Bot) GuildCreate(g *gateway.GuildCreateEvent)
- func (bot *Bot) InitValidPermissionNodes()
- func (bot *Bot) Member(guildID discord.GuildID, userID discord.UserID) (m discord.Member, err error)
- func (bot *Bot) Members(guildID discord.GuildID) (members []discord.Member)
- func (bot *Bot) MessageCreate(m *gateway.MessageCreateEvent)
- func (bot *Bot) NoDM(ctx *bcr.CommandContext) (err error)
- func (bot *Bot) NodeLevel(guildID discord.GuildID, node string) common.Node
- func (bot *Bot) PagedEmbed(ctx *bcr.Context, embeds []discord.Embed, timeout time.Duration) (msg *discord.Message, err error)
- func (bot *Bot) Report(ctx *bcr.Context, e error) (err error)
- func (bot *Bot) ReportInteraction(c bcr2.HasContext, e error) (err error)
- func (bot *Bot) RequireNode(required string) bcr.Check[*bcr.CommandContext]
- func (bot *Bot) ShowText(w http.ResponseWriter, title, header, text string, v ...interface{})
- func (bot *Bot) Start(ctx context.Context) error
- func (bot *Bot) UserBotPermissions(user discord.User, member *discord.Member, guild *discord.Guild) common.PermissionLevel
- type Event
- type Module
- type Scheduler
Constants ¶
const ErrUnknownEvent = errors.Sentinel("unknown event type")
const Reschedule = errors.Sentinel("reschedule event")
Return Reschedule if the event should be rescheduled (offset by the duration returned from Offset)
Variables ¶
var Commands = []api.CreateCommandData{ { Name: "bubble", Description: "Bubble wrap!", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.IntegerOption{ OptionName: "size", Description: "Size of the bubble wrap (default 10)", Min: option.NewInt(1), Max: option.NewInt(13), }, &discord.BooleanOption{ OptionName: "prepop", Description: "Whether to pre-pop some bubbles", }, &discord.BooleanOption{ OptionName: "ephemeral", Description: "Whether to send the bubble wrap as a message only visible to you", }, }, }, { Name: "linkto", Description: "Move a conversation to another channel.", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.ChannelOption{ OptionName: "channel", ChannelTypes: []discord.ChannelType{discord.GuildText, discord.GuildNews, discord.GuildPublicThread, discord.GuildPrivateThread, discord.GuildNewsThread}, Required: true, Description: "The channel to link to.", }, &discord.StringOption{ OptionName: "topic", Required: false, Description: "The topic.", }, }, }, { Name: "pride", Description: "Add a pride flag circle to your profile picture!", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.StringOption{ OptionName: "flag", Description: "Which flag to use.", Required: false, }, &discord.StringOption{ OptionName: "pk-member", Description: "Which PluralKit member's avatar to add a pride flag to.", Required: false, }, }, }, { Name: "sampa", Description: "Convert X-SAMPA to IPA.", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.StringOption{ OptionName: "text", Description: "The text to convert to IPA.", Required: true, }, }, }, { Name: "reminders", Description: "Show your reminders.", Type: discord.ChatInputCommand, }, { Name: "remindme", Description: "Show your reminders.", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.StringOption{ OptionName: "when", Description: "When or in how long to remind you.", Required: true, }, &discord.StringOption{ OptionName: "text", Description: "What to remind you of.", }, }, }, { Name: "level", Description: "Use levels.", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.SubcommandOption{ OptionName: "show", Description: "Show your or another user's level.", Options: []discord.CommandOptionValue{&discord.UserOption{ OptionName: "user", Description: "The user to show.", Required: false, }}, }, &discord.SubcommandOption{ OptionName: "leaderboard", Description: "Show this server's leaderboard.", Options: []discord.CommandOptionValue{&discord.BooleanOption{ OptionName: "full", Description: "Whether to show the full leaderboard (including users who have left the server)", Required: false, }}, }, }, }, { Name: "info", Description: "Show information about a user, role, or this server.", Type: discord.ChatInputCommand, Options: discord.CommandOptions{ &discord.SubcommandOption{ OptionName: "user", Description: "Show info about a user.", Options: []discord.CommandOptionValue{&discord.UserOption{ OptionName: "user", Description: "The user to look up.", Required: false, }}, }, }, }, { Name: "Show user avatar", Type: discord.UserCommand, }, }
Functions ¶
func IsOurProblem ¶
IsOurProblem checks if an error is "our problem", as in, should be in the logs and reported to Sentry. Will be expanded eventually once we get more insight into what type of errors we get.
Types ¶
type Bot ¶
type Bot struct { *bcrbot.Bot Interactions *bcr2.Router Config *common.BotConfig Sugar *zap.SugaredLogger DB *db.DB Scheduler *Scheduler Chi *chi.Mux EmbedColour discord.Color GuildLogWebhook *webhook.Client Counters struct { Mu sync.Mutex Mentions int Messages int } Hub *sentry.Hub PK *pkgo.Session ValidNodes []string // contains filtered or unexported fields }
Bot is the main bot struct
func (*Bot) CheckAdmin ¶
func (*Bot) CheckHelper ¶
func (*Bot) CheckPermissions ¶
func (*Bot) CheckPrefix ¶
CheckPrefix checks the prefix
func (*Bot) Commands ¶
func (bot *Bot) Commands() []api.CreateCommandData
func (*Bot) GuildCreate ¶
func (bot *Bot) GuildCreate(g *gateway.GuildCreateEvent)
GuildCreate logs the bot joining a server, and creates a database entry if one doesn't exist
func (*Bot) InitValidPermissionNodes ¶
func (bot *Bot) InitValidPermissionNodes()
func (*Bot) Member ¶
func (bot *Bot) Member(guildID discord.GuildID, userID discord.UserID) (m discord.Member, err error)
Member gets a member from the cache, or tries fetching it from Discord
func (*Bot) Members ¶
Members gets all *cached* members for a guild. Members are sorted by their ID.
func (*Bot) MessageCreate ¶
func (bot *Bot) MessageCreate(m *gateway.MessageCreateEvent)
MessageCreate is run on a message create event
func (*Bot) PagedEmbed ¶
func (bot *Bot) PagedEmbed(ctx *bcr.Context, embeds []discord.Embed, timeout time.Duration) (msg *discord.Message, err error)
PagedEmbed ...
func (*Bot) ReportInteraction ¶
func (bot *Bot) ReportInteraction(c bcr2.HasContext, e error) (err error)
ReportInteraction is like ReportCtx but takes a SlashContext instead
func (*Bot) RequireNode ¶
func (*Bot) ShowText ¶
func (bot *Bot) ShowText(w http.ResponseWriter, title, header, text string, v ...interface{})
type Event ¶
type Event interface { Execute(ctx context.Context, id int64, bot *Bot) error Offset() time.Duration }
Event is any event that can be scheduled. Execute is called when the event is due to fire, Offset is called to determine how much to move the event.