Skip to 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🔗

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

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}

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

Content Management Interface (CMI)🔗

CMIAfkEnterEvent.java

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

CMIAfkLeaveEvent.java

  # 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🔗

AfkStatusChangeEvent.java

  # 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🔗

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/images/0/0a/Ender_Dragon.gif/revision/latest?cb=20200819042230"
        Name: "An ender dragon has spawned!"

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

PlayerAuctionSellEvent.java

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

PlayerAuctionExpireEvent.java

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

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