use of discord4j.core.object.entity.channel.TextChannel in project KaellyBot by Kaysoro.
the class SendNudeCommand method request.
@Override
public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
if (message.getChannel().blockOptional().map(chan -> chan instanceof PrivateChannel).orElse(false) || message.getChannel().blockOptional().map(chan -> ((TextChannel) chan).isNsfw()).orElse(false)) {
int position = RANDOM.nextInt(Nude.values().length);
Nude nude = Nude.values()[position];
message.getChannel().flatMap(chan -> chan.createEmbed(spec -> spec.setTitle(Translator.getLabel(lg, "sendnude.title")).setDescription(Translator.getLabel(lg, "sendnude.author").replace("{author}", nude.getAuthor()).replace("{url}", nude.getUrl())).setColor(discord4j.rest.util.Color.PINK).setFooter(Translator.getLabel(lg, "sendnude.footer").replace("{position}", String.valueOf(position + 1)).replace("{number}", String.valueOf(Nude.values().length)), null).setImage(nude.getImage()))).subscribe();
} else
// Exception NSFW
BasicDiscordException.NO_NSFW_CHANNEL.throwException(message, this, lg);
}
Aggregations