Post inside thread in discord

i am making an admin system. and whenever someone kicks or bans a player i either want to create a new thread with the title of the user
or post a message inside an existing thread.

creating a new thread with webhooks is easy.
but how do i figure out if a thread with a name already exist.
and if it does. post inside of it

added my code so you cna see how far i got.
i isolated this part of code from the rest and made it stand alone.

if this part works ill move on to the next

--[[

+------------------+-------------------------------------------------------------------------------+
|       tag        |                                     item                                      |
+------------------+-------------------------------------------------------------------------------+
| content          | the message contents (up to 2000 characters)                                  |
| username         | override the default username of the webhook                                  |
| avatar_url       | override the default avatar of the webhook                                    |
| tts              | true if this is a TTS message                                                 |
| embeds           | embedded rich content                                                         |
| allowed_mentions | allowed mentions for the message                                              |
| components *     | the components to include with the message                                    |
| files[n] **      | the contents of the file being sent                                           |
| payload_json **  | JSON encoded body of non-file params                                          |
| attachments **   | attachment objects with filename and description                              |
| flags            | message flags combined as a bitfield (only SUPPRESS_EMBEDS can be set)        |
| thread_name      | name of thread to create (requires the webhook channel to be a forum channel) |
+------------------+-------------------------------------------------------------------------------+
]]


return function (player,msg,otherplayer)
	if not otherplayer then
		if player ~= "Server" then
			local Data = {
				["username"] =  "["..string.format("%0.3i",player:GetRankInGroup(game.CreatorId)).."]".."["..player.UserId.."]"..player.Name;
				["content"] = msg;
			}
			Data=HttpService:JSONEncode(Data)
			local response = HttpService:PostAsync(discordUrl,Data)
		end
	else
		if player ~= "Server" then
			local Data = {
				["username"] =  "["..string.format("%0.3i",player:GetRankInGroup(game.CreatorId)).."]".."["..player.UserId.."]"..player.Name;
				["content"] = msg;
				["thread_name"] = otherplayer.UserId
			}
			Data=HttpService:JSONEncode(Data)

			local response = HttpService:PostAsync(ForumdiscordUrl,Data)

		end
	end
end

here are some options that i have tried but didnt work

basic url

local ForumdiscordUrl = "https://hooks.hyra.io/api/webhooks/[webhookId]/[webhooktoken]"

changing the url with ?thread_id

local ForumDiscordUrl = "https://hooks.hyra.io/api/webhooks/[webhookId]/[webhooktoken]?thread_id=[threadId]"

or

local ForumDiscordUrl = "https://hooks.hyra.io/api/webhooks/[webhookId]/[webhooktoken]?thread_id=$[threadId]"

adding a /

local ForumDiscordUrl = "https://hooks.hyra.io/api/webhooks/[webhookId]/[webhooktoken]/[threadId]"

adding [“thread_id”] to content

local Data = {
				["username"] =  "["..string.format("%0.3i",player:GetRankInGroup(game.CreatorId)).."]".."["..player.UserId.."]"..player.Name;
				["content"] = msg;
				["thread_id"]= ***********
			}
			Data=HttpService:JSONEncode(Data)

			local response = HttpService:PostAsync(ForumdiscordUrl,Data)
			print(response)

I do not think that hyra supports threads, but just to be you sure that hyra actually supports thread ids, why don’t we check at https://docs.hyra.io/
I currently cant because my wifi isn’t having the most fun time right now :skull: but these will 100% help

1 Like

seeing this post

you are right

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.