61 lines
2.1 KiB
Java
61 lines
2.1 KiB
Java
package net.nevet5gi.buzzbot.commands;
|
|
|
|
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.OptionData;
|
|
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
|
import net.nevet5gi.buzzbot.commands.utils.ISlashCommand;
|
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
|
import net.nevet5gi.buzzbot.objects.ModRoles;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class SetRoleCmd implements ISlashCommand {
|
|
@Override
|
|
public String getName() {
|
|
return "setrole";
|
|
}
|
|
|
|
@Override
|
|
public int getPermissionLevel() {
|
|
return 4;
|
|
}
|
|
|
|
@Override
|
|
public String getHelp() {
|
|
return "Sets the role id for the moderation roles";
|
|
}
|
|
|
|
@Override
|
|
public void handleSlash(CommandContext ctx) {
|
|
SqlDB sql = new SqlDB();
|
|
sql.updateGuildRole(ctx.getGuild().getIdLong(), ctx.getSlashEvent().getOption("role").getAsString(), ctx.getSlashEvent().getOption("guild_role").getAsRole().getIdLong());
|
|
sql.close();
|
|
ctx.getHook().sendMessage("Assigned role <@&" + ctx.getSlashEvent().getOption("guild_role").getAsRole().getId() + "> to " + ctx.getSlashEvent().getOption("role").getAsString()).queue();
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return this.getHelp();
|
|
}
|
|
|
|
@Override
|
|
public CommandData getCommandData() {
|
|
List<OptionData> options = new ArrayList<>();
|
|
|
|
OptionData role = new OptionData(OptionType.STRING, "role", "Role assigned to moderation roles", true);
|
|
role.addChoice("helper", ModRoles.HELPER.getRole());
|
|
role.addChoice("moderator", ModRoles.MODERATOR.getRole());
|
|
role.addChoice("administrator", ModRoles.ADMINISTRATOR.getRole());
|
|
role.addChoice("owner", ModRoles.OWNER.getRole());
|
|
options.add(role);
|
|
|
|
OptionData guildRole = new OptionData(OptionType.ROLE, "guild_role", "Mentioned role to assign", true);
|
|
options.add(guildRole);
|
|
|
|
return new CommandData(this.getName(), this.getDescription())
|
|
.addOptions(options);
|
|
}
|
|
}
|