Added missing null checks.
This commit is contained in:
@@ -31,6 +31,7 @@ import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.utils.Checks;
|
||||
|
||||
public final class CommandResponse {
|
||||
private final Emoji emoji;
|
||||
@@ -43,38 +44,56 @@ public final class CommandResponse {
|
||||
private TimeUnit deletionDelayUnit, expireDelayUnit;
|
||||
|
||||
public CommandResponse(final String emoji, final String response) {
|
||||
Checks.notNull(emoji, "Emoji");
|
||||
Checks.notNull(response, "Response");
|
||||
|
||||
this.emoji = EmojiManager.getForAlias(emoji);
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public final CommandResponse attachEmbed(final MessageEmbed embed) {
|
||||
Checks.notNull(embed, "Embed");
|
||||
|
||||
this.responseEmbed = embed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final CommandResponse setDeletionDelay(final long delay, final TimeUnit unit) {
|
||||
Checks.notNull(delay, "Delay");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
this.deletionDelay = delay;
|
||||
this.deletionDelayUnit = unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final CommandResponse addReactionCallback(final String emoji, final ReactionCallback callback) {
|
||||
Checks.notNull(emoji, "Emoji");
|
||||
Checks.notNull(callback, "Callback");
|
||||
|
||||
this.callbacks.put(EmojiManager.getForAlias(emoji), callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final CommandResponse setReactionCallbackTarget(final Member member) {
|
||||
Checks.notNull(member, "Member");
|
||||
|
||||
this.callbacksTarget = member.getUser();
|
||||
return this;
|
||||
}
|
||||
|
||||
public final CommandResponse setReactionCallbackExpireDelay(final long delay, final TimeUnit unit) {
|
||||
Checks.notNull(delay, "Delay");
|
||||
Checks.notNull(unit, "Unit");
|
||||
|
||||
this.expireDelay = delay;
|
||||
this.expireDelayUnit = unit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final void sendResponse(final TextChannel channel) {
|
||||
Checks.notNull(channel, "Channel");
|
||||
|
||||
final MessageBuilder builder = new MessageBuilder();
|
||||
builder.setContent(this.emoji.getUnicode() + " " + this.response);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user