🔨 Add canManage to guild list

This commit is contained in:
SebClem 2022-06-11 19:06:04 +02:00
parent ccb0c6eee8
commit 606d223361
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
2 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,4 @@
package net.Broken.Api.Data.Guild;
public record Guild(String id, String name, String iconUrl) {
public record Guild(String id, String name, String iconUrl, boolean canManage) {
}

View File

@ -22,7 +22,12 @@ public class GuildService {
List<Guild> guildList = new ArrayList<>();
for (net.dv8tion.jda.api.entities.Guild guild : mutualGuilds) {
guildList.add(new Guild(guild.getId(), guild.getName(), guild.getIconUrl()));
boolean canManage = guild.getMember(discordUser).hasPermission(
Permission.MANAGE_SERVER,
Permission.MANAGE_PERMISSIONS,
Permission.MANAGE_CHANNEL
);
guildList.add(new Guild(guild.getId(), guild.getName(), guild.getIconUrl(), canManage));
}
return guildList;
}