Documentation ¶
Index ¶
- Constants
- func FetchUser(ctx context.Context, token string) (user *disgord.User, guilds []*models.UserGuildResponse, err error)
- func GenerateGuildIconURL(id, icon string) string
- func GenerateUserAvatarURL(user *disgord.User) string
- func UserHasAdmin(user *disgord.User, guild *models.UserGuildResponse) bool
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 ¶
GenerateGuildIconURL generates a discord server icon url from an icon hash.
func GenerateUserAvatarURL ¶
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.
Click to show internal directories.
Click to hide internal directories.