Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultTimeout = time.Second * 30 DefaultRetryInterval = time.Millisecond * 1500 )
Functions ¶
func ApplyRole ¶
func ApplyRole(applyCtx context.Context, session *discordgo.Session, guildID, userID, roleID uint64, add bool) (result <-chan ApplyRoleResult)
ApplyRole starts a retry loop to try to apply a role before a specified deadline.
Give this a context that can be canceled by a GUILD_MEMBER_UPDATE event pre-empting the next retry. https://discord.com/developers/docs/topics/gateway#guild-member-update
From observed behavior, we can infer that role application is an asynchronous/eventually consistent API call that sometimes fails to work on large (>5000 user) servers. So we just keep applying the role until it finally works or *we* time out trying to apply it.
Types ¶
type ApplyRoleResult ¶
type RoleUpdateTrackData ¶
type RoleUpdateTrackFunc ¶
type RoleUpdateTrackFunc func(RoleUpdateTrackData) (removeHook bool)
type RoleUpdateTracker ¶
type RoleUpdateTracker struct {
// contains filtered or unexported fields
}
func NewRoleUpdateTracker ¶
func NewRoleUpdateTracker(session *discordgo.Session) *RoleUpdateTracker
func (*RoleUpdateTracker) TrackHook ¶
func (r *RoleUpdateTracker) TrackHook(guildID, userID string, trackFunc RoleUpdateTrackFunc)
TrackHook executes a function on GUILD_MEMBER_UPDATE.
Click to show internal directories.
Click to hide internal directories.