Files
Sokobot/src/main/java/me/polymarsdev/sokobot/commands/PrefixCommand.java
T
AffluentAvo 6c3a422295 added packages
cleaned up messy things
fixed emoji not moving when prefix is a direction
fixed input message get deleted when game not active
fixed more errors
maybe something else i forgot
2020-08-07 16:22:11 +02:00

38 lines
1.3 KiB
Java

package me.polymarsdev.sokobot.commands;
import me.polymarsdev.sokobot.Bot;
import me.polymarsdev.sokobot.entity.Command;
import me.polymarsdev.sokobot.event.CommandEvent;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
public class PrefixCommand extends Command {
public PrefixCommand() {
super("prefix");
}
@Override
public void execute(CommandEvent event) {
User user = event.getAuthor();
Member member = event.getMember();
String[] args = event.getArgs();
if (args.length > 0) {
if (!member.hasPermission(Permission.ADMINISTRATOR)) {
event.reply(user.getAsMention() + ", you do not have permission to use this command.");
return;
}
String newPrefix = args[0].toLowerCase();
if (newPrefix.length() > 1) {
event.reply(user.getAsMention() + ", the prefix must be one character long!");
return;
}
Bot.setPrefix(event.getGuild(), newPrefix);
event.reply("Prefix successfully changed to ``" + newPrefix + "``.");
}
}
}