Compare commits
No commits in common. "db943f7e0582ecc8b15e66c2ec3d238f0ed44e6d" and "b318b9f22b34ecaf4f0b50fbac0ec3f81710c12b" have entirely different histories.
db943f7e05
...
b318b9f22b
@ -133,7 +133,6 @@ 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
|
||||
|
@ -1,11 +0,0 @@
|
||||
package wtf.beatrice.hidekobot.commands.base;
|
||||
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
|
||||
public class Say
|
||||
{
|
||||
|
||||
public static Permission getPermission() {
|
||||
return Permission.MESSAGE_MANAGE;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
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<String> getCommandLabels() {
|
||||
return new LinkedList<>(Collections.singletonList("say"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Permission> 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();
|
||||
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ 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
|
||||
@ -23,7 +22,7 @@ public class SayCommand extends SlashCommandImpl
|
||||
"The message to send.",
|
||||
true,
|
||||
false)
|
||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Say.getPermission()));
|
||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,11 +57,10 @@ public class MessageCommandListener extends ListenerAdapter
|
||||
@Override
|
||||
public void onMessageReceived(@NotNull MessageReceivedEvent event)
|
||||
{
|
||||
// warning: we are getting the RAW value of the message content, not the DISPLAY value!
|
||||
String eventMessage = event.getMessage().getContentRaw();
|
||||
String eventMessage = event.getMessage().getContentDisplay();
|
||||
|
||||
// check if the sent message matches the bot activation regex (prefix, name, ...)
|
||||
if(!eventMessage.toLowerCase().matches(commandRegex + "((.|\\n)*)"))
|
||||
if(!eventMessage.toLowerCase().matches(commandRegex + ".*"))
|
||||
return;
|
||||
|
||||
// generate args from the string
|
||||
@ -121,7 +120,6 @@ public class MessageCommandListener extends ListenerAdapter
|
||||
String[] commandArgs;
|
||||
if(commandObject.passRawArgs())
|
||||
{
|
||||
|
||||
// remove first argument, which is the command label
|
||||
argsString = argsString.replaceAll("^[\\S]+\\s+", "");
|
||||
// pass all other arguments as a single argument as the first array element
|
||||
|
Loading…
Reference in New Issue
Block a user