Server

Sending a message to discord via the server side is the preferred way.

Sending a message vis the server side can be done two ways

  1. From an export (Preferred).

  2. From an event.

Options marked (Optional) Do not have to be used, if that option is also marked (Uses Defaults) then it will use the defaults set in "Config.Defaults" if omitted.

Color is provided in "Decimal" format. Converting a HEX or RGB color to decimal is easy with a site like (https://convertingcolors.com/hex-color-EEEEEE.html?search=HEX(EEEEEE))

From an Export (Preferred)

exports['gfg_webhook']:sendToDiscord(data)
  • webhook = The webhook to use for this message (Optional) (Uses Defaults).

  • username = The username that the "bot" will use for this message (Optional) (Uses Defaults).

  • color = the color to use for this message (Optional) (Uses Defaults).

  • avatar = The profile picture the bot will use for this message (Optional) (Uses Defaults).

  • thumbnail = A small image displayed on the top right of the embed (Can be set to "true" top use the default thumbnail) (Optional).

  • image = A large image displayed on the bottom of the embed (Optional).

  • mention = Content that is sent as a regular message, useful for mentioning roles or users (Can be set to "true" to use the default mention) (Optional).

  • title = The title of the embed.

  • description = The main content of the embed (Optional).

  • fields = Customizable fields of information, useful for player, vehicle, or other specific information (Optional).

    • name = The title of the field.

    • value = the specific information of the field.

    • inline = if "true" places this field inline to the previous field if space is available (Optional).

Detailed Export Example

This is a look at a message with every option defined.

exports['gfg_webhook']:sendToDiscord(
   {
      webhook = "https://discord.com/api/webhooks/1120011382952300554/19KCBunGo1saG-o_UcqgkLhK6-d3UQeSglISNN9jy5Tr_lIFzDLhmVAt2X-6MolBMKGR",
      username = "Borat",
      color = 16776960,
      avatar = "https://i.imgur.com/lqKlotB.png",
      thumbnail = "https://i.imgur.com/lqKlotB.png",
      image = "https://i.imgur.com/i8PFAwg.jpeg",
      mention = "@borat",
      title = "Hello Discord",
      description = "This is a message!",
      fields = {
         {
            name = "First Name",
            value = "Borat",
            inline = true
         },
         {
            name = "First Name",
            value = "Sagdiyev",
            inline = true
         },
         {
            name = "Country of Origin",
            value = "Kazakhstan",
         },
      }
   }
)

This Particular usage of the export will result in a message that looks like this.

Simple Export Example

This is a look at a message with only the title option defined.

exports['gfg_webhook']:sendToDiscord(
   {
      title = "Discord Webhook is __**ONLINE**__"
   }
)

This Particular usage of the export will result in a message that looks like this.

From an Event

Very similar to the export method, instead you'll be triggering an event.

TriggerEvent('gfg_webhook:server:sendToDiscord', data)

The data follows the same premise as when using an export.

  • webhook = The webhook to use for this message (Optional) (Uses Defaults).

  • username = The username that the "bot" will use for this message (Optional) (Uses Defaults).

  • color = the color to use for this message (Optional) (Uses Defaults).

  • avatar = The profile picture the bot will use for this message (Optional) (Uses Defaults).

  • thumbnail = A small image displayed on the top right of the embed (Can be set to "true" top use the default thumbnail) (Optional).

  • image = A large image displayed on the bottom of the embed (Optional).

  • mention = Content that is sent as a regular message, useful for mentioning roles or users (Can be set to "true" to use the default mention) (Optional).

  • title = The title of the embed.

  • description = The main content of the embed (Optional).

  • fields = Customizable fields of information, useful for player, vehicle, or other specific information (Optional).

    • name = The title of the field.

    • value = the specific information of the field.

    • inline = if "true" places this field inline to the previous field if space is available (Optional).

Detailed Event Example

This is a look at a message with every option defined.

TriggerEvent('gfg_webhook:server:sendToDiscord',
   {
      webhook = "https://discord.com/api/webhooks/1120011382952300554/19KCBunGo1saG-o_UcqgkLhK6-d3UQeSglISNN9jy5Tr_lIFzDLhmVAt2X-6MolBMKGR",
      username = "Borat",
      color = 16776960,
      avatar = "https://i.imgur.com/lqKlotB.png",
      thumbnail = "https://i.imgur.com/lqKlotB.png",
      image = "https://i.imgur.com/i8PFAwg.jpeg",
      mention = "@borat",
      title = "Hello Discord",
      description = "This is a message!",
      fields = {
         {
            name = "First Name",
            value = "Borat",
            inline = true
         },
         {
            name = "First Name",
            value = "Sagdiyev",
            inline = true
         },
         {
            name = "Country of Origin",
            value = "Kazakhstan",
         },
      }
   }
)

This Particular usage of the event will result in a message that looks like this.

Simple Event Example

This is a look at a message with only the title option defined.

TriggerEvent('gfg_webhook:server:sendToDiscord',
   {
      title = "Discord Webhook is __**ONLINE**__"
   }
)

This Particular usage of the export will result in a message that looks like this.

Last updated