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