-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ charinfo command. + editChar command. * list chars can now show other people's characters if you mention the user * Various bug fixes. ! Updated Lib version to fix major issues with the $role commands.
- Loading branch information
1 parent
9df0477
commit cbd7516
Showing
31 changed files
with
1,090 additions
and
498 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
...ub_austinv11_Discord4j_shaded_5213b02.xml → ...ub_austinv11_Discord4j_shaded_ef410ed.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package Commands.Characters; | ||
|
||
import Commands.Command; | ||
import Commands.CommandObject; | ||
import Main.Utility; | ||
import Objects.CharacterObject; | ||
import Objects.RoleTypeObject; | ||
import sx.blah.discord.handle.obj.IRole; | ||
import sx.blah.discord.handle.obj.Permissions; | ||
import sx.blah.discord.util.EmbedBuilder; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharInfo implements Command { | ||
@Override | ||
public String execute(String args, CommandObject command) { | ||
for (CharacterObject object: command.characters.getCharacters()){ | ||
if (object.getName().equalsIgnoreCase(args)){ | ||
EmbedBuilder builder = new EmbedBuilder(); | ||
builder.withTitle(object.getNickname()); | ||
|
||
ArrayList<IRole> roles = new ArrayList<>(); | ||
ArrayList<String> roleNames = new ArrayList<>(); | ||
for (RoleTypeObject role : object.getRoles()){ | ||
roles.add(command.client.getRoleByID(role.getRoleID())); | ||
roleNames.add(command.client.getRoleByID(role.getRoleID()).getName()); | ||
} | ||
if (roles.size() > 0) { | ||
builder.withColor(Utility.getUsersColour(roles, command.guild)); | ||
}else { | ||
builder.withColor(Utility.getUsersColour(command.client.getOurUser(),command.guild)); | ||
} | ||
|
||
String description = ""; | ||
description += "Age: " + object.getAge(); | ||
description += "\nGender: " + object.getGender(); | ||
description += "\n" + Utility.listFormatter(roleNames,true); | ||
description += "\nBio: " + object.getShortBio(); | ||
if (object.getLongBioURL() != null && !object.getLongBioURL().isEmpty()) { | ||
description += "\n\n[Long Description Link...](" + object.getLongBioURL() + ")"; | ||
} | ||
builder.withDesc(description); | ||
if (object.getAvatarURL() != null && !object.getAvatarURL().isEmpty()) { | ||
builder.withThumbnail(object.getAvatarURL()); | ||
} | ||
Utility.sendEmbededMessage("",builder.build(),command.channel); | ||
return null; | ||
} | ||
} | ||
return "> Character with that name not found."; | ||
} | ||
|
||
@Override | ||
public String[] names() { | ||
return new String[]{"CharInfo","InfoChar"}; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Gives Information about a certain character."; | ||
} | ||
|
||
@Override | ||
public String usage() { | ||
return "[Character name]"; | ||
} | ||
|
||
@Override | ||
public String type() { | ||
return TYPE_CHARACTER; | ||
} | ||
|
||
@Override | ||
public String channel() { | ||
return CHANNEL_BOT_COMMANDS; | ||
} | ||
|
||
@Override | ||
public Permissions[] perms() { | ||
return new Permissions[0]; | ||
} | ||
|
||
@Override | ||
public boolean requiresArgs() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean doAdminLogging() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String dualDescription() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String dualUsage() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String dualType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Permissions[] dualPerms() { | ||
return new Permissions[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package Commands.Characters; | ||
|
||
import Commands.Characters.EditModes.*; | ||
import Commands.Command; | ||
import Commands.CommandObject; | ||
import Main.Utility; | ||
import Objects.CharacterObject; | ||
import Objects.SplitFirstObject; | ||
import sx.blah.discord.handle.obj.Permissions; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class EditChar implements Command { | ||
@Override | ||
public String execute(String args, CommandObject command) { | ||
SplitFirstObject charName = new SplitFirstObject(args); | ||
if (charName.getRest() == null || charName.getRest().isEmpty()){ | ||
return "> Mode Not Specified"; | ||
} | ||
SplitFirstObject mode = new SplitFirstObject(charName.getRest()); | ||
for (CharacterObject c: command.characters.getCharacters()){ | ||
if (c.getName().equalsIgnoreCase(charName.getFirstWord())){ | ||
if (c.getUserID().equals(command.authorID) || Utility.canBypass(command.author,command.guild)){ | ||
if (mode.getRest() == null || mode.getRest().isEmpty()){ | ||
return "> Missing Arguments for Editing."; | ||
} | ||
switch (mode.getFirstWord().toLowerCase()){ | ||
case "age": | ||
return CharAge.execute(mode.getRest(),c); | ||
case "gender": | ||
return CharGender.execute(mode.getRest(),c); | ||
case "avatar": | ||
return CharAvatar.execute(mode.getRest(),c); | ||
case "desc": | ||
return CharDesc.execute(mode.getRest(),c); | ||
case "longdesc": | ||
return CharLongDesc.execute(mode.getRest(),c); | ||
default: | ||
return "> Mode not Valid."; | ||
} | ||
}else { | ||
return command.notAllowed; | ||
} | ||
} | ||
} | ||
return "> Char with that name not found."; | ||
} | ||
|
||
@Override | ||
public String[] names() { | ||
return new String[]{"EditChar"}; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Allows the User to edit their Character.\n" + | ||
"Modes: Age, Avatar, Desc, Gender, LongDesc\n" + | ||
"\nAvatar and LongDesc need valid URLS."; | ||
} | ||
|
||
@Override | ||
public String usage() { | ||
return "[Char Name] [Mode] [Args]"; | ||
} | ||
|
||
@Override | ||
public String type() { | ||
return TYPE_CHARACTER; | ||
} | ||
|
||
@Override | ||
public String channel() { | ||
return CHANNEL_BOT_COMMANDS; | ||
} | ||
|
||
@Override | ||
public Permissions[] perms() { | ||
return new Permissions[0]; | ||
} | ||
|
||
@Override | ||
public boolean requiresArgs() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean doAdminLogging() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public String dualDescription() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String dualUsage() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String dualType() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Permissions[] dualPerms() { | ||
return new Permissions[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package Commands.Characters.EditModes; | ||
|
||
import Objects.CharacterObject; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharAge { | ||
|
||
public static String execute(String args, CharacterObject character){ | ||
if (args.length() > 20){ | ||
return "> Character Age length must be under 20 characters."; | ||
}else { | ||
character.setAge(args); | ||
return "> Age Updated"; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/Commands/Characters/EditModes/CharAvatar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package Commands.Characters.EditModes; | ||
|
||
import Main.Utility; | ||
import Objects.CharacterObject; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharAvatar { | ||
|
||
public static String execute(String args, CharacterObject character) { | ||
if (args.contains(" ") || args.contains("\n")) { | ||
return "> Image URL specified is invalid."; | ||
} | ||
if (Utility.isImageLink(args)) { | ||
character.setAvatarURL(args); | ||
return "> Character Avatar Updated."; | ||
} else { | ||
return "> Image URL specified is invalid."; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package Commands.Characters.EditModes; | ||
|
||
import Objects.CharacterObject; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharDesc { | ||
public static String execute(String args, CharacterObject character){ | ||
if (args.length() > 140){ | ||
return "> Character Description must be under 140 characters."; | ||
}else { | ||
character.setShortBio(args); | ||
return "> Description Updated."; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/Commands/Characters/EditModes/CharGender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package Commands.Characters.EditModes; | ||
|
||
import Objects.CharacterObject; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharGender { | ||
|
||
public static String execute(String args, CharacterObject character) { | ||
if (args.length() > 20) { | ||
return "> Gender Must be under 20 characters."; | ||
} | ||
character.setGender(args); | ||
return "> Gender Updated."; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/Commands/Characters/EditModes/CharLongDesc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package Commands.Characters.EditModes; | ||
|
||
import Objects.CharacterObject; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
/** | ||
* Created by Vaerys on 26/02/2017. | ||
*/ | ||
public class CharLongDesc { | ||
public static String execute(String args, CharacterObject character) { | ||
try { | ||
new URL(args); | ||
character.setLongBioURL(args); | ||
return "> Long Desc Link updated."; | ||
} catch (MalformedURLException e) { | ||
return "> Specified URL is invalid."; | ||
} | ||
} | ||
} |
Oops, something went wrong.