Minecraft Discord Messenger [1.13 - 1.21] icon

Minecraft Discord Messenger [1.13 - 1.21] -----

Script for sending messages to Discord via Webhook URL written in Skript



[​IMG]

Hello, Minecraft community!
I present to your attention a script written in Skript for sending messages to Discord via a webhook URL.
You can generate messages in JSON format and send them to the webhook of the URL Discord channel.​


[​IMG]

The script has two main functions.
The first one generates a message in JSON format, and the second one sends this message to the Discord channel.​

1. Function prepareDiscordMessage
Function to format message in JSON format.

Parameters:
● avatarUrl: Avatar for Discord bot
● botUsername: Username for Discord bot
embedTitle: Embed title
embedDescription: Embed description
embedFooter: Footer text
embedColor: Embed color

Usage example:
An example of the result of formatting a message for further sending as a message to the Discord channel.
Code (Text):
set {_discordMessage} to prepareDiscordMessage(BotAvatar(), BotUsername(), "%event-player% has joined the server", "The player **%event-player%** has joined the server.", FooterText(), GreenColor())
Result:

Code (Text):
'{ ""embeds"": [{ ""title"": ""CHYZHOV has joined the server"", ""description"": ""The player **CHYZHOV** has joined the server."", ""color"": 3066993, ""footer"": { ""text"": ""Date of action execution: 02.11.2024, 02:49"" } }], ""username"": ""System alert"", ""avatar_url"": ""https://cdn.discordapp.com/attachments/1014147200701435965/1294052865836318791/star-fall-svgrepo-com.png?ex=6714d0e5&is=67137f65&hm=aecc0259e4c8eda035b42ac9b414ea87c6d1d7e82a23fa21a3519273ef64ded3&"" }'


2. Function sendDiscordMessage
Function for sending messages to the Discord channel.

Parameters:
● message:
Message in JSON format
● channel: Channel webhook URL

Usage example:

When a player joins a server, a message will be sent to the Discord channel about it.
Code (Text):
on join:
  set {_discordMessage} to prepareDiscordMessage(BotAvatar(), BotUsername(), "%event-player% has joined the server", "The player **%event-player%** has joined the server.", FooterText(), GreenColor())
  sendDiscordMessage({_discordMessage}, Channel())
Result:
The message was sent to the Discord channel.

[​IMG]


[​IMG]

For more convenient use of the script, you can use such functions as those listed below.
Override the values in the functions below.​

1. Bot avatar
Specify a link to the bot's avatar, which will be displayed in the discord message.
Code (Text):
function BotAvatar() :: string:
  return "https://cdn.discordapp.com/attachments/1014147200701435965/1294052865836318791/star-fall-svgrepo-com.png?ex=6714d0e5&is=67137f65&hm=aecc0259e4c8eda035b42ac9b414ea87c6d1d7e82a23fa21a3519273ef64ded3&"
2. Bot username
The name of the bot will be displayed in the discord message.
Code (Text):
function BotUsername() :: string:
  return "System alert"
3. Footer text
The text will be displayed in the footer of the Discord message.
Code (Text):
function FooterText() :: string:
  return "Date of action execution: %now%"
4. Red color
The color code variant for the embed in the Discord message.
Code (Text):
function RedColor() :: integer:
  return 13458524
5. Yellow color
The color code variant for the embed in the Discord message.
Code (Text):
function YellowColor() :: integer:
  return 15844367
6. Green color
The color code variant for the embed in the Discord message.
Code (Text):
function GreenColor() :: integer:
  return 3066993
7. Channel
Link to the webhook of the URL channel to which the message will be sent.
Code (Text):
function Channel() :: string:
  return "https://discord.com/api/webhooks/your_webhook"

[​IMG]

Please pay attention to this information!
For the script to work, you need to install some plugins.​

1. Skript - https://www.spigotmc.org/resources/skript.114544/
2. skript reflect - https://www.spigotmc.org/resources/skript-reflect.82259/
Resource Information
Author:
----------
Total Downloads: 51
First Release: Nov 2, 2024
Last Update: Nov 2, 2024
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings