Version 3.7.0 - Message post failure
Summary
Post the version upgrade, when trying to post a message to a channel in our Discord server.
using the following code:
client = Discordrb::Webhooks::Client.new(url: {url})
client.execute do |builder|
builder.content = discord_message
end
We get the following error:
RestClient::AbstractResponse#exception_with_response': 400 Bad Request (RestClient::BadRequest)
Discordrb version:
3.7.0
Could you possibly give me the response body from your 400?
For example
[10] pry(main)> begin
[10] pry(main)> client.execute do |builder|
[10] pry(main)> builder.content = 'foo' * 1000
[10] pry(main)> end
[10] pry(main)> rescue Exception => e
[10] pry(main)> puts e.response.to_s
[10] pry(main)> end
{"content": ["Must be 2000 or fewer in length."]}
Hey @swarley 👋
The error response is:
{"thread_id": ["Value \"REDACTED?wait=false\" is not snowflake."]}
I redacted the id in case it's some kind of secret.
Are you including the thread_id in your url by chance?
Yes indeed. Should we simply remove it?
We introduced functionality in 3.7 that allows for passing thread_id during execute so you can do it that way, but I've also opened a PR that will handle this gracefully.
If you wanted to migrate it would look like this
client = Discordrb::Webhooks::Client.new(url: ...)
client.execute(thread_id: ...) do |builder|
builder.content = 'foo'
end