alerts.yml🔗
This is an advanced feature of DiscordSRV that allows you to send messages to Discord when a game event happens or when a command is run.
You will need a working knowledge of how Bukkit events work and their properties.
If you aren't sure about what you're doing here, maybe ask a developer or join our discord support server
Refer to the Bukkit API javadoc to find events & properties to use:
Helpful resources for learning how to use SpEL:
Available Placeholders🔗
Placeholders |
Explanation |
---|---|
|
server TPS |
|
formatted time |
|
formatted date |
|
if alert is for a player event, the name of the player |
|
if alert is for a player event, the ping of the player |
|
if alert is for a player event, the username of the player |
|
if alert is for a player event, the display name of the player |
|
if alert is for a player event, the username of the player without escaping discord format (for use in inline code & code block markdown) |
|
if alert is for a player event, the display name of the player without escaping discord format (for use in inline code & code block markdown) |
|
if alert is for a player event, the world the player is in |
|
if alert is for a player event, the avatar url for the player's head, otherwise, the bot's avatar url |
|
the bot's avatar url |
|
the bot's name |
|
any PlaceholderAPI placeholders, can only use player ones when alert is for a player event |
Getting a player's IP
${#player.address.address.hostAddress}
Getting a player's game mode
${#player.gameMode.name()}
Getting a player's linked Discord account ID
${#discordsrv.accountLinkManager.getDiscordId(player.uniqueId)}
Getting the online player count
${#server.onlinePlayers.size()}
Getting the status of DiscordSRV's connection to Discord
${#jda.status.name()}
Checking if a player is in a specific world
${#player.world.name == 'world_the_end'}
Checking if it's day in the world that the player is in
${#player.world.time > 0 && player.world.time < 13000}
|
the specified plugin instance, |
|
the event that's triggering the alert |
|
the Bukkit API server instance, equivalent to Bukkit#getServer |
|
the DiscordSRV plugin instance |
|
the player that the event is for, |
|
the command sender, |
|
the full command, with no leading slash, |
|
the command arguments, |
|
the command arguments as one string, |
|
the destination channel for this alert |
|
DiscordSRV's JDA instance that it uses to communicate with Discord |
Usage examples🔗
AdvancedBan🔗
- Trigger: PunishmentEvent
Channel: punishments
Embed:
Color: "#4287f5"
Author:
ImageUrl: "https://www.spigotmc.org/data/resource_icons/8/8695.jpg"
Name: "${punishment.name} was punished with reason: ${punishment.reason}"
Content Management Interface (CMI)🔗
# Send an AFK alert when someone is AFK
- Trigger: CMIAfkEnterEvent
Channel: afk
Embed:
Color: "#869600"
Author:
ImageUrl: "https://crafatar.com/avatars/${player.getUniqueId()}?overlay"
Name: '${player.displayName + " is now AFK"}'
# Send an AFK alert when someone is no longer AFK
- Trigger: CMIAfkLeaveEvent
Channel: afk
Embed:
Color: "#869600"
Author:
ImageUrl: "https://crafatar.com/avatars/${player.getUniqueId()}?overlay"
Name: '${player.displayName + " is no longer AFK"}'
Essentials🔗
# Send an AFK alert when someone is AFK / is no longer AFK
- Trigger: AfkStatusChangeEvent
Channel: afk
Embed:
Color: "#869600"
Author:
ImageUrl: "https://crafatar.com/avatars/${#event.getAffected().getUUID()}?overlay"
Name: '${#event.getAffected().getName() + " is " + (#event.value ? "now" : "no longer") + " AFK"}'
Matrix🔗
- Trigger: PlayerViolationEvent
Channel: matrix
Conditions:
- violations >= 5 # don't send events for players with < 5 violations
Embed:
Color: "#ff0000"
Author:
ImageUrl: "{embedavatarurl}"
Name: "{username} failed ${hackType.name().toLowerCase()} check | ${component} | vl:${violations} ping:${player.ping} tps:{tps}"
MythicMobs🔗
# Example alert to send a message when a MythicMobs ender dragon spawns
- Trigger: MythicMobSpawnEvent
Channel: mobs
Conditions:
- 'entity.type.name() == "ENDER_DRAGON"'
Embed:
Color: "#4b064c"
Author:
ImageUrl: "https://vignette.wikia.nocookie.net/minecraft/images/0/0a/Ender_Dragon.gif/revision/latest?cb=20200819042230"
Name: "An ender dragon has spawned!"
PlayerAuctions🔗
# Example alert to send a message when a player buys something from the auction
- Trigger: PlayerAuctionBuyEvent
Async: false
Channel: auctions
Embed:
Color: "#48f542" #Green
Author:
ImageUrl: "https://crafatar.com/avatars/${buyer.getUniqueId()}/"
Name: "${buyer.getName()} bought ${playerAuction.getItem().getType()} for $${price}"
Title:
Text: "Auction Information:"
Url: ""
Fields:
- "Buyer;${buyer.getName()};true"
- "Seller;${playerAuction.getAuctionPlayer().getName()};true"
- "Item;${itemStack.getType()};true"
- "Amount;${playerAuction.getItem().getAmount()};true"
- "Price;$${price};true"
Footer:
Text: "Auction ID: ${playerAuction.getID()}"
# Example alert to send a message when a player starts selling something from the auction
- Trigger: PlayerAuctionSellEvent
Channel: auctions
Embed:
Color: "#4287f5" #Blue
Author:
ImageUrl: "https://crafatar.com/avatars/${getSeller().getUniqueId()}/"
Name: "${seller.getName()} is selling ${playerAuction.getItem().getType()} for $${playerAuction.getPrice()}"
Title:
Text: "Auction Information:"
Url: ""
Fields:
- "Seller;${seller.getName()};true"
- "Item;${playerAuction.getItem().getType()};true"
- "Amount;${playerAuction.getItem().getAmount()};true"
- "Price;$${playerAuction.getPrice()};true"
Footer:
Text: "Auction ID: ${playerAuction.getID()}"
# Example alert to send a message when a player's item gets removed from the auction
- Trigger: PlayerAuctionExpireEvent
Channel: auctions
Conditions:
- 'playerAuction.getExpireTime() == null'
Embed:
Color: "#bf2a2a" #Red
Author:
ImageUrl: "https://crafatar.com/avatars/${getPlayerAuction().getAuctionPlayer().getUUID()}/"
Name: "${playerAuction.getAuctionPlayer().getName()} removed ${getPlayerAuction().getItem().getType()} from the Auction House."
Title:
Text: "Auction Information:"
Url: ""
Fields:
- "Owner;${playerAuction.getAuctionPlayer().getName()};true"
- "Item;${playerAuction.getItem().getType()};true"
- "Amount;${playerAuction.getItem().getAmount()};true"
- "Price;$${playerAuction.getPrice()};true"
Footer:
Text: "Auction ID: ${playerAuction.getID()}"
Purpur🔗
- Trigger: PlayerAFKEvent
Channel: afk
Embed:
Color: "#fbfb54"
Author:
ImageUrl: "{embedavatarurl}"
Name: '{username} is ${#event.isGoingAfk() ? "now" : "no longer"} AFK'
Spartan🔗
- Trigger: PlayerViolationEvent
Channel: spartan
Conditions:
- violation >= 5 # don't send events for players with < 5 violations
Embed:
Color: "#ff0000"
Author:
ImageUrl: "{embedavatarurl}"
Name: "{username} failed ${hackType.name().toLowerCase()} check | ${message} | vl:${violation} ping:${player.ping} tps:{tps}"
Command Triggers🔗
- Trigger: /gamemode
Channel: gamemode
Conditions:
- '#player.hasPermission("minecraft.command.gamemode")'
Embed:
Color: "#ff0000"
Author:
ImageUrl: "{embedavatarurl}"
Name: "{username} changed game mode to ${#args.get(0)}"
- Trigger: /me
Channel: me
Conditions:
- '#player.hasPermission("minecraft.command.me") || #player.hasPermission("essentials.me")'
Embed:
Color: "#ff0000"
Author:
ImageUrl: "{embedavatarurl}"
Name: "* {username} ${#allArgs}"
Social Spy🔗
- Trigger: [/msg, /w, /m, /pm, /emsg, /epm, /tell, /etell, /whisper, /ewhisper]
Channel: SocialSpy
Embed:
Color: "#000001"
Author:
ImageUrl: "{embedavatarurl}"
Name: "[{username}> ${#allArgs}]"
- Trigger: PlayerCommandPreprocessEvent
Channel: SocialSpy
Conditions:
- "!(#command.split(\"\\s+|$\")[0].equals(\"msg\"))" #ignores the /msg command
- "!(#command.split(\"\\s+|$\")[0].equals(\"w\"))" #ignores the /w command
- "!(#command.split(\"\\s+|$\")[0].equals(\"m\"))" #ignores the /m command
- "!(#command.split(\"\\s+|$\")[0].equals(\"pm\"))" #ignores the /pm command
- "!(#command.split(\"\\s+|$\")[0].equals(\"emsg\"))" #ignores the /emsg command
- "!(#command.split(\"\\s+|$\")[0].equals(\"epm\"))" #ignores the /epm command
- "!(#command.split(\"\\s+|$\")[0].equals(\"tell\"))" #ignores the /tell command
- "!(#command.split(\"\\s+|$\")[0].equals(\"etell\"))" #ignores the /etell command
- "!(#command.split(\"\\s+|$\")[0].equals(\"whisper\"))" #ignores the /whisper command
- "!(#command.split(\"\\s+|$\")[0].equals(\"ewhisper\"))" #ignores the /ewhisper command
- "!(#command.split(\"\\s+|$\")[0].equals(\"r\"))" #ignores the /r command
- "!(#command.split(\"\\s+|$\")[0].equals(\"er\"))" #ignores the /er command
- "!(#command.split(\"\\s+|$\")[0].equals(\"reply\"))" #ignores the /reply command
- "!(#command.split(\"\\s+|$\")[0].equals(\"ereply\"))" #ignores the /ereply command
# - "!(#command.split(\"\\s+|$\")[0].equals(\"example\"))" #ignores the /example command
Embed:
Color: "#000001"
Author:
ImageUrl: "{embedavatarurl}"
Name: '{username} issued command: /${#command}'
- Trigger: SignChangeEvent
Channel: SocialSpy
Conditions:
- 'getLine(0) + getLine(1) + getLine(2) + getLine(3) != ""'
Embed:
Color: "#000001"
Author:
ImageUrl: "https://crafatar.com/avatars/${#event.getPlayer().getUniqueId()}?overlay"
Name: '${#event.getPlayer().getName()}'
Description: |-
Coords: `[${block.getLocation().getBlockX() + ", " + block.getLocation().getBlockY() + ", " + block.getLocation().getBlockZ()}]`
```
${theLines[0]}
${theLines[1]}
${theLines[2]}
${theLines[3]}
```