Add FoxCommand
This commit is contained in:
parent
9a1d011ff2
commit
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();
|
||||||
|
}
|
||||||
|
}
|
@ -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…
Reference in New Issue
Block a user