use of fredboat.db.transfer.GuildPermissions in project FredBoat by Frederikam.
the class PermissionsCommand method list.
public void list(CommandContext context) {
Guild guild = context.guild;
Member invoker = context.invoker;
GuildPermissions gp = Launcher.getBotController().getGuildPermsService().fetchGuildPermissions(guild);
List<IMentionable> mentionables = idsToMentionables(guild, gp.getFromEnum(permissionLevel));
String roleMentions = "";
String memberMentions = "";
for (IMentionable mentionable : mentionables) {
if (mentionable instanceof Role) {
if (((Role) mentionable).isPublicRole()) {
// Prevents ugly double double @@
roleMentions = roleMentions + "@everyone" + "\n";
} else {
roleMentions = roleMentions + mentionable.getAsMention() + "\n";
}
} else {
memberMentions = memberMentions + mentionable.getAsMention() + "\n";
}
}
PermissionLevel invokerPerms = PermsUtil.getPerms(invoker);
boolean invokerHas = PermsUtil.checkPerms(permissionLevel, invoker);
if (roleMentions.isEmpty())
roleMentions = "<none>";
if (memberMentions.isEmpty())
memberMentions = "<none>";
EmbedBuilder eb = CentralMessaging.getColoredEmbedBuilder().setTitle(context.i18nFormat("permsListTitle", permissionLevel)).setAuthor(invoker.getEffectiveName(), null, invoker.getUser().getAvatarUrl()).addField("Roles", roleMentions, true).addField("Members", memberMentions, true).addField(TextUtils.escapeMarkdown(invoker.getEffectiveName()), (invokerHas ? ":white_check_mark:" : ":x:") + " (" + invokerPerms + ")", false);
context.reply(CentralMessaging.addFooter(eb, guild.getSelfMember()).build());
}
Aggregations