Documentation ¶
Index ¶
- Variables
- func ShouldReportError(err error) bool
- type DB
- func (db *DB) BanSystem(guild discord.GuildID, uuid uuid.UUID) (err error)
- func (db *DB) Channels(id discord.GuildID) (ch EventMap, err error)
- func (db *DB) CreateServerIfNotExists(g *gateway.GuildCreateEvent)
- func (db *DB) DeleteMessage(id discord.MessageID) (err error)
- func (db *DB) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (db *DB) GetInviteName(code string) (name string, err error)
- func (db *DB) GetInvites(guildID discord.GuildID) (Invites, error)
- func (db *DB) GetMessage(id discord.MessageID) (m *Message, err error)
- func (db *DB) GuildWatchlist(id discord.GuildID) (l []WatchlistUser, err error)
- func (db *DB) IgnoreMessage(id discord.MessageID) error
- func (db *DB) InsertMessage(m Message) (err error)
- func (db *DB) IsBlacklisted(guildID discord.GuildID, channelID discord.ChannelID) (blacklisted bool)
- func (db *DB) IsIgnored(id discord.MessageID) (exists bool)
- func (db *DB) IsSystemBanned(guild discord.GuildID, id string, uuid uuid.UUID) (banned bool, err error)
- func (db *DB) NameInvite(guildID discord.GuildID, code, name string) (err error)
- func (db *DB) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (db *DB) Redirects(id discord.GuildID) (m RedirectMap, err error)
- func (db *DB) Report(ctx ErrorContext, err error) *sentry.EventID
- func (db *DB) ReportCtx(ctx bcr.Contexter, e error) (err error)
- func (db *DB) ReportEmbed(ctx bcr.Contexter, id *sentry.EventID) (err error)
- func (db *DB) SetChannels(id discord.GuildID, ch EventMap) (err error)
- func (db *DB) SetRedirects(id discord.GuildID, m RedirectMap) (err error)
- func (db *DB) UnbanSystem(guild discord.GuildID, id string, uuid uuid.UUID) (err error)
- func (db *DB) UpdatePKInfo(msgID discord.MessageID, userID pkgo.Snowflake, system, member string) (err error)
- func (db *DB) UpdateUserID(msgID discord.MessageID, userID discord.UserID) (err error)
- func (db *DB) UserWatchlist(guildID discord.GuildID, userID discord.UserID) (w *WatchlistUser, err error)
- func (db *DB) WatchlistAdd(guildID discord.GuildID, userID, modID discord.UserID, reason string) (w WatchlistUser, err error)
- func (db *DB) WatchlistRemove(guildID discord.GuildID, userID discord.UserID) (err error)
- type ErrorContext
- type EventMap
- type Invite
- type Invites
- type Message
- type Metadata
- type RedirectMap
- type WatchlistUser
Constants ¶
This section is empty.
Variables ¶
var DefaultRedirectMap = RedirectMap{}
DefaultRedirectMap is an empty redirect map
var EventDescs map[string]string = map[string]string{
"GUILD_UPDATE": "Guild Update: changes to the server",
"GUILD_EMOJIS_UPDATE": "Guild Emojis Update: changes to custom emotes",
"GUILD_ROLE_CREATE": "Guild Role Create: roles being created",
"GUILD_ROLE_UPDATE": "Guild Role Update: changes to roles",
"GUILD_ROLE_DELETE": "Guild Role Delete: roles being deleted",
"CHANNEL_CREATE": "Channel Create: channels being created",
"CHANNEL_UPDATE": "Channel Update: changes to channels",
"CHANNEL_DELETE": "Channel Delete: channels being deleted",
"GUILD_MEMBER_ADD": "Guild Member Add: members joining",
"GUILD_MEMBER_UPDATE": "Guild Member Update: roles being added/removed from members",
"GUILD_MEMBER_NICK_UPDATE": "Guild Member Nick Update: avatar and nickname changes",
"GUILD_KEY_ROLE_UPDATE": "Key Role Update: key roles added/removed to users",
"GUILD_MEMBER_REMOVE": "Guild Member Remove: members leaving",
"GUILD_MEMBER_KICK": "Guild Member Kick: members being kicked",
"GUILD_BAN_ADD": "Guild Ban Add: members being banned",
"GUILD_BAN_REMOVE": "Guild Ban Remove: members being unbanned",
"INVITE_CREATE": "Invite Create: invites being created",
"INVITE_DELETE": "Invite Delete: invites being deleted",
"MESSAGE_UPDATE": "Message Update: edited messages",
"MESSAGE_DELETE": "Message Delete: deleted messages",
"MESSAGE_DELETE_BULK": "Message Delete Bulk: bulk deleted messages",
}
EventDescs is a description of events used in command options
var Events []string = []string{
"GUILD_UPDATE",
"GUILD_EMOJIS_UPDATE",
"GUILD_ROLE_CREATE",
"GUILD_ROLE_UPDATE",
"GUILD_ROLE_DELETE",
"CHANNEL_CREATE",
"CHANNEL_UPDATE",
"CHANNEL_DELETE",
"GUILD_MEMBER_ADD",
"GUILD_MEMBER_UPDATE",
"GUILD_MEMBER_NICK_UPDATE",
"GUILD_KEY_ROLE_UPDATE",
"GUILD_MEMBER_REMOVE",
"GUILD_BAN_ADD",
"GUILD_BAN_REMOVE",
"GUILD_MEMBER_KICK",
"INVITE_CREATE",
"INVITE_DELETE",
"MESSAGE_UPDATE",
"MESSAGE_DELETE",
"MESSAGE_DELETE_BULK",
}
Events is a list of all available events
Functions ¶
func ShouldReportError ¶
ShouldReportError returns true if err should be reported to Sentry.
Types ¶
type DB ¶
type DB struct { Pool *pgxpool.Pool Hub *sentry.Hub // Used for encryption AESKey [32]byte Stats *stats.Client }
DB ...
func (*DB) CreateServerIfNotExists ¶
func (db *DB) CreateServerIfNotExists(g *gateway.GuildCreateEvent)
CreateServerIfNotExists ...
func (*DB) DeleteMessage ¶
DeleteMessage deletes a message from the database
func (*DB) GetInviteName ¶
GetInviteName gets an invite by name. If the invite is not found, returns "Unnamed".
func (*DB) GetInvites ¶
GetInvites gets this guild's named invites
func (*DB) GetMessage ¶
GetMessage gets a single message
func (*DB) GuildWatchlist ¶
func (db *DB) GuildWatchlist(id discord.GuildID) (l []WatchlistUser, err error)
GuildWatchlist gets the watchlist for the given guild ID.
func (*DB) InsertMessage ¶
InsertMessage inserts a message
func (*DB) IsBlacklisted ¶
func (*DB) IsSystemBanned ¶
func (db *DB) IsSystemBanned(guild discord.GuildID, id string, uuid uuid.UUID) (banned bool, err error)
IsSystemBanned returns true if the system is banned
func (*DB) NameInvite ¶
NameInvite names an invite
func (*DB) Redirects ¶
func (db *DB) Redirects(id discord.GuildID) (m RedirectMap, err error)
Redirects gets the server's channel:channel map
func (*DB) Report ¶
func (db *DB) Report(ctx ErrorContext, err error) *sentry.EventID
Report reports an error.
func (*DB) ReportCtx ¶
ReportCtx reports an error and sends the event ID to the context channel, if possible
func (*DB) ReportEmbed ¶
ReportEmbed ...
func (*DB) SetChannels ¶
SetChannels ...
func (*DB) SetRedirects ¶
func (db *DB) SetRedirects(id discord.GuildID, m RedirectMap) (err error)
SetRedirects sets the server's channel:channel map
func (*DB) UnbanSystem ¶
UnbanSystem unbans the given system
func (*DB) UpdatePKInfo ¶
func (db *DB) UpdatePKInfo(msgID discord.MessageID, userID pkgo.Snowflake, system, member string) (err error)
UpdatePKInfo updates the PluralKit info for the given message, if it exists in the database.
func (*DB) UpdateUserID ¶
UpdateUserID updates *just* the user ID for the given message, if it exists in the database.
func (*DB) UserWatchlist ¶
func (db *DB) UserWatchlist(guildID discord.GuildID, userID discord.UserID) (w *WatchlistUser, err error)
UserWatchlist returns the watchlist entry for a user, if any.
func (*DB) WatchlistAdd ¶
func (db *DB) WatchlistAdd(guildID discord.GuildID, userID, modID discord.UserID, reason string) (w WatchlistUser, err error)
WatchlistAdd adds a user to the watchlist, or updates the reason.
type ErrorContext ¶
type ErrorContext struct { Event string Command string UserID discord.UserID GuildID discord.GuildID }
ErrorContext is the context for an error
type EventMap ¶
EventMap is a map of event names → log channels
var DefaultEventMap EventMap = EventMap{
"GUILD_UPDATE": 0,
"GUILD_EMOJIS_UPDATE": 0,
"GUILD_ROLE_CREATE": 0,
"GUILD_ROLE_UPDATE": 0,
"GUILD_ROLE_DELETE": 0,
"CHANNEL_CREATE": 0,
"CHANNEL_UPDATE": 0,
"CHANNEL_DELETE": 0,
"GUILD_MEMBER_ADD": 0,
"GUILD_MEMBER_UPDATE": 0,
"GUILD_MEMBER_NICK_UPDATE": 0,
"GUILD_KEY_ROLE_UPDATE": 0,
"GUILD_MEMBER_REMOVE": 0,
"GUILD_BAN_ADD": 0,
"GUILD_BAN_REMOVE": 0,
"GUILD_MEMBER_KICK": 0,
"INVITE_CREATE": 0,
"INVITE_DELETE": 0,
"MESSAGE_UPDATE": 0,
"MESSAGE_DELETE": 0,
"MESSAGE_DELETE_BULK": 0,
}
DefaultEventMap is an event map with all events set to 0
type Message ¶
type Message struct { MsgID discord.MessageID UserID discord.UserID ChannelID discord.ChannelID ServerID discord.GuildID Content string Username string // These are only filled if the message was proxied by PluralKit Member *string System *string Metadata *Metadata `db:"-"` RawMetadata *[]byte `db:"metadata"` }
Message is a single message
type Metadata ¶
type Metadata struct { UserID *discord.UserID `json:"user_id,omitempty"` Username string `json:"username,omitempty"` Avatar string `json:"avatar,omitempty"` Embeds []discord.Embed `json:"embeds,omitempty"` }
Metadata is optional message metadata
type RedirectMap ¶
RedirectMap is a map of origin channels → redirect channels. Key is string type so it can get encoded into JSON to store in the database