diff --git a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java index a50d7f5..41b300c 100644 --- a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java +++ b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java @@ -133,6 +133,7 @@ public class HidekoBot messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.BotInfoCommand()); messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.CoinFlipCommand()); messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.ClearCommand()); + messageCommandListener.registerCommand(new wtf.beatrice.hidekobot.commands.message.SayCommand()); Cache.setMessageCommandListener(messageCommandListener); // register listeners diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/base/Say.java b/src/main/java/wtf/beatrice/hidekobot/commands/base/Say.java new file mode 100644 index 0000000..33c5670 --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/commands/base/Say.java @@ -0,0 +1,11 @@ +package wtf.beatrice.hidekobot.commands.base; + +import net.dv8tion.jda.api.Permission; + +public class Say +{ + + public static Permission getPermission() { + return Permission.MESSAGE_MANAGE; + } +} diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java new file mode 100644 index 0000000..aa7c162 --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/commands/message/SayCommand.java @@ -0,0 +1,51 @@ +package wtf.beatrice.hidekobot.commands.message; + +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import org.jetbrains.annotations.Nullable; +import wtf.beatrice.hidekobot.commands.base.ClearChat; +import wtf.beatrice.hidekobot.commands.base.Say; +import wtf.beatrice.hidekobot.objects.commands.MessageCommand; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +public class SayCommand implements MessageCommand +{ + + + @Override + public LinkedList getCommandLabels() { + return new LinkedList<>(Collections.singletonList("say")); + } + + @Nullable + @Override + public List getPermissions() { return Collections.singletonList(Say.getPermission()); } + + @Override + public boolean passRawArgs() { + return true; + } + + @Override + public void runCommand(MessageReceivedEvent event, String label, String[] args) + { + + String messageContent = ""; + if(args.length != 0) + { + messageContent = args[0]; + } 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(); + + } +} diff --git a/src/main/java/wtf/beatrice/hidekobot/commands/slash/SayCommand.java b/src/main/java/wtf/beatrice/hidekobot/commands/slash/SayCommand.java index 9cd2e4b..6e5b9cb 100644 --- a/src/main/java/wtf/beatrice/hidekobot/commands/slash/SayCommand.java +++ b/src/main/java/wtf/beatrice/hidekobot/commands/slash/SayCommand.java @@ -9,6 +9,7 @@ import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.CommandData; import net.dv8tion.jda.api.interactions.commands.build.Commands; import org.jetbrains.annotations.NotNull; +import wtf.beatrice.hidekobot.commands.base.Say; import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl; public class SayCommand extends SlashCommandImpl @@ -22,7 +23,7 @@ public class SayCommand extends SlashCommandImpl "The message to send.", true, false) - .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE)); + .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Say.getPermission())); } @Override