Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
Pre-Release v0.2.0a Build 0 (#12)
Browse files Browse the repository at this point in the history
* Finalization updates for pre-release

- Prefix configuration added
- Warnings finalized

* Finalized Pre-Release v0.2.0a Build 0

* Removed extra remnants of the welcome command
  • Loading branch information
AlphaSerpentis authored Aug 19, 2020
1 parent 05e58d4 commit 2203bb7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project-Lynx/src/main/java/commands/moderation/Warnings.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public boolean action(MessageChannel chn, String msg, Object misc) {
if(generatedWarnings.equals("")) {
MessageHandler.sendMessage(chn, punished.getName() + " has no logged warnings.");
} else {
MessageHandler.sendMessage(chn, "> **" + punished.getName() + "'s List of Warnings**\n\n" + generatedWarnings);
MessageHandler.sendMessage(chn, "> **List of Warnings for:** `" + punished.getAsTag() + "`\n\n" + generatedWarnings);
}

}
Expand All @@ -61,7 +61,7 @@ public String generateWarningsList(Guild gld, User usr) {
if(arr.getString(1).equals(usr.getId())) {
construct +=
"**Warning ID**: " + key +
"\n**Moderator**: " + gld.getMemberById(arr.getLong(0)) +
"\n**Moderator**: " + gld.getMemberById(arr.getLong(0)).getUser().getAsTag() + " (" + gld.getMemberById(arr.getLong(0)).getUser().getId() + ")" +
"\n**Reason**: " + arr.getString(2) + "\n\n";
}

Expand Down
65 changes: 65 additions & 0 deletions Project-Lynx/src/main/java/commands/utilities/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,35 @@
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

enum SpecialConfigs {

PREFIX("prefix", 0),
URP("urp", 1);

private String assignmentName = "DEFAULT";
private int assignmentNum = -1;

SpecialConfigs(String n, int i) {
setAssignmentName(n);
setAssignmentNum(i);
}

public String getAssignmentName() {
return assignmentName;
}
public int getAssignmentNum() {
return assignmentNum;
}

public void setAssignmentName(String assignmentName) {
this.assignmentName = assignmentName;
}
public void setAssignmentNum(int assignmentNum) {
this.assignmentNum = assignmentNum;
}

}

enum Commands {

// This will suffice for now lol
Expand Down Expand Up @@ -236,6 +265,42 @@ public boolean action(MessageChannel chn, String msg, Object misc) {
}

}

// Iterate through the special configs
for(SpecialConfigs sc: SpecialConfigs.values()) {
if(sc.getAssignmentName().equals("prefix")) {

JSONObject rawData = Data.rawJSON;
String replaceText = msg;
String parsedPrefix = null;

// Parse the prefix
try {
replaceText = replaceText.replace("configure prefix", "");
replaceText = replaceText.replace(" ", "");
parsedPrefix = replaceText;
} catch(Exception e) {
e.printStackTrace();
}

// Verify it isn't null
if(parsedPrefix == null) {
MessageHandler.sendMessage(chn, "Prefix was unable to be parsed!");
return false;
}

if(parsedPrefix.equals("")) {
MessageHandler.sendMessage(chn, "Prefix cannot be null!");
return false;
}

rawData.getJSONObject(gld.getId()).getJSONObject("srvr_config").put("prefix", parsedPrefix);

// Write the new data
if(Data.writeData(InitData.locationJSON, rawData.toString(), true, gld.getId()))
MessageHandler.sendMessage(chn, "You've configured the bot to use the new prefix of " + parsedPrefix);
}
}

return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Project-Lynx/src/main/java/init/InitData.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public class InitData {
/*
* Use this to define the version
*/
public static String version = "0.2.0a (unfinished) - The Rewrite Update";
public static String version = "Pre-Release v0.2.0a Build 0 - The Rewrite Update";

}
12 changes: 3 additions & 9 deletions resources/guildData.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"DEFAULT": {
{
"DEFAULT": {
"cmds_config": {
"warn": {
"roleIDs": [],
Expand Down Expand Up @@ -28,13 +29,6 @@
"active": true,
"logging": false
},
"welcome": {
"roleIDs": [],
"tier_level": 0,
"userIDs": [],
"active": false,
"logging": false
},
"ban": {
"roleIDs": [],
"tier_level": 0,
Expand All @@ -45,7 +39,6 @@
},
"srvr_config": {
"prefix": "!",
"welcome": false,
"user_raid_prot": {
"active": true,
"user_moving_avg": 0,
Expand All @@ -59,3 +52,4 @@
"logging_channel": null
}
}
}

0 comments on commit 2203bb7

Please sign in to comment.