Skip to content

Commit e0e8d5b

Browse files
authored
fix get webhooks (#272)
1 parent 3defaeb commit e0e8d5b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

rest/channels.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ func (s *channelImpl) DeleteChannel(channelID snowflake.ID, opts ...RequestOpt)
7676
}
7777

7878
func (s *channelImpl) GetWebhooks(channelID snowflake.ID, opts ...RequestOpt) (webhooks []discord.Webhook, err error) {
79-
err = s.client.Do(GetChannelWebhooks.Compile(nil, channelID), nil, &webhooks, opts...)
79+
var whs []discord.UnmarshalWebhook
80+
err = s.client.Do(GetChannelWebhooks.Compile(nil, channelID), nil, &whs, opts...)
81+
if err == nil {
82+
webhooks = make([]discord.Webhook, len(whs))
83+
for i := range whs {
84+
webhooks[i] = whs[i].Webhook
85+
}
86+
}
8087
return
8188
}
8289

rest/guilds.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,14 @@ func (s *guildImpl) BeginGuildPrune(guildID snowflake.ID, guildPrune discord.Gui
239239
}
240240

241241
func (s *guildImpl) GetAllWebhooks(guildID snowflake.ID, opts ...RequestOpt) (webhooks []discord.Webhook, err error) {
242-
err = s.client.Do(GetGuildWebhooks.Compile(nil, guildID), nil, &webhooks, opts...)
242+
var whs []discord.UnmarshalWebhook
243+
err = s.client.Do(GetGuildWebhooks.Compile(nil, guildID), nil, &whs, opts...)
244+
if err == nil {
245+
webhooks = make([]discord.Webhook, len(whs))
246+
for i := range whs {
247+
webhooks[i] = whs[i].Webhook
248+
}
249+
}
243250
return
244251
}
245252

0 commit comments

Comments
 (0)