Compare commits

..

2 Commits

Author SHA1 Message Date
d54d2ffe0d wording 2024-06-27 21:11:37 -05:00
409e71a0aa Add FoxCommand 2024-06-27 21:04:21 -05:00
3 changed files with 58 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -40,7 +40,7 @@ public class SetTopicSubCommand extends BatSubCommand {
String topic = interaction.getOption("topic").getAsString(); String topic = interaction.getOption("topic").getAsString();
if (topic.length() > 1024) { if (topic.length() > 1024) {
interaction.replyEmbeds(EmbedUtils.errorEmbed() interaction.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("The topic must be less than 1024 characters!") .setDescription("The topic must be 1024 characters or less!")
.build()) .build())
.queue(); .queue();
return; return;

View File

@ -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;
}