I’ve wanted a simple way to quickly send message embeds to discord. Having discord integration in your game can help in all sorts of ways. As someone who has worked with discord.js frequently, I wanted a similar functionality that discord.js message embeds provide.
Example
This example assumes that the class is a child of the script. Also, I know there is a webhook included within this, it has already been deleted in discord.
local MessageEmbed = require(script.MessageEmbed)
local fieldsToAdd = {
{"testing", "other testing"},
{"more testing", "even more testing"}
}
local embed = MessageEmbed.new("https://discordapp.com/api/webhooks/556545042198560798/Kjk3NvUGZgyWvq4vNoKg5xKgKp1K2YiQEV4uj8fvScbZVkxzO8VnpyYYiqFNU_Feqy3a")
embed:SetTitle("Test")
embed:SetDescription("more test")
embed:AddField("testing", "other testing")
embed:AddFields(fieldsToAdd)
embed:SetColor(16770680)
embed:SetFooter("created by tomspell", "https://tr.rbxcdn.com/6a63f2b5da298c220feef4294755709c/150/150/AvatarHeadshot/Png")
embed:SetImage("https://tr.rbxcdn.com/6a63f2b5da298c220feef4294755709c/150/150/AvatarHeadshot/Png")
embed:SetThumbnail("https://tr.rbxcdn.com/6a63f2b5da298c220feef4294755709c/150/150/AvatarHeadshot/Png")
embed:SetUrl("https://www.roblox.com/users/9345226/profile")
embed:PostAsync()
As you can see, this class uses the exact same methods as discord.js message embeds, and take in the exact same parameters. The only difference is when you create the message embed, you pass the webhook parameter into the function, which allows you to post the embed.
This is not meant to be used as a logging service for your game, as discord’s ToS does not allow for discord to be used as a logging service. I’d recommend using trello or even slack instead.
Has that actually ever happened before when using one of these in-game? Yes, there’s ways to prevent it if it actually has happened at one point. You could just turn off those permissions for people in your discord server with specific roles and if they do it in-game it won’t ping everyone or the channel.
If you were to use this to log everyone’s messages in-game, which I wouldn’t recommend due to discord rate limits, you could simply do this on your chatted function
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(text)
if string.match(text, "@here") or string.match(text, "@everyone") or string.match(text, "<@") then return end
-- Handle the rest of what you want to do with the player's message
end
end
Don’t use Discord as a logging service. They will suspend your API access if they catch you.
ESPECIALLY do not use it to log player chat. Someone could say something NSFW in chat, which would be automatically flagged by Discord, and… get your account terminated.
I’ll reiterate, Do not use discord as a logging service
It’s also just common sense that you don’t use an instant messenger for logging. Trello is, frankly, a better logging solution than Discord. (Doesn’t mean you should use ith though!!)
You can prevent this spam with RequestAsync. Why hasn’t anyone mentioned this useful function for rate limiting except this public Discord webhook module thread?
The intended function of the class doesn’t concern itself with rate limits. The entire goal of this project was to make a embed class similar to discord.js. If developers wish to use lots and lots of embeds very quickly, it falls upon them to add rate limits.
However, as it stands, most developers are not sending lots and lots of embeds at a very rapid pace, which reduces the need for any rate limiting on the classes’ end.
Yeah of course you could, and I’ve done that for a while now. I just made this for people who don’t want to do that, or are used to the discord.js message embed. I plan on adding most of the settings directly to the constructor in the next version I commit to github as well.
Something that got added in discord.js v12 (I think) was the ability to add multiple fields without constantly having to do :AddField(). That method is called :AddFields(). I recommend adding that to your module and passing in a table of fields as a parameter.
Discord like any other company has rate limits, you should check their Legal information and Rate-limit information as it will guide you through the information you should acknowledge before logging all actions for your Discord server. Quite frankly, yes, the embedded messages, cool system and chatting is extraordinarily great to control but to protect your account, server and members you should go with something more basic like ElliottLMz stated but go with something that can handle every-second request and chatting issues and is not logged to the company or flagged.
Sorry for the late response. Just like normal embeds, you can just drop links normally, or if you want to hyperlink text, you can use the (text)[link] format.