bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.01k stars 796 forks source link

ChannelMessagesPinned uses wrong ratelimit bucket #712

Open riking opened 4 years ago

riking commented 4 years ago

The ChannelMessagesPinned function uses EndpointChannelMessagesPins(channelID) as its ratelimit bucket. https://github.com/bwmarrin/discordgo/blob/8416350/restapi.go#L1693

This is incorrect. The ratelimit for pins requests is shared across all channels and guilds.

I recommend replacing the bucket with a constant of "/pins/global".

riking commented 4 years ago

I wrote a small program that logs the response headers to prove this: https://github.com/riking/AutoDelete/blob/master/cmd/pinsHeaders.go

It consistently prints "X-Ratelimit-Bucket: 29438e9be9d5f3f082da200ec5a36e41" no matter what channel I request, plus:

X-Ratelimit-Limit: 1
X-Ratelimit-Remaining: 0
X-Ratelimit-Reset: <timestamp in near future>
X-Ratelimit-Reset-After: 5
riking commented 2 years ago

This is the code currently in use:

body, err = c.bot.s.RequestWithBucketID("GET", discordgo.EndpointChannelMessagesPins(c.ChannelID), nil, "/custom/pinsGlobal")