Simple Webhook Module (Add file from binary data feature)

When i was searching for webhook modules today, i haven’t found any that allow attaching files from binary data, which was shocking.
so using my past webhook experience, i made one myself!

• Download

Webhook.rbxm (6.8 KB)

• Examples

- Message with script-generated Image

Basic Webhook Request
local Webhook = require(workspace.Webhook)
local PNGEncode = require(workspace.Webhook.PNGEncode)
local AssetService = game:GetService('AssetService')

local web = Webhook.new('https://discord.com/api/webhooks/ID/YOUR_TOKEN')

local EditableImage = AssetService:CreateEditableImage({Size = Vector2.new(600, 600)})
EditableImage:DrawCircle(Vector2.new(150, 450), 300, Color3.fromRGB(0, 255, 0), 0, Enum.ImageCombineType.Overwrite)
EditableImage:DrawCircle(Vector2.new(450, 450), 300, Color3.fromRGB(0, 0, 255), 0, Enum.ImageCombineType.Add)
EditableImage:DrawCircle(Vector2.new(300, 150), 300, Color3.fromRGB(255, 0, 0), 0, Enum.ImageCombineType.Add)

local encoded = PNGEncode(EditableImage:ReadPixelsBuffer(Vector2.zero, EditableImage.Size), 600, 600, 4)
web:send({
	username = 'Roblox Webhook',
	content = 'Hello world!',
	files = {
		{name = "test.png", type = "image/png", bytes = encoded, extension = "png"}
	},
	attachments = {
		{id = 0, file = {name = "test.png", bytes = encoded}, description="made using EditableImage"}
	},
	embeds = {
		{
			title = 'Beautiful colors!',
			description = 'check out these amazing colors!',
			color = 0x00ff00,
			image = {
				name = "test.png"
			},
			author = {
				icon = {name = 'test.png'},
				name = 'EditableImage',
				url = "https://create.roblox.com/docs/reference/engine/classes/EditableImage"
			},
			thumbnail = {name = 'test.png'},
			footer = {
				icon = {name = 'test.png'},
				text = 'embeds from ROBLOX'
			},
			fields = {
				{name = 'Field1', value = 'value1', inline = true},
				{name = 'Field2', value = 'value2', inline = true},
				{name = 'Field3', value = 'value3', inline = true},
			},
			timestamp = "2026-01-01T12:00:00.000Z"
		}
	}
})

- Poll

Poll Webhook Request
web:send({
	poll = {
		duration = 24,
		allow_multiselect = false,
		question = {text = "Which color is the prettiest?"},
		answers = {
			{
				poll_media = {
					text = "Purple"
				}
			},
			{
				poll_media = {
					text = "Yellow",
					emoji = {
						name = "🌞"
					}
				}
			}
		}
	}
})

Credits

credits to wyozi on github for this wonderful PNG library!

Enjoy!

1 Like