feat: "hashing" via discord by DM-ing the bot hash

This commit is contained in:
ChomeNS
2025-04-11 17:08:23 +07:00
parent 9557231010
commit a5602d1a01
9 changed files with 214 additions and 18 deletions

View File

@@ -1,8 +1,13 @@
package me.chayapak1.chomens_bot.command;
import me.chayapak1.chomens_bot.Configuration;
import me.chayapak1.chomens_bot.Main;
import net.dv8tion.jda.api.entities.Role;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import java.util.List;
public enum TrustLevel {
PUBLIC(0, Component.text("Public").color(NamedTextColor.GREEN)),
TRUSTED(1, Component.text("Trusted").color(NamedTextColor.RED)),
@@ -16,4 +21,29 @@ public enum TrustLevel {
this.level = level;
this.component = component;
}
public static TrustLevel fromDiscordRoles (final List<Role> roles) {
if (Main.discord == null) return PUBLIC;
final Configuration.Discord options = Main.discord.options;
if (options == null) return PUBLIC;
TrustLevel userTrustLevel = PUBLIC;
for (final Role role : roles) {
if (role.getName().equalsIgnoreCase(options.ownerRoleName)) {
userTrustLevel = OWNER;
break;
} else if (role.getName().equalsIgnoreCase(options.adminRoleName)) {
userTrustLevel = ADMIN;
break;
} else if (role.getName().equalsIgnoreCase(options.trustedRoleName)) {
userTrustLevel = TRUSTED;
break;
}
}
return userTrustLevel;
}
}