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 |
---|---|
{tps} | server TPS |
{time} | formatted time |
{date} | formatted date |
{name} | if alert is for a player event, the name of the player |
{ping} | if alert is for a player event, the ping of the player |
{username} | if alert is for a player event, the username of the player |
{displayname} | if alert is for a player event, the display name of the player |
{usernamenoescapes} | if alert is for a player event, the username of the player without escaping discord format (for use in inline code & code block markdown) |
{displaynamenoescapes} | 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) |
{world} | if alert is for a player event, the world the player is in |
{embedavatarurl} | if alert is for a player event, the avatar url for the player's head, otherwise, the bot's avatar url |
{botavatarurl} | the bot's avatar url |
{botname} | the bot's name |
%placeholder% | any PlaceholderAPI placeholders, can only use player ones when alert is for a player event |
- SpEL Examples
- SpEL Placeholders
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}
SpEL Placeholders | Explanation |
---|---|
#plugins.<plugin> | the specified plugin instance, null if doesn't exist |
#event | the event that's triggering the alert if this alert is an event alert |
#server | the Bukkit API server instance, equivalent to Bukkit#getServer |
#discordsrv | the DiscordSRV plugin instance |
#player | the player that the event is for, if this is a player event or command |
#sender | the command sender, if this is a command alert |
#command | the full command, with no leading slash, if this is a command alert |
#args | the command arguments, if this is a command alert |
#allArgs | the command arguments as one string, if this is a command alert |
#channel | the destination channel for this alert |
#jda | DiscordSRV's JDA instance that it uses to communicate with Discord |
Usage examples
AdvancedBan
- PunishmentEvent
- 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}"
LuckPerms
Requires the LuckPermsAlerts plugin
- NodeAddEvent (Permission)
- NodeAddEvent (Group)
# Example alert to send a message when a permission has been added or removed from a player
- Trigger: LPNodeAddEvent
Channel: global
Conditions:
- "#event.getEvent().getNode().getType() == 'PERMISSION'"
- "#event.getEvent().isUser()"
Embed:
Title: "Player's permissions changed"
Color: "#00ff00"
Description: "`${#event.getEvent().getTarget().getFriendlyName()}` has had the permission `${#event.getEvent().getNode().getPermission()}` set to `${#event.getEvent().getNode().getValue()}`"
# Example alert to send a message when a rank has been added or removed from a player
- Trigger: LPNodeAddEvent
Channel: global
Conditions:
- "#event.getEvent().getNode().getType() == 'INHERITANCE'"
- "#event.getEvent().isUser()"
Embed:
Title: "Player's groups changed"
Color: "#00ff00"
Description: "`${#event.getEvent().getTarget().getFriendlyName()}` has had the group `${#event.getEvent().getNode().getGroupName()}` set to `${#event.getEvent().getNode().getValue()}`"
Content Management Interface (CMI)
- CMIAfkEnterEvent
- CMIAfkLeaveEvent
# Send an AFK alert when someone is AFK
- Trigger: CMIAfkEnterEvent
Channel: afk
Embed:
Color: "#869600"
Author:
ImageUrl: "https://crafthead.net/helm/${player.getUniqueId()}"
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://crafthead.net/helm/${player.getUniqueId()}"
Name: '${player.displayName + " is no longer AFK"}'
Discord
- GuildMemberUpdateBoostTimeEvent (Boosting)
- GuildMemberUpdateBoostTimeEvent (Not Boosting)
GuildMemberUpdateBoostTimeEvent.java
- Trigger: GuildMemberUpdateBoostTimeEvent
Channel: boosters
Conditions:
- '#event.getOldTimeBoosted() == null'
- '#event.getNewTimeBoosted() != null'
Embed:
Color: "#00ff00"
Author:
ImageUrl: "{embedavatarurl}"
Name: "${member.getEffectiveName()} started boosting the server :)"
GuildMemberUpdateBoostTimeEvent.java
- Trigger: GuildMemberUpdateBoostTimeEvent
Channel: boosters
Conditions:
- '#event.getOldTimeBoosted() != null'
- '#event.getNewTimeBoosted() == null'
Embed:
Color: "#00ff00"
Author:
ImageUrl: "{embedavatarurl}"
Name: "${member.getEffectiveName()} is no longer boosting the server :("
DiscordSRV
- AccountLinkedEvent
- AccountUnlinkedEvent
- Trigger: AccountLinkedEvent
Channel: linked
Embed:
Enabled: true
Color: "#ffffff"
Author:
ImageUrl: "{embedavatarurl}"
Name: "User '${#event.getPlayer().getName()}' linked their account with the discord user '${#event.getUser().getAsTag()}'" # This message will show the users ingame name, not their nickname (for clarification) and the username from discord as well as their #Tag number.
Timestamp: true
- Trigger: AccountUnlinkedEvent
Channel: linked
Embed:
Enabled: true
Color: "#ffffff"
Author:
ImageUrl: "{embedavatarurl}"
Name: "User '${#event.getPlayer().getName()}' unlinked their account from the discord user '${#event.getDiscordUser().getAsTag()}'"
Timestamp: true
Essentials
- AfkStatusChangeEvent
# Send an AFK alert when someone is AFK / is no longer AFK
- Trigger: AfkStatusChangeEvent
Channel: afk
Embed:
Color: "#869600"
Author:
ImageUrl: "https://crafthead.net/helm/${#event.getAffected().getUUID()}"
Name: '${#event.getAffected().getName() + " is " + (#event.value ? "now" : "no longer") + " AFK"}'
Matrix
- PlayerViolationEvent
- 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
- MythicMobSpawnEvent
# 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/assets/0/0a/Ender_Dragon.gif/revision/latest?cb=20200819042230"
Name: "An ender dragon has spawned!"
NuVotifier (Votifier)
- VotifierEvent
# Example alert to send a message when a player has voted
- Trigger: VotifierEvent
Channel: votes
Embed:
Color: "#00ff00"
Author:
ImageUrl: "{embedavatarurl}"
Name: "${vote.username} voted on ${vote.serviceName}!"
PlayerAuctions
- PlayerAuctionBuyEvent
- PlayerAuctionSellEvent
- PlayerAuctionExpireEvent
# 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://crafthead.net/helm/${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://crafthead.net/helm/${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://crafthead.net/helm/${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
- PlayerAFKEvent
- Trigger: PlayerAFKEvent
Channel: afk
Embed:
Color: "#fbfb54"
Author:
ImageUrl: "{embedavatarurl}"
Name: '{username} is ${#event.isGoingAfk() ? "now" : "no longer"} AFK'
Spartan
- PlayerViolationEvent
- 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
- /gamemode
- /me
- 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
- Private messages
- Commands
- Sign placement
- 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://crafthead.net/helm/${#event.getPlayer().getUniqueId()}"
Name: '${#event.getPlayer().getName()}'
Description: |-
Coords: `[${block.getLocation().getBlockX() + ", " + block.getLocation().getBlockY() + ", " + block.getLocation().getBlockZ()}]`
```
${getLine(0)}
${getLine(1)}
${getLine(2)}
${getLine(3)}
```