forked from Fascinated/Bat
Compare commits
2 Commits
9a1d011ff2
...
d54d2ffe0d
Author | SHA1 | Date | |
---|---|---|---|
d54d2ffe0d | |||
409e71a0aa |
@ -0,0 +1,36 @@
|
||||
package cc.fascinated.bat.command.impl.fun;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.Category;
|
||||
import cc.fascinated.bat.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.common.WebRequest;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.model.token.randomfox.RandomFoxToken;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Component
|
||||
@CommandInfo(name = "fox", description = "Get a random fox image", category = Category.FUN, guildOnly = false)
|
||||
public class FoxCommand extends BatCommand {
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||
RandomFoxToken responseEntity = WebRequest.getAsEntity("https://randomfox.ca/floof/", RandomFoxToken.class);
|
||||
if (responseEntity == null) {
|
||||
interaction.reply("Failed to get a fox image!").queue();
|
||||
return;
|
||||
}
|
||||
|
||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
||||
.setAuthor("Here's a random fox image!")
|
||||
.setImage(responseEntity.getImage())
|
||||
.build()).queue();
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ public class SetTopicSubCommand extends BatSubCommand {
|
||||
String topic = interaction.getOption("topic").getAsString();
|
||||
if (topic.length() > 1024) {
|
||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("The topic must be less than 1024 characters!")
|
||||
.setDescription("The topic must be 1024 characters or less!")
|
||||
.build())
|
||||
.queue();
|
||||
return;
|
||||
|
@ -0,0 +1,21 @@
|
||||
package cc.fascinated.bat.model.token.randomfox;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Nick (okNick)
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class RandomFoxToken {
|
||||
/**
|
||||
* The URL of the raw image.
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* The link of the image + other web info.
|
||||
*/
|
||||
private String link;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user