Disabled color commands.

This commit is contained in:
Salmonllama 2021-09-07 19:26:16 -04:00
parent d3c63e2150
commit 7e57f2f56c
3 changed files with 9 additions and 82 deletions

View File

@ -5,13 +5,7 @@
package dev.salmonllama.fsbot.commands.general;
import dev.salmonllama.fsbot.config.BotConfig;
import dev.salmonllama.fsbot.database.controllers.ColorRoleController;
import dev.salmonllama.fsbot.guthix.*;
import org.apache.logging.log4j.util.Strings;
import org.javacord.api.entity.server.Server;
import org.javacord.api.entity.user.User;
import java.util.Arrays;
import java.util.List;
@ -25,43 +19,8 @@ public class ColorCommand extends Command {
@Override
public void onCommand(CommandContext ctx) {
// The color given will be the args.
// Check if args[0] is reset. If so, remove all color roles.
// Check if the given string is a current color role.
// Remove any color roles that the user has.
// Give the user the color role they specified
ctx.getServer().ifPresentOrElse(server -> {
String[] args = ctx.getArgs();
if (server.getIdAsString().equals(BotConfig.HOME_SERVER)) {
if (args[0].equals("reset")) {
// Remove all color roles
removeColorRoles(ctx.getUser(), server);
}
String color = Strings.join(Arrays.asList(args), ' ');
ColorRoleController.get(color).thenAcceptAsync(possibleColorRole -> possibleColorRole.ifPresentOrElse(colorRole -> {
// Remove all color roles
removeColorRoles(ctx.getUser(), server);
// Give the user the one they specified
addColorRole(ctx.getUser(), server, colorRole.getRoleId());
}, () -> ctx.reply("That color does not exist")));
}
}, () -> ctx.reply("This command can only be used in the fashionscape server"));
}
private static void removeColorRoles(User user, Server server) {
ColorRoleController.getAll().thenAcceptAsync(
possibleRoles -> possibleRoles.ifPresent(
colorRoles -> colorRoles.forEach(
colorRole -> server.getRoleById(colorRole.getRoleId()).ifPresent(
role -> user.removeRole(role, "Removed color role")
)
)
)
);
}
private static void addColorRole(User user, Server server, long roleId) {
server.getRoleById(roleId).ifPresent(role -> user.addRole(role, "Added color role"));
ctx.getApi().getOwner().thenAcceptAsync(owner -> {
ctx.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner);
});
}
}

View File

@ -23,26 +23,8 @@ public class ColorsCommand extends Command {
@Override
public void onCommand(CommandContext ctx) {
// List available color roles
ctx.getServer().ifPresentOrElse(server -> {
if (server.getIdAsString().equals(BotConfig.HOME_SERVER)) {
ColorRoleController.getAll().thenAcceptAsync(
possibleColorRoles -> possibleColorRoles.ifPresentOrElse(colorRoles -> {
EmbedBuilder response = new EmbedBuilder()
.setTitle("Color roles")
.setFooter(String.format("Found %d roles", colorRoles.size()));
colorRoles.forEach(
colorRole -> server.getRoleById(colorRole.getRoleId()).ifPresent(
role -> response.addField(colorRole.getColor(), role.getMentionTag(), true)
)
);
ctx.reply(response);
}, () -> ctx.reply("No color roles have been found")));
} else {
ctx.reply("This command can only be used in the fashionscape server");
}
}, () -> ctx.reply("This command can only be used in the fashionscape server"));
ctx.getApi().getOwner().thenAcceptAsync(owner -> {
ctx.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner);
});
}
}

View File

@ -24,22 +24,8 @@ public class AddColorCommand extends Command {
@Override
public void onCommand(CommandContext ctx) {
// Command takes only a role mention.
ctx.getServer().ifPresentOrElse(server -> {
if (server.getIdAsString().equals(BotConfig.HOME_SERVER)) {
List<Role> roles = ctx.getMessage().getMentionedRoles();
roles.forEach(role -> {
ColorRole colorRole = new ColorRole.ColorRoleBuilder(role.getId())
.setColor(role.getName())
.setServerId(server.getId())
.build();
ColorRoleController.insert(colorRole);
ctx.reply("Added color role:" + colorRole.toString());
});
} else {
ctx.reply("This command can only be used in the fashionscape server");
}
}, () -> ctx.reply("This command can only be used in the fashionscape server"));
ctx.getApi().getOwner().thenAcceptAsync(owner -> {
ctx.reply("This command is no longer active. An alternative is currently being developed. For more information, please contact " + owner);
});
}
}