From 5b086cb2ef42f8176ee7ee061319dcee80f8cf68 Mon Sep 17 00:00:00 2001 From: Droid Date: Wed, 15 Jan 2025 15:56:48 -0500 Subject: [PATCH 1/3] message threads --- lib/discordrb/commands/command_bot.rb | 2 +- lib/discordrb/data/message.rb | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/discordrb/commands/command_bot.rb b/lib/discordrb/commands/command_bot.rb index ddf68ea37..2f315628b 100644 --- a/lib/discordrb/commands/command_bot.rb +++ b/lib/discordrb/commands/command_bot.rb @@ -274,7 +274,7 @@ def arg_check(args, types = nil, server = nil) rescue ArgumentError nil end - elsif types[i] == TrueClass || types[i] == FalseClass + elsif [TrueClass, FalseClass].include?(types[i]) if arg.casecmp('true').zero? || arg.downcase.start_with?('y') true elsif arg.casecmp('false').zero? || arg.downcase.start_with?('n') diff --git a/lib/discordrb/data/message.rb b/lib/discordrb/data/message.rb index 718a0a103..91b991b88 100644 --- a/lib/discordrb/data/message.rb +++ b/lib/discordrb/data/message.rb @@ -70,12 +70,15 @@ class Message # @return [Integer, nil] the webhook ID that sent this message, or `nil` if it wasn't sent through a webhook. attr_reader :webhook_id - # @return [Array] + # @return [Array] Interaction components for this message. attr_reader :components - # @return [Integer] flags set on the message + # @return [Integer] flags set on the message. attr_reader :flags + # @return [Channel, nil] The thread that was started from this message, or nil. + attr_reader :thread + # @!visibility private def initialize(data, bot) @bot = bot @@ -160,7 +163,10 @@ def initialize(data, bot) @components = [] @components = data['components'].map { |component_data| Components.from_data(component_data, @bot) } if data['components'] + @flags = data['flags'] || 0 + + @thread = Channel.new(data['thread'], @bot, @server) if data['thread'] end # Replies to this message with the specified content. From 034db3957e1513081983393c0371e973ae8ef650 Mon Sep 17 00:00:00 2001 From: Droid Date: Wed, 15 Jan 2025 16:23:48 -0500 Subject: [PATCH 2/3] ternerary assignment --- lib/discordrb/data/message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/data/message.rb b/lib/discordrb/data/message.rb index 91b991b88..86636210f 100644 --- a/lib/discordrb/data/message.rb +++ b/lib/discordrb/data/message.rb @@ -166,7 +166,7 @@ def initialize(data, bot) @flags = data['flags'] || 0 - @thread = Channel.new(data['thread'], @bot, @server) if data['thread'] + @thread = data['thread'] ? Channel.new(data['thread'], @bot, @server) : nil end # Replies to this message with the specified content. From 696467bc3e35ac2224640204a346a7f469f91850 Mon Sep 17 00:00:00 2001 From: Droid Date: Wed, 15 Jan 2025 17:00:54 -0500 Subject: [PATCH 3/3] hit the cache --- lib/discordrb/data/message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discordrb/data/message.rb b/lib/discordrb/data/message.rb index 86636210f..37d718402 100644 --- a/lib/discordrb/data/message.rb +++ b/lib/discordrb/data/message.rb @@ -166,7 +166,7 @@ def initialize(data, bot) @flags = data['flags'] || 0 - @thread = data['thread'] ? Channel.new(data['thread'], @bot, @server) : nil + @thread = data['thread'] ? @bot.ensure_channel(data['thread'], @server) : nil end # Replies to this message with the specified content.