tools/module/discord/guild-icon.go
2022-03-28 21:22:34 +01:00

18 lines
423 B
Go

package discord
import (
"bytes"
"github.com/bwmarrin/discordgo"
"image"
)
func getGuildIcon(s *discordgo.Session, guild *discordgo.UserGuild) (image.Image, error) {
body, err := s.RequestWithBucketID("GET", discordgo.EndpointGuildIcon(guild.ID, guild.Icon), nil, discordgo.EndpointGuildIcon(guild.ID, ""))
if err != nil {
return nil, nil
}
img, _, err := image.Decode(bytes.NewReader(body))
return img, err
}