diff --git a/src/main/java/com/darichey/discord/CommandListener.java b/src/main/java/com/darichey/discord/CommandListener.java index 2dc9c7c..f164d03 100644 --- a/src/main/java/com/darichey/discord/CommandListener.java +++ b/src/main/java/com/darichey/discord/CommandListener.java @@ -18,7 +18,7 @@ public CommandListener(CommandRegistry registry) { @Override public void handle(MessageReceivedEvent event) { String content = event.getMessage().getContent(); - String prefix = registry.getEffectivePrefix(event.getGuild().getLongID()); + String prefix = registry.getEffectivePrefix(event.getGuild()); if (content.startsWith(prefix)) { String prefixRemoved = content.substring(prefix.length()); diff --git a/src/main/java/com/darichey/discord/CommandRegistry.java b/src/main/java/com/darichey/discord/CommandRegistry.java index 5e85a13..732779d 100644 --- a/src/main/java/com/darichey/discord/CommandRegistry.java +++ b/src/main/java/com/darichey/discord/CommandRegistry.java @@ -125,16 +125,17 @@ public Optional getPrefixForGuild(long id) { /** * Gets the prefix for the given guild. This is either the guild-specific prefix or the default prefix if one is not set. * @param guild The guild to look up. - * @return The guild-specific prefix for this guild or + * @return The guild-specific prefix for this guild or the default prefix. */ public String getEffectivePrefix(IGuild guild) { - return getEffectivePrefix(guild.getLongID()); + if (guild == null) return defaultPrefix; + else return getEffectivePrefix(guild.getLongID()); } /** * Gets the prefix for the given guild. This is either the guild-specific prefix or the default prefix if one is not set. * @param id The id of the guild to look up. - * @return The guild-specific prefix for this guild or + * @return The guild-specific prefix for this guild or the default prefix. */ public String getEffectivePrefix(long id) { return getPrefixForGuild(id).orElse(defaultPrefix);