Documentation ¶
Index ¶
- Constants
- Variables
- func BitMask[T ~int](opts, req T) bool
- func DM(s *discordgo.Session, userID string, msg *discordgo.MessageSend) (resp *discordgo.Message, err error)
- func EMessageURL(msg *discordgo.Message) string
- func GEmbed(title, desc string) *discordgo.MessageEmbed
- func GetChannel(s *discordgo.Session, channelID string) *discordgo.Channel
- func GetMember(s *discordgo.Session, guildID, userID string) *discordgo.Member
- func GetMessage(s *discordgo.Session, channelID, msgID string) *discordgo.Message
- func HasAllRoles(m *discordgo.Member, roles []string) bool
- func HasAnyRoles(m *discordgo.Member, roles []string) bool
- func HasRole(m *discordgo.Member, roleNeeded string) bool
- func IAuthor(i *discordgo.Interaction) *discordgo.User
- func IAutocomplete(s *discordgo.Session, i *discordgo.Interaction, ...) error
- func IDefer(s *discordgo.Session, i *discordgo.Interaction, opts ...InteractionOpt) error
- func IEmbed(s *discordgo.Session, i *discordgo.Interaction, emb *discordgo.MessageEmbed, ...) error
- func IError(s *discordgo.Session, i *discordgo.Interaction, errMsg string, ...) error
- func IErrorComponents(s *discordgo.Session, i *discordgo.Interaction, errMsg string, ...) error
- func IMessageAuthor(i *discordgo.Interaction) *discordgo.User
- func IModal(s *discordgo.Session, i *discordgo.Interaction, customID, title string, ...) error
- func IOwnInteraction(msg *discordgo.Message, userID string) bool
- func IResp(s *discordgo.Session, i *discordgo.Interaction, conf *IRespOpts, ...) error
- func InitEmbed(opts *Options)
- func IsMemberPremium(mem *discordgo.Member) bool
- func MemberName(mem *discordgo.Member) string
- func MessageURL(Guild, Channel, Message string) string
- func PurgeChannel(s *discordgo.Session, chanID string) error
- func SendMessage(s *discordgo.Session, channelID string, msg *discordgo.MessageSend) (resp *discordgo.Message, err error)
- func UpdateMessageWithSelf(s *discordgo.Session, i *discordgo.Interaction)
- func Username(u *discordgo.User) string
- type IRespOpts
- type InteractionOpt
- type Options
Constants ¶
const ( CHAR_CROSS = "❌" CHAR_TICK = "✅" // Empty character, used commonly for embed field names/values CHAR_ZWS = "\u200b" )
Common characters used in many bots
Variables ¶
var ( COLOR_PRIMARY = 0xad6bee COLOR_SUCCESS = 0x08dd7e COLOR_DANGER = 0xA51D2A )
var BaseEmbed = discordgo.MessageEmbed{ Title: CHAR_ZWS, Color: COLOR_PRIMARY, }
var EmptyField = &discordgo.MessageEmbedField{ Name: CHAR_ZWS, Value: CHAR_ZWS, Inline: true, }
A fully empty field that is inline
var EmptyFieldNotInline = &discordgo.MessageEmbedField{ Name: CHAR_ZWS, Value: CHAR_ZWS, Inline: false, }
A fully empty field that is not inline
var ErrEmbed func(err string) *discordgo.MessageEmbed
Functions ¶
func DM ¶
func DM(s *discordgo.Session, userID string, msg *discordgo.MessageSend) (resp *discordgo.Message, err error)
Shortcut to DMing a user (by also calling UserChannelCreate)
func EMessageURL ¶
func GEmbed ¶
func GEmbed(title, desc string) *discordgo.MessageEmbed
Generate an embed using the base embed
func HasAllRoles ¶
Returns true if the member has all the roles mentioned in argument "roles"
func HasAnyRoles ¶
Returns true if the member has any of the roles mentioned in argument "roles"
func IAuthor ¶
func IAuthor(i *discordgo.Interaction) *discordgo.User
Get the author of an interaction
func IAutocomplete ¶
func IAutocomplete(s *discordgo.Session, i *discordgo.Interaction, choices []*discordgo.ApplicationCommandOptionChoice) error
Shortcut for autocomplete response
func IDefer ¶
func IDefer(s *discordgo.Session, i *discordgo.Interaction, opts ...InteractionOpt) error
Respond to an interaction by deferring it
func IEmbed ¶
func IEmbed(s *discordgo.Session, i *discordgo.Interaction, emb *discordgo.MessageEmbed, opts ...InteractionOpt) error
Respond to an interaction with a single embed. Supports OPT_REMOVE_COMPONENTS - include it to remove components
func IError ¶
func IError(s *discordgo.Session, i *discordgo.Interaction, errMsg string, opts ...InteractionOpt) error
Respond to an interaction with an error embed. This method calls IEmbed under the hood, so OPT_REMOVE_COMPONENTS works here too. The embed is formatted using ErrEmbed
WARNING: IS_EPHEMERAL is reversed in here! That is, by default (no opts) it has IS_EPHEMERAL, but, if IS_EPHEMERAL is present, it will make it **not** ephemeral!
func IErrorComponents ¶
func IErrorComponents(s *discordgo.Session, i *discordgo.Interaction, errMsg string, components []discordgo.MessageComponent, opts ...InteractionOpt) error
Respond with an error embed and components. WARNING: IS_EPHEMERAL is reversed in here! That is, by default (no opts) it has IS_EPHEMERAL, but, if IS_EPHEMERAL is present, it will make it **not** ephemeral!
func IMessageAuthor ¶
func IMessageAuthor(i *discordgo.Interaction) *discordgo.User
Returns the author of the original interaction message Use only for buttons!
func IModal ¶
func IModal(s *discordgo.Session, i *discordgo.Interaction, customID, title string, components []discordgo.MessageComponent) error
Shortcut for modal response
func IOwnInteraction ¶
Returns true if userID is the author of the message's interaction This can be used with regular messages or, if its a button interaction, i.Message
func IResp ¶
func IResp(s *discordgo.Session, i *discordgo.Interaction, conf *IRespOpts, opts InteractionOpt) error
Respond to an interaction, the 'lowest level' of the utils that this package provides. Can auto resolve components into Action Row (so you can directly pass buttons, without the need to nest them) This supports OPT_REMOVE_COMPONENTS. if len(conf.Comps) == 0 && OPT_REMOVE_COMPONENTS && I_EDIT_RESP, then components will be removed. Argument opts is a bit mask - eg. I_EDIT_RESP | OPT_REMOVE_COMPONENTS
func IsMemberPremium ¶
func MemberName ¶
Returns the name that should be used for a member
If a nickname exists, it returns that. If not, it returns the
func SendMessage ¶
func SendMessage(s *discordgo.Session, channelID string, msg *discordgo.MessageSend) (resp *discordgo.Message, err error)
Send a message to a channel. If the channel is a news channel, auto-crosspost it.
func UpdateMessageWithSelf ¶
func UpdateMessageWithSelf(s *discordgo.Session, i *discordgo.Interaction)
Updates a message with itself. Used to fake-acknowledge an interaction.
Types ¶
type IRespOpts ¶
type IRespOpts struct { Embeds []*discordgo.MessageEmbed Comps []discordgo.MessageComponent Content *string }
type InteractionOpt ¶
type InteractionOpt int
const ( // For first-time responses, updates a message. Usually used for buttons I_UPDATE InteractionOpt = 1 << iota // For editing after a response (eg. for a defer) I_EDIT_RESP // Only applicable to some operations. Should be used in conjunction with I_EDIT to remove components OPT_REMOVE_COMPONENTS // Make the message ephemeral. Should be used with I_UPDATE OPT_EPHEMERAL )
type Options ¶
type Options struct { // This function will be called after setting all the colors. // This is a function so that you can use that to your advantage. Base func() discordgo.MessageEmbed ErrorEmbed func(err string) *discordgo.MessageEmbed ColorPrimary *int ColorSuccess *int ColorDanger *int }