discordapi

package
v0.0.0-...-c01e7cb Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserEndpoint   = "https://discord.com/api/users/@me"
	GuildsEndpoint = "https://discord.com/api/users/@me/guilds?limit=200"

	// https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
	GIFAvatarPrefix       = "a_"
	AvatarEndpoint        = "https://cdn.discordapp.com/avatars/%s/%s.%s"     // user id, avatar id, extension.
	DefaultAvatarEndpoint = "https://cdn.discordapp.com/embed/avatars/%d.png" // user-discriminator modulo 5 (Test#1337 % 5 == 2).
	ServerIconEndpoint    = "https://cdn.discordapp.com/icons/%s/%s.%s"       // guild id, icon id, extension.
)

Variables

This section is empty.

Functions

func FetchUser

func FetchUser(ctx context.Context, token string) (user *disgord.User, guilds []*models.UserGuildResponse, err error)

FetchUser fetches the current discord user that is authenticated with the token, as well as any guilds that are a part of. Make sure to check that the user has the administrator permission in the guild, or is an owner of the guild.

func GenerateGuildIconURL

func GenerateGuildIconURL(id, icon string) string

GenerateGuildIconURL generates a discord server icon url from an icon hash.

func GenerateUserAvatarURL

func GenerateUserAvatarURL(user *disgord.User) string

GenerateUserAvatarURL parses out the discord avatar. If they don't have an avatar, use the default avatar endpoint.

func UserHasAdmin

func UserHasAdmin(user *disgord.User, guild *models.UserGuildResponse) bool

UserHasAdmin checks if a user has the administrator permission in a guild.

Types

This section is empty.

Jump to

Keyboard shortcuts

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