How to detect a reaction from a Discord Webhook

Hello everyone! I had a question regarding Discord Webhooks. As we know, it is possible to create a discord webhook and send messages on it via Roblox HTTPService. I’ve done it many times. But I can’t seem to find the answer to my question, how can I make it react to it’s own message, and how can I detect if a user reacted to it?

I’ve looked at discord.js for some kind of answer, even though that’s JavaScript and not Luau. All I can find is sending messages and embeds.

I have looked over and over for tutorials on DevForum, Developer Hub, and YouTube but I cannot find a single thing regarding this topic. If anyone can answer this for me, it will be greatly appreciated, and thank you so, so much.

This is also my first DevForum post, so I’m kind of new to this. Thank you so much again.

-Ryan_Cruiser (NintendoSwitchRyan)

1 Like

Javascript has a method “.on”, which is basically “:Connect()”. You can use this to detect reactions.

2 Likes

Thanks! How would I implement this in my code though?

1 Like

While I am not entirely sure if this will work, you should look into discord’s API. I found an endpoint you can use to get reactions, but you’d likely have to make it a loop. Here’s what I found on getting a specific reaction on a specific message:

GetReactions Discord Endpoint

And this is the discord developer documentation, so you may be able to find something else you’re looking for:

Discord Developer Documentation

I hope this helps!

1 Like

You can use this:

Client.on("messageReactionAdd", (reactionObj,userObj) => {})
1 Like

This is my code:

function sendToDiscord(user, id, len, userID)
	local webhook = "https://discord.com/api/webhooks/875184855346978818/IG4CwqF6en7tqXC8tWxIpAB0teJagoImBrnZ02WMVz26SbpmrYgZz3gWNTixU5Fke00r"
	local data = {
		["content"] = "A user has queued a song! Link to user's profile: https://www.roblox.com/users/".. userID.. "/profile",
		["embeds"] = {{
			["title"] = "Username: ".. user,
			["color"] = 6534911,
			["fields"] = {
				{
					["name"] = "Song ID: ".. id,
					["value"] = "Song Length: ".. len.. " seconds"
				}

			}}
		}
	}

	local jsonData = http:JSONEncode(data)
	http:PostAsync(webhook, jsonData)
end

How would I add in Client.on("messageReactionAdd", (reactionObj,userObj) => {}) and convert it into Luau? Sorry, I just have no JavaScript experience.

Oh. I do not think you can do so without using JS. You will have to connect a bot to an external application.

Oh alright. Thank you for your time and help :slight_smile:

Hey, short and simply - webhooks are for sending messages only. They cannot react, delete, or do anything that a discord bot application can do.

However, you can link a Discord Bot to Roblox. There is a few tutorials for that, here is one I found by simply googling “discord bot to roblox”: Is there a way to link discord to roblox?

If you have any questions regarding bots or webhooks you can ask, I’ve made several bots in the past and I’m happy to help if you need :slight_smile:

2 Likes