Documentation ¶
Index ¶
- type Connection
- func (db *Connection) AddAdminRole(gid string, roleID string) (int, error)
- func (db *Connection) AddDiscordStatusPost(tid string, post *guildmodels.MessageRef) error
- func (db *Connection) AddManagedRoleRule(rule guildmodels.ManagedRoleRule) error
- func (db *Connection) ClearDiscordStatusPosts(uid string) error
- func (db *Connection) Close()
- func (db *Connection) CreateDatabase(dbName string)
- func (db *Connection) CreateTables()
- func (db *Connection) DeleteTwitchStream(uid string) error
- func (db *Connection) GetAllTwitchUIDs() ([]string, error)
- func (db *Connection) GetGuildRolesWithInitialReact(guildID string) ([]guildmodels.ManagedRoleRule, error)
- func (db *Connection) GetMemberByConnection(connection guildmodels.MemberConnections, guildID, userID *string) ([]guildmodels.MemberData, error)
- func (db *Connection) GetOrCreateGuild(id string) (*guildmodels.DiscordGuild, error)
- func (db *Connection) GetRoleRules(guildID string, roleID string) ([]guildmodels.ManagedRoleRule, error)
- func (db *Connection) GetTwitchConnectionData(guildID, userID string) (*guildmodels.TwitchStream, error)
- func (db *Connection) GetTwitchStream(uid string) (*guildmodels.TwitchStream, error)
- func (db *Connection) IsManagedRole(guildID string, roleID string) (bool, error)
- func (db *Connection) LookupNowLiveRoles(guildID string) ([]guildmodels.ManagedRoleRule, error)
- func (db *Connection) LookupRolesByEmote(msgID string, chanID string, guildID string, emojiID string) ([]guildmodels.ManagedRoleRule, error)
- func (db *Connection) RemoveDiscordStatusPost(uid string, post *guildmodels.MessageRef) error
- func (db *Connection) SetTwitchConnectionData(guildID, userID, twitchUID string) (*guildmodels.TwitchStream, *guildmodels.TwitchStream, error)
- func (db *Connection) SetTwitchStreamLive(uid string, isLive bool) error
- func (db *Connection) UpdateGuildNotificationChannels(gid string, notifChans guildmodels.NotificationChannels) error
- func (db *Connection) WaitTablesRead()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection contains a handle to the database
func Init ¶
func Init() (*Connection, error)
Init creates a new connection pool for the database at the address provided by the relevant environment variable
func (*Connection) AddAdminRole ¶
func (db *Connection) AddAdminRole(gid string, roleID string) (int, error)
AddAdminRole adds a roleID to the list of AdminRoles for the given guild. It returns the number of updated entries as well as any errors
func (*Connection) AddDiscordStatusPost ¶
func (db *Connection) AddDiscordStatusPost(tid string, post *guildmodels.MessageRef) error
AddDiscordStatusPost inserts a message reference into the status posts array for the provided twitch UID in the database
func (*Connection) AddManagedRoleRule ¶
func (db *Connection) AddManagedRoleRule(rule guildmodels.ManagedRoleRule) error
AddManagedRoleRule inserts a new managed role rule struct into the database
func (*Connection) ClearDiscordStatusPosts ¶
func (db *Connection) ClearDiscordStatusPosts(uid string) error
ClearDiscordStatusPosts removes all message references from the status posts array for the provided twitch UID in the database
func (*Connection) Close ¶
func (db *Connection) Close()
Close cleanly terminates the database connection
func (*Connection) CreateDatabase ¶
func (db *Connection) CreateDatabase(dbName string)
CreateDatabase ensures the nia database exists
func (*Connection) CreateTables ¶
func (db *Connection) CreateTables()
CreateTables ensures all tables needed exist.
func (*Connection) DeleteTwitchStream ¶
func (db *Connection) DeleteTwitchStream(uid string) error
DeleteTwitchStream removes a twitch stream from the database
func (*Connection) GetAllTwitchUIDs ¶
func (db *Connection) GetAllTwitchUIDs() ([]string, error)
GetAllTwitchUIDs returns a list of all twitch braodcaster UIDs that have been registered by members
func (*Connection) GetGuildRolesWithInitialReact ¶
func (db *Connection) GetGuildRolesWithInitialReact(guildID string) ([]guildmodels.ManagedRoleRule, error)
GetGuildRolesWithInitialReact takes a guild ID and returns a slice of all role assignment rules for that server that both use reactions for role assignment and for which the bost should make an initial reaction.
func (*Connection) GetMemberByConnection ¶
func (db *Connection) GetMemberByConnection(connection guildmodels.MemberConnections, guildID, userID *string) ([]guildmodels.MemberData, error)
GetMemberByConnection looks up members by connection. The MemberConnections struct should have exactly one non-nil connection.
func (*Connection) GetOrCreateGuild ¶
func (db *Connection) GetOrCreateGuild(id string) (*guildmodels.DiscordGuild, error)
GetOrCreateGuild fetches a guild with a given ID from the database, creating a new one if it does not exist.
func (*Connection) GetRoleRules ¶
func (db *Connection) GetRoleRules(guildID string, roleID string) ([]guildmodels.ManagedRoleRule, error)
GetRoleRules returns all role assignment rules for a given role in a given server
func (*Connection) GetTwitchConnectionData ¶
func (db *Connection) GetTwitchConnectionData(guildID, userID string) (*guildmodels.TwitchStream, error)
GetTwitchConnectionData returns exactly one twitch connection object for the given member if it exists.
func (*Connection) GetTwitchStream ¶
func (db *Connection) GetTwitchStream(uid string) (*guildmodels.TwitchStream, error)
GetTwitchStream returns a TwitchStream struct for the stream with the provided uid. If it does not exist, a new one will be created and returned.
func (*Connection) IsManagedRole ¶
func (db *Connection) IsManagedRole(guildID string, roleID string) (bool, error)
IsManagedRole returns true iff we have any rules stored for the given roleID in the given guildID
func (*Connection) LookupNowLiveRoles ¶
func (db *Connection) LookupNowLiveRoles(guildID string) ([]guildmodels.ManagedRoleRule, error)
LookupNowLiveRoles returns a list of all roles in the given server which should be assigned when a member is online on a streaming platform.
func (*Connection) LookupRolesByEmote ¶
func (db *Connection) LookupRolesByEmote(msgID string, chanID string, guildID string, emojiID string) ([]guildmodels.ManagedRoleRule, error)
LookupRolesByEmote takes a message ID as well as its channel and guild, along with an emoji ID. It then returns any managed role rules that include that reaction.
func (*Connection) RemoveDiscordStatusPost ¶
func (db *Connection) RemoveDiscordStatusPost(uid string, post *guildmodels.MessageRef) error
RemoveDiscordStatusPost removes the given message reference from the status posts array for the provided twitch UID in the database
func (*Connection) SetTwitchConnectionData ¶
func (db *Connection) SetTwitchConnectionData(guildID, userID, twitchUID string) (*guildmodels.TwitchStream, *guildmodels.TwitchStream, error)
SetTwitchConnectionData updates the stored twitch connection for a given member, returning the new TwitchStream value as well as the previous value if it was set.
func (*Connection) SetTwitchStreamLive ¶
func (db *Connection) SetTwitchStreamLive(uid string, isLive bool) error
SetTwitchStreamLive updates the database to reflect whether the provided twitch stream is live or not.
func (*Connection) UpdateGuildNotificationChannels ¶
func (db *Connection) UpdateGuildNotificationChannels(gid string, notifChans guildmodels.NotificationChannels) error
UpdateGuildNotificationChannels updates the notification channels assigned to a given guild stored in the database
func (*Connection) WaitTablesRead ¶
func (db *Connection) WaitTablesRead()