Skip to content

Commit

Permalink
Fixed Emojis not loading
Browse files Browse the repository at this point in the history
Also updated the MessageType constants
  • Loading branch information
R3alCl0ud committed Sep 6, 2017
1 parent e9fd73f commit 4db4f18
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* @since 0.0.1
*/
public class CommandHandler {

public static String prefix = "/";

public static boolean handleCommands = false;

public static boolean selfBot = true;

public static void handleMessageCreate(MessageCreateEvent e) {
try {
IMessage message = e.getMessage();
Expand All @@ -33,7 +33,7 @@ public static void handleMessageCreate(MessageCreateEvent e) {
String rest = "";
if (label.length() < message.getContent().length()) rest = message.getContent().substring(label.length() + 1);
int argc = Args.length > 1 ? Args.length - 1 : 0;

if (label.length() < prefix.length() || !label.substring(0, prefix.length()).equals(prefix)) {
return;
}
Expand All @@ -49,7 +49,7 @@ public static void handleMessageCreate(MessageCreateEvent e) {
Matcher argM = command.getArgsPattern().matcher(rest);
int n = 0;
while (argM.find()) {
for (int i = 0; i < argM.groupCount(); i++) {
for (int i = 0; i < argM.groupCount() && i < args.length; i++) {
try {
args[n] = argM.group(i);
} catch (Exception ex) {
Expand All @@ -65,11 +65,12 @@ public static void handleMessageCreate(MessageCreateEvent e) {
e1.printStackTrace();
}
}

/**
* @param label The label of the command
* @param message The message the label is from
* @return A Command if a command was found, {@code null} if no command was found
* @return A Command if a command was found, {@code null} if no command was
* found
*/
public static Command getCommand(String label, IMessage message) {
String region = message.getGuild() != null ? getGuildRegion(message.getGuild()) : "us-central";
Expand All @@ -87,9 +88,9 @@ public static Command getCommand(String label, IMessage message) {
}
return null;
}

public static String getGuildRegion(IGuild guild) {
return guild.getVoiceRegion().id;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class Emojis {
}
List<String> keywords = new ArrayList<>(), shortnames = new ArrayList<>();
obj.getJSONArray("keywords").forEach(keyword -> keywords.add(keyword.toString()));
obj.getJSONArray("shortname_alternatives").forEach(alt -> shortnames.add(alt.toString().replaceAll(":", "")));
emojis.add(new Emoji(name, unicode, obj.getDouble("unicode_version"), obj.getInt("order"), obj.getInt("display"), keywords, shortnames, EmojiGender.getByCode(obj.getString("gender")), category, codePoints));
obj.getJSONArray("shortname_alternates").forEach(alt -> shortnames.add(alt.toString().replaceAll(":", "")));
emojis.add(new Emoji(name, unicode, obj.getDouble("unicode_version"), obj.getInt("order"), obj.getInt("display"), keywords, shortnames, EmojiGender.getByCode(obj.get("gender").toString()), category, codePoints));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,19 @@
* @author Perry Berman
*/
public enum MessageType {
MESSAGE, GROUP_ADD, GROUP_LEAVE, CALL_START, MESSAGE_PINNED
MESSAGE(0), GROUP_ADD(1), GROUP_LEAVE(2), CALL(3), GROUP_NAME_CHANGE(4), GROUP_ICON_CHANGE(5), MESSAGE_PINNED(6), GUILD_MEMBER_JOIN(7);

private int num;

MessageType(int num) {
this.num = num;
}

public static MessageType getMessageType(int type) {
for (MessageType mType : values()) {
if (mType.num == type) return mType;
}
return MESSAGE;
}

}

0 comments on commit 4db4f18

Please sign in to comment.