feat: added userId entry to perms
Allowed add/remove subtypes within the permissions command to be used without user mentions, and simply just the user ID FS-34
This commit is contained in:
parent
01af9b916c
commit
9118ceefd8
@ -93,7 +93,7 @@ public class PermissionCommand extends Command {
|
|||||||
perm -> ctx.getApi().getUserById(perm.getUserId()).thenAcceptAsync(
|
perm -> ctx.getApi().getUserById(perm.getUserId()).thenAcceptAsync(
|
||||||
(discordUser) -> text.append(perm.getUserId())
|
(discordUser) -> text.append(perm.getUserId())
|
||||||
.append(" - ")
|
.append(" - ")
|
||||||
.append(discordUser.getDiscriminatedName())
|
.append(discordUser.getName())
|
||||||
.append(System.lineSeparator())
|
.append(System.lineSeparator())
|
||||||
).join()
|
).join()
|
||||||
)
|
)
|
||||||
@ -116,14 +116,14 @@ public class PermissionCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void add(CommandContext ctx) {
|
private void add(CommandContext ctx) {
|
||||||
|
String userId;
|
||||||
if (ctx.getMessage().getMentionedUsers().isEmpty()) {
|
if (ctx.getMessage().getMentionedUsers().isEmpty()) {
|
||||||
System.out.println("No mentioned users");
|
// If no mentioned users, then the user ID = args[1]
|
||||||
// If no mentioned users, improper usage
|
userId = ctx.getArgs()[1];
|
||||||
return;
|
} else {
|
||||||
|
userId = ctx.getMessage().getMentionedUsers().get(0).getIdAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
String userId = ctx.getMessage().getMentionedUsers().get(0).getIdAsString();
|
|
||||||
|
|
||||||
StaticPermission perm = new StaticPermission.StaticPermissionBuilder(userId).setPermission(ctx.getArgs()[2]).build();
|
StaticPermission perm = new StaticPermission.StaticPermissionBuilder(userId).setPermission(ctx.getArgs()[2]).build();
|
||||||
|
|
||||||
StaticPermissionController.insert(perm).thenAcceptAsync((Void) -> {
|
StaticPermissionController.insert(perm).thenAcceptAsync((Void) -> {
|
||||||
@ -131,19 +131,19 @@ public class PermissionCommand extends Command {
|
|||||||
.setTitle("Permissions Added")
|
.setTitle("Permissions Added")
|
||||||
.addField("User:", userId)
|
.addField("User:", userId)
|
||||||
.addField("Permission:", ctx.getArgs()[2]);
|
.addField("Permission:", ctx.getArgs()[2]);
|
||||||
|
|
||||||
ctx.reply(response);
|
ctx.reply(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove(CommandContext ctx) { // TODO: Remove is not functional
|
private void remove(CommandContext ctx) { // TODO: Remove is not functional
|
||||||
if (ctx.getMessage().getMentionedUsers().isEmpty()) {
|
String userId = ctx.getArgs()[1];
|
||||||
// If no mentioned users, improper usage
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String userId = ctx.getMessage().getMentionedUsers().get(0).getIdAsString();
|
StaticPermissionController.delete(userId, ctx.getArgs()[2]).thenAcceptAsync((Void) -> {
|
||||||
|
EmbedBuilder response = new EmbedBuilder()
|
||||||
StaticPermissionController.delete(userId, ctx.getArgs()[2]).thenAcceptAsync((Void) -> System.out.println("Permission removed")).exceptionally(ExceptionLogger.get());
|
.setTitle("Permissions Removed")
|
||||||
|
.addField("User:", userId)
|
||||||
|
.addField("Permission:", ctx.getArgs()[2]);
|
||||||
|
ctx.reply(response);
|
||||||
|
}).exceptionally(ExceptionLogger.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user