Skip to main content

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

PlaceholdersExplanation
{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

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}

Usage examples

AdvancedBan

PunishmentEvent.java

  - 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

warning

Requires the LuckPermsAlerts plugin

NodeAddEvent.java

# 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()}`"

Content Management Interface (CMI)

CMIAfkEnterEvent.java

# 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"}'

Discord

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 :)"

DiscordSRV

AccountLinkedEvent.java

  - 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

Essentials

AfkStatusChangeEvent.java

# 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.java

  - 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.java

# 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.java

# 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.java

# 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()}"

Purpur

PlayerAFKEvent

  - Trigger: PlayerAFKEvent
Channel: afk
Embed:
Color: "#fbfb54"
Author:
ImageUrl: "{embedavatarurl}"
Name: '{username} is ${#event.isGoingAfk() ? "now" : "no longer"} AFK'

Spartan

PlayerViolationEvent.java

  - 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)}"

Social Spy

  - Trigger: [/msg, /w, /m, /pm, /emsg, /epm, /tell, /etell, /whisper, /ewhisper]
Channel: SocialSpy
Embed:
Color: "#000001"
Author:
ImageUrl: "{embedavatarurl}"
Name: "[{username}> ${#allArgs}]"