diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java index 9f2cd8d..7c87b89 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java @@ -1,6 +1,7 @@ package wtf.beatrice.hidekobot.commands.message; import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,17 +54,26 @@ public class SayCommand implements MessageCommand { String messageContent; - if(args.length != 0 && !args[0].isEmpty()) + if (args.length != 0 && !args[0].isEmpty()) { messageContent = args[0]; - } else { + } else + { event.getMessage().reply("\uD83D\uDE20 Hey, you have to tell me what to say!") .queue(); return; } event.getChannel().sendMessage(messageContent).queue(); - event.getMessage().delete().queue(); + if (event.getChannel() instanceof TextChannel) + { + event.getMessage().delete().queue(response -> { + // nothing to do with the response + }, error -> { + // ignore the error if we couldn't delete it, we were probably missing permissions + // without this block it would print a stack trace in console + }); + } } }