discordrb icon indicating copy to clipboard operation
discordrb copied to clipboard

Version 3.7.0 - Message post failure

Open TickettEnterprises opened this issue 1 month ago • 5 comments

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

TickettEnterprises avatar Nov 24 '25 15:11 TickettEnterprises

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."]}

swarley avatar Nov 24 '25 15:11 swarley

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.

ltickett avatar Nov 24 '25 20:11 ltickett

Are you including the thread_id in your url by chance?

swarley avatar Nov 24 '25 20:11 swarley

Yes indeed. Should we simply remove it?

ltickett avatar Nov 24 '25 20:11 ltickett

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

swarley avatar Nov 24 '25 20:11 swarley