Discord
How to use
Simple message example
One hook + one player
-- Creates a reusable Discord API object. In this example for the example player "John Doe".
---@type NssLibsDiscordApi
local discord_api = exports.nss_libs:getDiscordApi(
GetCurrentResourceName(),
'WEBHOOK_URL',
'USERNAME_OR_PLAYER_NAME_OR_BOT_NAME', -- E.g. as example the current player name "John Doe"
'AVATAR_URL'
)
-- Send a message in the name of the example player "John Doe"
discord_api.message('Cheese stinks!')
Citizen.Wait(1000)
-- Send another message in the name of the example player "John Doe"
discord_api.message('Cheese still stinks!')
Citizen.Wait(1000)
-- Special case for method 'message': Alternative webhook URL
-- Send another message in the name of the example player "John Doe" to a different webhook url (but the alternate
-- webhook url is only used for this message)
discord_api.message('Player loves stinking cheese!', 'ALTERNATE_WEBHOOK_URL')One webhook + multiple players
Example with modifiable embeds
Commands / Objects
exports.nss_libs:getDiscordApi(resource_name, webhook_url, username, avatar_url):NssLibsDiscordApi
exports.nss_libs:getDiscordApi(resource_name, webhook_url, username, avatar_url):NssLibsDiscordApiNssLibsDiscordApi
NssLibsDiscordApicreate(username, avatar_url, message):NssLibsDiscordRequestApi
create(username, avatar_url, message):NssLibsDiscordRequestApimessage(message, temporary_webhook_url)
message(message, temporary_webhook_url)setUsername(username)
setUsername(username)setAvatarUrl(avatar_url)
setAvatarUrl(avatar_url)setWebhookUrl(webhook_url)
setWebhookUrl(webhook_url)NssLibsDiscordRequestApi
NssLibsDiscordRequestApisetUsername(username)
setUsername(username)setAvatarUrl(avatar_url)
setAvatarUrl(avatar_url)setContent(message)
setContent(message)enableTextToSpeech()
enableTextToSpeech()addEmbed():NssLibsDiscordRequestEmbedApi
addEmbed():NssLibsDiscordRequestEmbedApisend()
send()NssLibsDiscordRequestEmbedApi
NssLibsDiscordRequestEmbedApisetTitle(title)
setTitle(title)setAuthor(name, url, icon_url)
setAuthor(name, url, icon_url)setDescription(description)
setDescription(description)setUrl(url)
setUrl(url)setColor(color)
setColor(color)setImage(url)
setImage(url)setThumbnail(url)
setThumbnail(url)setFooter(text, icon_url)
setFooter(text, icon_url)setTimestamp()
setTimestamp()addField(name, value, inline)
addField(name, value, inline)Last updated
Was this helpful?