client

package
v0.1.16-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeBasePermissions

func ComputeBasePermissions(guild discord.Guild, member discord.MemberWithUser) (p discord.Permission)

func ComputeOverwrites

func ComputeOverwrites(base discord.Permission, guild discord.Guild, member discord.MemberWithUser, overwrites discord.PermissionOverwrites) (p discord.Permission)

func ComputePermissions

func ComputePermissions(guild discord.Guild, member discord.MemberWithUser, channel discord.Channel) (p discord.Permission)

func MemberHighestRole

func MemberHighestRole(roles []discord.Role, member []snowflake.ID) discord.Role

func SortedGuildRoles

func SortedGuildRoles(roles []discord.Role) []discord.Role

func SortedMemberRoles

func SortedMemberRoles(guild []discord.Role, member []snowflake.ID) (result []discord.Role)

Types

type Creator

type Creator interface {
	Cache(c cache.Store) Creator
	Logger(log golog.Logger) Creator
	EnableAutoSharding() Creator
	ShardCount(c uint16) Creator
	Shards(c uint16, s ...uint16) Creator
	Concurrency(c int) Creator
	Intents(i ws.GatewayIntent) Creator
	Build(token string) (Session, error)
}

func New

func New() Creator

type Session

type Session interface {
	api.Client

	API() api.Client
	Events() events.SessionDispatcher
	Cache() cache.Store
	Log() golog.Logger
	ShardID(guild snowflake.ID) uint16

	Get(id uint16) Shard
	Ping() int
	Shards() []uint16
	ShardCount() uint16
	// Alive checks if shard is connected to the Discord Gateway. It is good to check when you want to make sure the cache is up-to-date.
	//
	// If no shard id is provided, then all shards of current Session instance are checked. It is not recommended in most cases.
	//
	// If gateway reach the max reconnection limit, it will wait 5 minutes before next try. Of course, you won't receive any new events you have to handle but if you have the interval jobs (or dashboard), you should be sure the specific shard is connected.
	Alive(shard ...uint16) bool
	// Unavailable checks if guild is not available due to outage or has not been loaded from lazy GUILD_CREATE events yet.
	Unavailable(id snowflake.ID) bool
	UnavailableCount() int
	FetchMembers(ctx context.Context, params ws.RequestGuildMembersParams) ([]discord.MemberWithUser, []discord.Presence, error)

	PermissionsIn(guild, channel, member snowflake.ID) (discord.Permission, error)
	SortedMemberRoles(guild, member snowflake.ID) ([]discord.Role, error)

	Shutdown()
	Start()
}

type Shard

type Shard interface {
	ws.Gateway

	Ping() int
	History() []int
	ID() uint16
	Unavailable() utils.SimpleMap[snowflake.ID, ws.UnavailableGuild]
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL