Documentation ¶
Overview ¶
Package ningen contains a set of helpful functions and packages to aid in making a Discord client.
Index ¶
- type ConnectedEvent
- type DisconnectedEvent
- type MessageMentionFlags
- type NoPermissionError
- type State
- func (s *State) AssertPermissions(chID discord.ChannelID, perms discord.Permissions) error
- func (s *State) ChannelCountUnreads(chID discord.ChannelID) int
- func (r *State) ChannelIsMuted(chID discord.ChannelID, category bool) bool
- func (r *State) ChannelIsUnread(chID discord.ChannelID) UnreadIndication
- func (s *State) Channels(guildID discord.GuildID, allowedTypes []discord.ChannelType) ([]discord.Channel, error)
- func (r *State) GuildIsUnread(guildID discord.GuildID, types []discord.ChannelType) UnreadIndication
- func (s *State) HasPermissions(chID discord.ChannelID, perms discord.Permissions) bool
- func (r *State) LastMessage(chID discord.ChannelID) discord.MessageID
- func (s *State) MessageMentions(msg *discord.Message) MessageMentionFlags
- func (s *State) Offline() *State
- func (s *State) Online() *State
- func (s *State) Open(ctx context.Context) error
- func (s *State) PrivateChannels() ([]discord.Channel, error)
- func (r *State) SetStatus(status discord.Status, custom *gateway.CustomUserStatus, ...) error
- func (s *State) Status() discord.Status
- func (r *State) UserIsBlocked(uID discord.UserID) bool
- func (s *State) WithContext(ctx context.Context) *State
- type UnreadIndication
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectedEvent ¶
ConnectedEvent is an event that's sent on Ready or Resumed. The event arrives before all ningen's handlers are called.
type DisconnectedEvent ¶
type DisconnectedEvent struct {
ws.CloseEvent
}
DisconnectedEvent is an event that's sent when the websocket is disconnected.
func (*DisconnectedEvent) IsGraceful ¶
func (ev *DisconnectedEvent) IsGraceful() bool
IsGraceful returns true if the disconnection is done by the websocket and not by a connection drop.
func (*DisconnectedEvent) IsLoggedOut ¶
func (ev *DisconnectedEvent) IsLoggedOut() bool
IsLoggedOut returns true if the session that Discord gave is now outdated and that the user must login again.
type MessageMentionFlags ¶
type MessageMentionFlags uint8
MessageMentionFlags is the resulting flag of a MessageMentions check. If it's 0, then absolutely no mentions are done, otherwise non-0 is returned.
const ( // MessageMentions is when a message mentions the user either by tagging // that user or a role that the user is in. MessageMentions MessageMentionFlags = 1 << iota // MessageNotifies is when the message should also send a visible // notification. MessageNotifies )
func (MessageMentionFlags) Has ¶
func (f MessageMentionFlags) Has(other MessageMentionFlags) bool
Has returns true if other is in f.
type NoPermissionError ¶
type NoPermissionError struct { Has discord.Permissions Wanted discord.Permissions }
NoPermissionError is returned by AssertPermissions if the user lacks the requested permissions.
func (*NoPermissionError) Error ¶
func (err *NoPermissionError) Error() string
Error implemenets error.
type State ¶
type State struct { *state.State *handler.Handler // Custom Cabinet values. MemberStore *nstore.MemberStore PresenceStore *nstore.PresenceStore // Custom State values. NoteState *note.State ReadState *read.State MutedState *mute.State GuildState *guild.State EmojiState *emoji.State MemberState *member.State RelationshipState *relationship.State // contains filtered or unexported fields }
func NewWithIdentifier ¶
func NewWithIdentifier(id gateway.Identifier) *State
NewWithIdentifier creates a new ningen state from the given identifier.
func (*State) AssertPermissions ¶
AssertPermissions asserts that the current user has the given permissions in the given channel. If the assertion fails, a NoPermissionError might be returned.
func (*State) ChannelCountUnreads ¶
ChanneCountUnreads returns the number of unread messages in the channel.
func (*State) ChannelIsMuted ¶
ChannelIsMuted returns true if the channel with the given ID is muted or if it's in a category that's muted.
func (*State) ChannelIsUnread ¶
func (r *State) ChannelIsUnread(chID discord.ChannelID) UnreadIndication
ChannelIsUnread returns true if the channel with the given ID has unread messages.
func (*State) Channels ¶
func (s *State) Channels(guildID discord.GuildID, allowedTypes []discord.ChannelType) ([]discord.Channel, error)
Channels returns a list of visible channels. Empty categories are automatically filtered out.
func (*State) GuildIsUnread ¶
func (r *State) GuildIsUnread(guildID discord.GuildID, types []discord.ChannelType) UnreadIndication
GuildIsUnread returns true if the guild contains unread channels.
func (*State) HasPermissions ¶
HasPermissions returns true if AssertPermissions returns a nil error.
func (*State) LastMessage ¶
LastMessage returns the last message ID in the given channel.
func (*State) MessageMentions ¶
func (s *State) MessageMentions(msg *discord.Message) MessageMentionFlags
MessageMentions returns true if the given message mentions the current user.
func (*State) Online ¶
Online returns an online state. If the state is already online, then it returns itself.
func (*State) PrivateChannels ¶
PrivateChannels returns the sorted list of private channels from the state.
func (*State) SetStatus ¶
func (r *State) SetStatus(status discord.Status, custom *gateway.CustomUserStatus, activities ...discord.Activity) error
SetStatus sets the current user's status and presence.
func (*State) Status ¶
Status returns the user's presence status. Use to check if notifications should be sent.
func (*State) UserIsBlocked ¶
UserIsBlocked returns true if the user with the given ID is blocked by the current user.
type UnreadIndication ¶
type UnreadIndication uint8
UnreadIndication indicates the channel as either unread, mentioned (which implies unread) or neither.
const ( ChannelRead UnreadIndication = iota ChannelUnread ChannelMentioned )