Can you send a Message through a Discord Bot using Lua, if so, how?

Hello!
I am creating a Report System, and I use Discord Webhooks as of now.
However, I feel that sending it by my Discord Bot would look more professional, and better.
Is there a way I can send a Message through a Discord Bot? (And as the Titles Asks…) If so, how?
I do not need Hosting, I have a Hoster available (Python & Node.js Files).

Thanks, AridOats.

Well I’d suggest using a Discord webhook instead of a bot since it is more simpler. Also I don’t think this is the right category.

For example:

local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
 
local webhook = "Webhook link"
 
Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(Function(msg)
local data={
    content = msg;
    username = plr.Name
    avatar_url="http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId" .. plr.UserId
}
HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
    end)
end)
1 Like

You would need to setup an API with your bot that you can send a request to that triggers a message to be sent.

Ok! Thanks! I’ll take a look into it!

1 Like

OFC a Webhook is easier, but I want to go the Extra Mile and have a Bot, as they are more Secure. I also want it to look professional, as said, and I think a Discord Bot would look better than a Webhook.

you shouldnt use discord bot for report system, they have limit of 5 message/5s (per-channel).

I don’t have any Powerful or Big Games, so I don’t expect many Requests, and it reports problems with a Script, not Players, so it cannot be spammed; it reports, then shuts down the script. And Webhooks also have limits too.

If you specifically don’t want to use a webhook and use a bot you can check out my guide on using the Discord REST API through Roblox which has an example for sending a bot message.

2 Likes

Yeah just use a webhook to discord

You could just mimic the webhook to look like the bot It’s not like bots can send messageTypes the webhook can’t send. Also it is much simpler.

This may be perfect! TYSM! Just what I wanted. Have the solution!

Here I will show you go to discord and make a server. Next go to edit channel (general) and go to Integration. Their you will find “webhook” so you click “new webhook” then you can custom your webhook. My my is “hamster” at the button their is copy webhook url. The one I made is https://discord.com/api/webhooks/792100260889100308/ZHj4r8HfJR_X9zDR0NkD0hmryosAuJYXAfUr4GnMumjDGP5-v-bOAcmhrEnol0AS93Ke. After that you make a script on roblox studio connect discord to roblox. You can create a function on roblox and depending what function you made it will go genral in discord where you can see. Such as chat function here a vid to show you (2021) How to make CUSTOM DISCORD MESSAGE EVENTS! (Roblox Studio) - YouTube

Btw the way put on httpsservice