diff --git a/app/src/main/java/bot/cmd/DefineCommand.java b/app/src/main/java/bot/cmd/DefineCommand.java index 2730747..3fee387 100644 --- a/app/src/main/java/bot/cmd/DefineCommand.java +++ b/app/src/main/java/bot/cmd/DefineCommand.java @@ -13,6 +13,7 @@ import lombok.extern.log4j.Log4j2; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; @@ -54,15 +55,18 @@ public void execute(SlashCommandInteractionEvent event) { String word = event.getOption("word").getAsString(); WordCacheView wordCacheView = new WordCacheView(); Optional cachedWord = wordCacheService.getWordFromCacheOrAPI(word); + ChannelType channelType = event.getChannel().getType(); if (cachedWord.isEmpty()) { event.reply("I am not familiar with that word! :pensive:").setEphemeral(true).queue(); return; } + boolean ephemeral = !channelType.isGuild(); EmbedBuilder embedBuilder = wordCacheView.getDefinitionEmbed(cachedWord.get()); event.replyEmbeds(embedBuilder.build()) .addActionRow(Button.secondary("save", "Save").withEmoji(Emoji.fromUnicode("💾"))) + .setEphemeral(ephemeral) .queue(); }