2022-12-19 18:24:29 +01:00
|
|
|
package wtf.beatrice.hidekobot.commands.message;
|
|
|
|
|
|
|
|
import net.dv8tion.jda.api.Permission;
|
|
|
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
2022-12-19 18:37:17 +01:00
|
|
|
import wtf.beatrice.hidekobot.commands.base.MagicBall;
|
2022-12-19 18:24:29 +01:00
|
|
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class MagicBallCommand implements MessageCommand
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public LinkedList<String> getCommandLabels() {
|
2022-12-19 18:37:17 +01:00
|
|
|
return MagicBall.getLabels();
|
2022-12-19 18:24:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public List<Permission> getPermissions() {
|
|
|
|
return null; // anyone can use it
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean passRawArgs() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
|
|
|
{
|
|
|
|
if(args.length == 0)
|
|
|
|
{
|
|
|
|
event.getMessage().reply("You need to specify a question!").queue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder questionBuilder = new StringBuilder();
|
|
|
|
for(int i = 0; i < args.length; i++)
|
|
|
|
{
|
|
|
|
String arg = args[i];
|
|
|
|
questionBuilder.append(arg);
|
|
|
|
if(i + 1 != args.length) // don't add a separator on the last iteration
|
|
|
|
questionBuilder.append(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
String question = questionBuilder.toString();
|
|
|
|
|
|
|
|
|
2022-12-19 18:37:17 +01:00
|
|
|
event.getMessage().replyEmbeds(MagicBall.generateEmbed(question, event.getAuthor())).queue();
|
2022-12-19 18:24:29 +01:00
|
|
|
}
|
|
|
|
}
|