Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Deleted = Deletable{true} NotDeleted = Deletable{false} )
Convenient variables for Deletables.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { // ID is the ID of the channel. ID discord.ChannelID // ParentID is the ID of the parent channel, if any. ParentID discord.ChannelID // Name is the name of the channel. Name string // Type is the type of the channel. Type discord.ChannelType // Position is the position of the role. Position int }
Channel is metadata for a channel.
func ChannelFromDiscord ¶
ChannelFromDiscord returns a Channel from a discord.Channel.
type Deletable ¶
type Deletable struct {
Deleted bool
}
Deletable is a structure for an entity that can be deleted.
type FetchedChannel ¶
FetchedChannel is a Channel fetched from the store.
type FetchedGuild ¶
type FetchedGuild struct { Guild // Channels is the list of channels in the guild. Channels []FetchedChannel Deletable }
FetchedGuild is a Guild fetched from the store.
type FetchedMessage ¶
FetchedMessage is a message that is fetched from the store.
type FetchedMessages ¶
type FetchedMessages struct { // Messages is a slice of messages. The messages are sorted latest first. Messages []FetchedMessage // ExtraRepliedTo is a map of message IDs to the message that they are // replying to. It does not contain messages that are already in Messages, // so that should be searched first. ExtraRepliedTo map[discord.MessageID]FetchedMessage // Authors is a map of author IDs to author metadata. The map should contain // all known authors of the messages, but some authors may be missing. Authors map[discord.UserID]Member // Roles is a map of role IDs to role metadata. The map should contain all // known roles of the authors, but some roles may be missing. Roles map[discord.RoleID]Role // HasMore is whether there are more messages that could be fetched. HasMore bool }
FetchedMessages is a slice of messages that are fetched from the store.
func (FetchedMessages) AuthorColor ¶
func (m FetchedMessages) AuthorColor(uID discord.UserID) discord.Color
AuthorColor returns the color of the author of the message. If the author doesn't have a color, then false is returned.
func (FetchedMessages) EarliestID ¶
func (m FetchedMessages) EarliestID() discord.MessageID
EarliestID returns the earliest message ID in the slice. If the slice is empty, then 0 is returned.
func (FetchedMessages) Message ¶
func (m FetchedMessages) Message(id discord.MessageID) (FetchedMessage, bool)
Message looks up both the Messages list and the ExtraRepliedTo map for the message with the given ID.
type Guild ¶
type Guild struct { // ID is the ID of the guild. ID discord.GuildID // OwnerID is the ID of the owner of the guild. OwnerID discord.UserID // Name is the name of the guild. Name string // Icon is the icon of the guild. Icon string Deletable }
Guild is metadata for a guild.
func GuildFromDiscord ¶
GuildFromDiscord returns a Guild from a discord.Guild.
type GuildStorer ¶
type GuildStorer interface { // Guilds returns all guilds. Guilds(context.Context) ([]Guild, error) // Guild returns a guild by its ID. This method returns more data than // Guilds does. Guild(context.Context, discord.GuildID) (*FetchedGuild, error) // UpdateGuild updates the metadata of a guild. The store must replace all // existing channels and roles within each guild with the new ones. UpdateGuild(context.Context, GuildUpdateData) error // DeleteGuild deletes the given guild. DeleteGuild(context.Context, discord.GuildID) error // UpdateMember updates the metadata of a guild member. If the members' // guilds are not found, then the store is permitted to ignore them. The // store should persistently store all members. UpdateMember(context.Context, discord.GuildID, Member) error // UnknownMembers returns all unknown member IDs within the guild. This is // obtained by going over messages and checking if they have a member in the // record. UnknownMembers(context.Context, discord.GuildID) ([]discord.UserID, error) }
GuildStorer stores guilds.
type GuildUpdateData ¶
type GuildUpdateData struct { Guild // Channels is the list of channels in the guild. Channels []Channel // Role is the list of roles in the guild. Roles []Role }
GuildUpdateData contains more data for updating a Guild's state.
type Member ¶
type Member struct { User // Nick is the nickname of the member. Nick string // RoleIDs is a list of role IDs that the member has. RoleIDs []discord.RoleID }
Member is metadata for a member.
func MemberFromDiscord ¶
MemberFromDiscord returns a Member from a discord.Member.
type Message ¶
type Message struct { // ID is the ID of the message. ID discord.MessageID // ReplyingTo is the ID of the message that this message is replying to, if // any. ReplyingTo discord.MessageID // AuthorID is the ID of the author of the message. AuthorID discord.UserID // LastEditedAt is the timestamp of the last update to the message. If 0, // then the message has never been edited. LastEditedAt discord.Timestamp // Content is the content of the message. Content MessageContent }
Message is metadata for a message.
func MessageFromDiscord ¶
MessageFromDiscord returns a Message from a discord.Message.
type MessageContent ¶
type MessageContent struct { Body string `json:"content"` Embeds []discord.Embed `json:"embeds"` Attachments []discord.Attachment `json:"attachments"` Reactions []discord.Reaction `json:"reactions,omitempty"` Components discord.ContainerComponents `json:"components,omitempty"` Stickers []discord.StickerItem `json:"sticker_items,omitempty"` MentionEveryone bool `json:"mention_everyone"` MentionUserIDs []discord.UserID `json:"mention_user_ids"` MentionRoleIDs []discord.RoleID `json:"mention_role_ids"` MentionChannelIDs []discord.ChannelID `json:"mention_channel_ids,omitempty"` }
MessageContent is the content of a message. This specific structure is JSON-encodable; it is recommended to store this as JSON to be faithful to the API.
type MessageStorer ¶
type MessageStorer interface { // Messages returns messages in the given channel. Messages must be returned // latest first. // // The store determines how many messages to paginate, and the client must // handle that by using the beforeID parameter. If beforeID is 0, then the // store must return the latest messages. The returned messages should not // fetch beforeID again. Messages(ctx context.Context, chID discord.ChannelID, beforeID discord.MessageID) (*FetchedMessages, error) // UpdateMessages adds or updates a slice of messages to the store. The // messages shall be persisted permanently unless deleted later. UpdateMessages(ctx context.Context, chID discord.ChannelID, msgs []MessageUpdateData) error // DeleteMessages deletes a slice of messages from the store. The messages // don't have to be permanently deleted from the store. DeleteMessages(ctx context.Context, chID discord.ChannelID, msgIDs []discord.MessageID) error }
MessageStorer stores messages.
type MessageUpdateData ¶
MessageUpdateData contains more data for updating a Message's state.
type Role ¶
type Role struct { // ID is the ID of the role. ID discord.RoleID // Name is the name of the role. Name string // Position is the position of the role. Position int // Color is the color of the role. Color discord.Color // Permissions is the permissions of the role. Permissions discord.Permissions }
Role is metadata for a role.
func RoleFromDiscord ¶
RoleFromDiscord returns a Role from a discord.Role.
type Storer ¶
type Storer interface { GuildStorer MessageStorer // Me returns the current user that the store has been tracking as. Me(context.Context) (*User, error) // SetMe sets the current user. SetMe(context.Context, User) error }
Storer describes a store for all tracked states.
type User ¶
type User struct { // ID is the ID of the user. ID discord.UserID // Username is the username of the user. Username string // Discriminator is the discriminator of the member. Discriminator string // Avatar is the avatar of the member. Avatar discord.Hash // Bot is whether the member is a bot. Bot bool }
User is a user that is tracked by the store.
func UserFromDiscord ¶
UserFromDiscord returns a User from a discord.User.
func (User) StaticAvatarURL ¶
StaticAvatarURL always returns a PNG avatar URL of the user.