Skip to content

Commit

Permalink
minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 28, 2020
1 parent fe6b042 commit b8463ae
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/main/java/com/denizenscript/ddiscordbot/DiscordCommand.java
Expand Up @@ -120,9 +120,8 @@ public enum DiscordInstruction { CONNECT, DISCONNECT, MESSAGE, ADD_ROLE, REMOVE_

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
// Interpret arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

for (Argument arg : scriptEntry.getProcessedArgs()) {
if (!scriptEntry.hasObject("id")
&& arg.matchesPrefix("id")) {
scriptEntry.addObject("id", new ElementTag(CoreUtilities.toLowerCase(arg.getValue())));
Expand Down Expand Up @@ -179,12 +178,9 @@ else if (!scriptEntry.hasObject("message")) {
}
}

// Check for required information
if (!scriptEntry.hasObject("id")) {
throw new InvalidArgumentsException("Must have an ID!");
}

// Check for required information
if (!scriptEntry.hasObject("instruction")) {
throw new InvalidArgumentsException("Must have an instruction!");
}
Expand Down Expand Up @@ -227,8 +223,6 @@ public void run() {

@Override
public void execute(ScriptEntry scriptEntry) {

// Fetch required objects
ElementTag id = scriptEntry.getElement("id");
ElementTag instruction = scriptEntry.getElement("instruction");
ElementTag code = scriptEntry.getElement("code"); // Intentionally do not debug this value.
Expand All @@ -242,18 +236,19 @@ public void execute(ScriptEntry scriptEntry) {
ElementTag url = scriptEntry.getElement("url");
ElementTag messageId = scriptEntry.getElement("message_id");

// Debug the execution
Debug.report(scriptEntry, getName(), id.debug()
+ (channel != null ? channel.debug(): "")
+ instruction.debug()
+ (message != null ? message.debug(): "")
+ (user != null ? user.debug(): "")
+ (guild != null ? guild.debug(): "")
+ (role != null ? role.debug(): "")
+ (status != null ? status.debug(): "")
+ (activity != null ? activity.debug(): "")
+ (url != null ? url.debug(): "")
+ (messageId != null ? messageId.debug(): ""));
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), id.debug()
+ (channel != null ? channel.debug() : "")
+ instruction.debug()
+ (message != null ? message.debug() : "")
+ (user != null ? user.debug() : "")
+ (guild != null ? guild.debug() : "")
+ (role != null ? role.debug() : "")
+ (status != null ? status.debug() : "")
+ (activity != null ? activity.debug() : "")
+ (url != null ? url.debug() : "")
+ (messageId != null ? messageId.debug() : ""));
}

DiscordClient client;

Expand Down

0 comments on commit b8463ae

Please sign in to comment.