Discord REST API utility for FiveM and RedM.
- Easy Discord interaction from any resource.
- Promise-based asynchronous export functions.
- Actions are handled in a queue to prevent rate limiting.
-- Print "Hello, world!" in a Discord channel via a webhook
exports.discord_rest:executeWebhookUrl("https://discord.com/api/webhook/.../...", {content = "Hello, world!"})
-- Get the last 10 messages from a channel and print them
exports.discord_rest:getChannelMessages(channelId, {limit = 10}, botToken):next(function(messages)
for _, message in ipairs(messages) do
print(message.author.username .. ": " .. message.content)
end
end)
-- Get a player's name on Discord
local playerName = GetPlayerName(player)
exports.discord_rest:getUserForPlayer(player):next(function(user)
print(playerName .. " is called " .. user.username .. " on Discord")
end, function(err)
print(playerName .. " does not have Discord connected")
end)