From bb22fa5cb4df7a0088507f281d49d51f1a11cbe3 Mon Sep 17 00:00:00 2001 From: Armin Herling Date: Sat, 15 Jul 2023 16:00:40 +0200 Subject: [PATCH 1/2] Exceptions thrown in send_temporary_message cannot be caught currently, moving send_message out of the thread fixes this --- lib/discordrb/bot.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/discordrb/bot.rb b/lib/discordrb/bot.rb index 462624a7d..5a552b835 100644 --- a/lib/discordrb/bot.rb +++ b/lib/discordrb/bot.rb @@ -418,10 +418,11 @@ def send_message(channel, content, tts = false, embeds = nil, attachments = nil, # @param message_reference [Message, String, Integer, nil] The message, or message ID, to reply to if any. # @param components [View, Array] Interaction components to associate with this message. def send_temporary_message(channel, content, timeout, tts = false, embeds = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil) + message = send_message(channel, content, tts, embeds, attachments, allowed_mentions, message_reference, components) + Thread.new do Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg" - message = send_message(channel, content, tts, embeds, attachments, allowed_mentions, message_reference, components) sleep(timeout) message.delete end From 23093477a2ec0fe0a01d9bf34b0382e3b9dde0f9 Mon Sep 17 00:00:00 2001 From: Armin Herling Date: Sat, 15 Jul 2023 16:31:51 +0200 Subject: [PATCH 2/2] Removed trailing whitespace --- lib/discordrb/bot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/bot.rb b/lib/discordrb/bot.rb index 5a552b835..b16b5eb45 100644 --- a/lib/discordrb/bot.rb +++ b/lib/discordrb/bot.rb @@ -419,7 +419,7 @@ def send_message(channel, content, tts = false, embeds = nil, attachments = nil, # @param components [View, Array] Interaction components to associate with this message. def send_temporary_message(channel, content, timeout, tts = false, embeds = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil) message = send_message(channel, content, tts, embeds, attachments, allowed_mentions, message_reference, components) - + Thread.new do Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg"