Overview | EssentialsC | DiscordApi
net.godlycow.org.essc.api

Interface DiscordApi

public interface DiscordApi

API interface for interacting with EssentialsC's DiscordSRV integration. Lets external plugins push event embeds to the configured Discord punishment channel through EssentialsC's existing DiscordSRV connection. All send methods are no-ops if DiscordSRV is not hooked.

Retrieve an instance via EssentialsCAPI.getDiscordApi().

DiscordApi discord = APIProvider.getAPI().getDiscordApi();

if (discord.isHooked()) {
    discord.sendBanEmbed(
        player.getUniqueId(), player.getName(),
        "Cheating", "AdminName", -1L   // -1 = permanent
    );
}

Method Summary

boolean isHooked()
Returns whether the DiscordSRV hook is fully established and ready.
void sendBanEmbed(UUID targetUUID, String targetName, String reason, String banner, long expires)
Sends a ban notification embed to the configured Discord channel.
void sendKickEmbed(UUID targetUUID, String targetName, String reason, String kicker)
Sends a kick notification embed to the configured Discord channel.
void sendMuteEmbed(UUID targetUUID, String targetName, String reason, String muter, long expires)
Sends a mute notification embed to the configured Discord channel.
void sendHomeSetEmbed(UUID playerUUID, String playerName, String homeName, String worldName, int homeCount, int maxHomes)
Sends a home-set notification embed to the configured Discord channel.
void sendHomeDeleteEmbed(UUID playerUUID, String playerName, String homeName, int remainingHomes, int maxHomes)
Sends a home-deleted notification embed to the configured Discord channel.
Method Detail
public boolean isHooked()

Returns whether the DiscordSRV hook is fully established and the JDA instance is available.

This is false if DiscordSRV is not installed, if the Discord bot has not yet connected, or if DiscordSRV integration is disabled in the EssentialsC config. All send* methods silently do nothing when this returns false.

Returns:
booleantrue if DiscordSRV is connected and ready to send messages
public void sendBanEmbed(UUID targetUUID, String targetName, String reason, String banner, long expires)

Sends a ban notification embed to the configured Discord punishments channel. Has no effect if isHooked() is false.

Parameters:
targetUUIDthe UUID of the banned player; must not be null
targetNamethe name of the banned player; must not be null
reasonthe ban reason displayed in the embed; must not be null
bannerthe name of the staff member or console who issued the ban; must not be null
expiresthe Unix timestamp (milliseconds) when the ban expires, or -1 for permanent
public void sendKickEmbed(UUID targetUUID, String targetName, String reason, String kicker)

Sends a kick notification embed to the configured Discord punishments channel. Has no effect if isHooked() is false.

Parameters:
targetUUIDthe UUID of the kicked player; must not be null
targetNamethe name of the kicked player; must not be null
reasonthe kick reason displayed in the embed; must not be null
kickerthe name of the staff member or console who issued the kick; must not be null
public void sendMuteEmbed(UUID targetUUID, String targetName, String reason, String muter, long expires)

Sends a mute notification embed to the configured Discord punishments channel. Has no effect if isHooked() is false.

Parameters:
targetUUIDthe UUID of the muted player; must not be null
targetNamethe name of the muted player; must not be null
reasonthe mute reason displayed in the embed; must not be null
muterthe name of the staff member or console who issued the mute; must not be null
expiresthe Unix timestamp (milliseconds) when the mute expires, or -1 for permanent
public void sendHomeSetEmbed(UUID playerUUID, String playerName, String homeName, String worldName, int homeCount, int maxHomes)

Sends a home-set notification embed to the configured Discord channel. Has no effect if isHooked() is false.

Parameters:
playerUUIDthe UUID of the player who set the home; must not be null
playerNamethe name of the player; must not be null
homeNamethe name given to the new home; must not be null
worldNamethe name of the world the home was set in; must not be null
homeCountthe player's total number of homes after setting this one
maxHomesthe player's current home limit
public void sendHomeDeleteEmbed(UUID playerUUID, String playerName, String homeName, int remainingHomes, int maxHomes)

Sends a home-deleted notification embed to the configured Discord channel. Has no effect if isHooked() is false.

Parameters:
playerUUIDthe UUID of the player who deleted the home; must not be null
playerNamethe name of the player; must not be null
homeNamethe name of the home that was deleted; must not be null
remainingHomesthe number of homes the player has left after the deletion
maxHomesthe player's current home limit