mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-19 21:32:49 +00:00
discord: Fix Channel not unmarshaling
This commit is contained in:
parent
5b328bdab0
commit
68313eb872
|
@ -24,10 +24,34 @@ func TestIntegration(t *testing.T) {
|
||||||
log.Println("API user:", u.Username)
|
log.Println("API user:", u.Username)
|
||||||
|
|
||||||
// POST with URL param and paginator
|
// POST with URL param and paginator
|
||||||
_, err = client.Guilds(100)
|
guilds, err := client.Guilds(100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Can't get guilds:", err)
|
t.Fatal("Can't get guilds:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, guild := range guilds {
|
||||||
|
if !guild.ID.IsValid() {
|
||||||
|
t.Errorf("guild %q has invalid ID", guild.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
channels, err := client.Channels(guild.ID)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to fetch channels for guild %q (%v): %v",
|
||||||
|
guild.Name, guild.ID, err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ch := range channels {
|
||||||
|
if !ch.ID.IsValid() {
|
||||||
|
t.Errorf(
|
||||||
|
"channel %q of guild %q (%v) has invalid ID",
|
||||||
|
ch.Name, guild.Name, guild.ID,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var emojisToSend = [...]discord.APIEmoji{
|
var emojisToSend = [...]discord.APIEmoji{
|
||||||
|
|
|
@ -71,9 +71,7 @@ type Channel struct {
|
||||||
|
|
||||||
func (ch *Channel) UnmarshalJSON(data []byte) error {
|
func (ch *Channel) UnmarshalJSON(data []byte) error {
|
||||||
type RawChannel Channel
|
type RawChannel Channel
|
||||||
|
if err := json.Unmarshal(data, (*RawChannel)(ch)); err != nil {
|
||||||
var newCh RawChannel
|
|
||||||
if err := json.Unmarshal(data, &newCh); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue