Skip to content

Commit

Permalink
add discord.exists tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 15, 2019
1 parent 9b152c9 commit cec02ca
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/java/com/denizenscript/ddiscordbot/dDiscordBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.DenizenCore;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.ObjectFetcher;
import net.aufdemrand.denizencore.objects.TagRunnable;
import net.aufdemrand.denizencore.tags.Attribute;
Expand Down Expand Up @@ -67,11 +68,30 @@ public void discordTagBase(ReplaceableTagEvent event) {
bot = dDiscordConnection.valueOf(event.getNameContext(), event.getAttributes().context);
}

if (bot == null) {
Attribute attribute = event.getAttributes().fulfill(1);

// <--[tag]
// @attribute <discord[<bot-id>].exists>
// @returns Element(Boolean)
// @plugin dDiscordBot
// @description
// Returns whether a Discord bot exists with the given bot ID.
// -->
if (attribute.startsWith("exists")) {
event.setReplacedObject(CoreUtilities.autoAttrib(new Element(bot != null), attribute.fulfill(1)));
return;
}

Attribute attribute = event.getAttributes();
event.setReplacedObject(CoreUtilities.autoAttrib(bot, attribute.fulfill(1)));
// <--[tag]
// @attribute <discord[<bot-id>]>
// @returns Discord
// @plugin dDiscordBot
// @description
// Returns the Discord bot for the given bot ID.
// -->
if (bot == null) {
return;
}
event.setReplacedObject(CoreUtilities.autoAttrib(bot, attribute));
}
}

0 comments on commit cec02ca

Please sign in to comment.