Documentation ¶
Index ¶
- Constants
- Variables
- func ChannelName(ch *discord.Channel) string
- func ChannelNameFromID(ctx context.Context, id discord.ChannelID) string
- func EmojiURL(emojiID string, gif bool) string
- func InjectAvatarSize(urlstr string) string
- func InjectSize(urlstr string, size int) string
- func InjectSizeUnscaled(urlstr string, size int) string
- func InjectState(ctx context.Context, state *State) context.Context
- func NewChannelIDVariant(id discord.ChannelID) *glib.Variant
- func NewGuildIDVariant(id discord.GuildID) *glib.Variant
- func NewMessageIDVariant(id discord.MessageID) *glib.Variant
- func NewSnowflakeVariant(snowflake discord.Snowflake) *glib.Variant
- func RecipientNames(ch *discord.Channel) string
- func SanitizeEmoji(emoji string) string
- func WindowTitleFromID(ctx context.Context, id discord.ChannelID) string
- type MainThreadHandler
- type State
- func (s *State) AddHandler(fns ...any) func()
- func (s *State) AddHandlerForWidget(w gtk.Widgetter, fns ...any) func()
- func (s *State) AuthorMarkup(m *gateway.MessageCreateEvent, mods ...author.MarkupMod) string
- func (s *State) BindHandler(ctx gtkutil.Cancellable, fn func(gateway.Event), filters ...gateway.Event)
- func (s *State) BindWidget(w gtk.Widgetter, fn func(gateway.Event), filters ...gateway.Event)
- func (s *State) MemberMarkup(gID discord.GuildID, u *discord.GuildUser, mods ...author.MarkupMod) string
- func (s *State) MessagePreview(msg *discord.Message) string
- func (s *State) Offline() *State
- func (s *State) Online() *State
- func (s *State) UserIDMarkup(chID discord.ChannelID, uID discord.UserID, mods ...author.MarkupMod) string
- func (s *State) UserMarkup(gID discord.GuildID, u *discord.User, mods ...author.MarkupMod) string
- func (s *State) WithContext(ctx context.Context) *State
Constants ¶
const ( HeaderHeight = 42 HeaderPadding = 16 GuildIconSize = 48 ChannelIconSize = 32 MessageAvatarSize = 42 EmbedMaxWidth = 250 EmbedImgHeight = 300 InlineEmojiSize = 22 LargeEmojiSize = 48 StickerSize = 92 UserBarAvatarSize = 32 )
Constants for dimensions.
Variables ¶
var AllowedChannelTypes = []discord.ChannelType{ discord.GuildText, discord.GuildCategory, discord.GuildPublicThread, discord.GuildPrivateThread, discord.GuildForum, discord.GuildAnnouncement, discord.GuildAnnouncementThread, discord.GuildVoice, discord.GuildStageVoice, }
AllowedChannelTypes are the channel types that are shown.
var EmojiAttrs = textutil.Attrs( pango.NewAttrSize(32 * pango.SCALE), )
var SnowflakeVariant = glib.NewVariantType("x")
SnowflakeVariant is the variant type for a discord.Snowflake.
Functions ¶
func ChannelName ¶
ChannelName returns the channel's name in plain text.
func ChannelNameFromID ¶
ChannelNameFromID returns the channel's name in plain text from the channel with the given ID.
func InjectAvatarSize ¶
InjectAvatarSize calls InjectSize with size being 64px.
func InjectSize ¶
InjectSize injects the size query parameter into the URL. Size is automatically scaled up to 2x or more.
func InjectSizeUnscaled ¶
InjectSizeUnscaled is like InjectSize, except the size is not scaled according to the scale factor.
func InjectState ¶
InjectState injects the given state to a new context.
func NewChannelIDVariant ¶
NewChannelIDVariant creates a new ChannelID variant.
func NewGuildIDVariant ¶
NewGuildIDVariant creates a new GuildID variant.
func NewMessageIDVariant ¶
NewMessageIDVariant creates a new MessageID variant.
func NewSnowflakeVariant ¶
NewSnowflakeVariant creates a new Snowflake variant.
func RecipientNames ¶
RecipientNames formats the string for the list of recipients inside the given channel.
func SanitizeEmoji ¶
SanitizeEmoji checks if provided emoji doesn't contain extraneous variation selector codepoint NOTE: This sanitizer covers ~70% of emojis
Types ¶
type MainThreadHandler ¶
type MainThreadHandler struct {
// contains filtered or unexported fields
}
MainThreadHandler wraps a handler.Handler to run all events on the main thread.
func NewMainThreadHandler ¶
func NewMainThreadHandler(h *handler.Handler) *MainThreadHandler
NewMainThreadHandler creates a new MainThreadHandler.
func (*MainThreadHandler) AddHandler ¶
func (m *MainThreadHandler) AddHandler(handler any) func()
AddHandler adds a handler to the handler.Handler. The given handler will be called on the main thread. The returned function will remove the handler.
func (*MainThreadHandler) AddSyncHandler ¶
func (m *MainThreadHandler) AddSyncHandler(handler any) func()
AddSyncHandler is the same as [AddHandler]. It exists for compatibility.
type State ¶
type State struct { *MainThreadHandler *ningen.State }
State extends the Discord state controller.
func FromContext ¶
FromContext gets the Discord state controller from the given context.
func (*State) AddHandler ¶
AddHandler adds a handler to the state. The handler is removed when the returned function is called.
func (*State) AddHandlerForWidget ¶
AddHandlerForWidget replaces BindWidget and provides a way to bind a handler that only receives events as long as the widget is mapped. As soon as the widget is unmapped, the handler is unbound.
func (*State) AuthorMarkup ¶
AuthorMarkup renders the markup for the message author's name. It makes no API calls.
func (*State) BindHandler ¶
func (s *State) BindHandler(ctx gtkutil.Cancellable, fn func(gateway.Event), filters ...gateway.Event)
BindHandler is similar to BindWidgetHandler, except the lifetime of the handler is bound to the context.
func (*State) BindWidget ¶
BindWidget is similar to BindHandler, except it doesn't rely on contexts.
func (*State) MemberMarkup ¶
func (s *State) MemberMarkup(gID discord.GuildID, u *discord.GuildUser, mods ...author.MarkupMod) string
MemberMarkup is like AuthorMarkup but for any member inside a guild.
func (*State) MessagePreview ¶
MessagePreview renders the message into a short content string.
func (*State) UserIDMarkup ¶
func (s *State) UserIDMarkup(chID discord.ChannelID, uID discord.UserID, mods ...author.MarkupMod) string
UserIDMarkup gets the User markup from just the channel and user IDs.
func (*State) UserMarkup ¶
UserMarkup is like AuthorMarkup but for any user optionally inside a guild.