mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
[DISCORD] Lots and lots of bugfixes
- Fixes bug where sending any messages through Discord would result in errors about roles - Fixes bug where attempting to send any messages to Discord just didn't work - Discord integration now shows main chat messages in color
This commit is contained in:
parent
071d19c5e0
commit
a5135ef641
@ -86,7 +86,7 @@ public class Bot
|
|||||||
|
|
||||||
public Mono<Guild> getGuildById()
|
public Mono<Guild> getGuildById()
|
||||||
{
|
{
|
||||||
return client.getGuildById(SnowflakeEntry.serverID);
|
return client.getGuildById(SnowflakeEntry.SERVER_ID.getSnowflake());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GatewayDiscordClient getClient()
|
public GatewayDiscordClient getClient()
|
||||||
@ -112,7 +112,7 @@ public class Bot
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Guild server = client.getGuildById(SnowflakeEntry.serverID).block();
|
Guild server = client.getGuildById(SnowflakeEntry.SERVER_ID.getSnowflake()).block();
|
||||||
if (server == null)
|
if (server == null)
|
||||||
{
|
{
|
||||||
FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server.");
|
FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server.");
|
||||||
|
@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class TFD4J extends JavaPlugin
|
public class TFD4J extends JavaPlugin
|
||||||
{
|
{
|
||||||
private final Logger slf4j = LoggerFactory.getLogger("TFD4J");
|
private final Logger slf4j = getSLF4JLogger();
|
||||||
private Bot bot;
|
private Bot bot;
|
||||||
private MinecraftListener mc;
|
private MinecraftListener mc;
|
||||||
private AdminChatListener ac;
|
private AdminChatListener ac;
|
||||||
|
@ -62,11 +62,11 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
Mono<Message> sentMessage = tfd4J
|
Mono<Message> sentMessage = tfd4J
|
||||||
.getBot()
|
.getBot()
|
||||||
.getClient()
|
.getClient()
|
||||||
.getChannelById(SnowflakeEntry.adminChatChannelID)
|
.getChannelById(SnowflakeEntry.ADMIN_CHAT_CHANNEL_ID.getSnowflake())
|
||||||
.ofType(TextChannel.class)
|
.ofType(TextChannel.class)
|
||||||
.flatMap(c -> c.createMessage(spec));
|
.flatMap(c -> c.createMessage(spec));
|
||||||
|
|
||||||
insert(sentMessage);
|
sentMessage.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +104,11 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
Mono<Message> sentMessage = tfd4J
|
Mono<Message> sentMessage = tfd4J
|
||||||
.getBot()
|
.getBot()
|
||||||
.getClient()
|
.getClient()
|
||||||
.getChannelById(SnowflakeEntry.chatChannelID)
|
.getChannelById(SnowflakeEntry.CHAT_CHANNEL_ID.getSnowflake())
|
||||||
.ofType(TextChannel.class)
|
.ofType(TextChannel.class)
|
||||||
.flatMap(c -> c.createMessage(spec));
|
.flatMap(c -> c.createMessage(spec));
|
||||||
|
|
||||||
insert(sentMessage);
|
sentMessage.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,11 +159,11 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
Role adminRole = server.getRoleById(SnowflakeEntry.adminRoleID)
|
Role adminRole = server.getRoleById(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake())
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
Role senioradminRole = server.getRoleById(SnowflakeEntry.seniorRoleID)
|
Role senioradminRole = server.getRoleById(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake())
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
|
|
||||||
if (server == null) return false;
|
if (server == null) return false;
|
||||||
|
|
||||||
final TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID)
|
final TextChannel channel = server.getChannelById(SnowflakeEntry.REPORT_CHANNEL_ID.getSnowflake())
|
||||||
.ofType(TextChannel.class)
|
.ofType(TextChannel.class)
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
@ -324,7 +324,7 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
|
|
||||||
final Guild server = tfd4J.getBot()
|
final Guild server = tfd4J.getBot()
|
||||||
.getClient()
|
.getClient()
|
||||||
.getGuildById(SnowflakeEntry.serverID)
|
.getGuildById(SnowflakeEntry.SERVER_ID.getSnowflake())
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
if (server == null)
|
if (server == null)
|
||||||
@ -333,7 +333,7 @@ public class TFD4JCommonsImpl implements TFD4JCommons
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID)
|
final TextChannel channel = server.getChannelById(SnowflakeEntry.REPORT_CHANNEL_ID.getSnowflake())
|
||||||
.ofType(TextChannel.class)
|
.ofType(TextChannel.class)
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
@ -49,7 +49,7 @@ public class AdminChatListener
|
|||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow()
|
.orElseThrow()
|
||||||
.getId()
|
.getId()
|
||||||
.equals(SnowflakeEntry.adminChatChannelID))
|
.equals(SnowflakeEntry.ADMIN_CHAT_CHANNEL_ID.getSnowflake()))
|
||||||
.filter(m -> !m.getMessage()
|
.filter(m -> !m.getMessage()
|
||||||
.getAuthor()
|
.getAuthor()
|
||||||
.orElseThrow()
|
.orElseThrow()
|
||||||
@ -61,7 +61,7 @@ public class AdminChatListener
|
|||||||
public void createMessageSpec(MessageCreateEvent m)
|
public void createMessageSpec(MessageCreateEvent m)
|
||||||
{
|
{
|
||||||
Member member = m.getMember().orElseThrow(IllegalAccessError::new);
|
Member member = m.getMember().orElseThrow(IllegalAccessError::new);
|
||||||
String tag = tfd4j.getMinecraftListener().getDisplay(member);
|
String tag = tfd4j.getBot().getTFM().getDisplay(member);
|
||||||
Message msg = m.getMessage();
|
Message msg = m.getMessage();
|
||||||
String mediamessage = ChatColor.YELLOW + "[Media]";
|
String mediamessage = ChatColor.YELLOW + "[Media]";
|
||||||
|
|
||||||
@ -129,28 +129,35 @@ public class AdminChatListener
|
|||||||
assert server != null;
|
assert server != null;
|
||||||
return member.getRoles().map(role ->
|
return member.getRoles().map(role ->
|
||||||
{
|
{
|
||||||
if (role.getId().equals(SnowflakeEntry.ownerRoleID))
|
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Title.OWNER;
|
return Title.OWNER;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.developerRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Title.DEVELOPER;
|
return Title.DEVELOPER;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.executiveRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Title.EXECUTIVE;
|
return Title.EXECUTIVE;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.assistantRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Title.ASSTEXEC;
|
return Title.ASSTEXEC;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.seniorRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Rank.SENIOR_ADMIN;
|
return Rank.SENIOR_ADMIN;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.adminRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Rank.ADMIN;
|
return Rank.ADMIN;
|
||||||
} else if (role.getId().equals(SnowflakeEntry.builderRoleID))
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return Title.MASTER_BUILDER;
|
return Title.MASTER_BUILDER;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.discord.listener;
|
|||||||
|
|
||||||
import discord4j.core.event.domain.message.MessageCreateEvent;
|
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||||
import discord4j.core.object.entity.Attachment;
|
import discord4j.core.object.entity.Attachment;
|
||||||
import discord4j.core.object.entity.Guild;
|
|
||||||
import discord4j.core.object.entity.Member;
|
import discord4j.core.object.entity.Member;
|
||||||
import discord4j.core.object.entity.Message;
|
import discord4j.core.object.entity.Message;
|
||||||
import discord4j.core.object.entity.channel.TextChannel;
|
import discord4j.core.object.entity.channel.TextChannel;
|
||||||
@ -11,17 +10,14 @@ import me.totalfreedom.discord.TFD4J;
|
|||||||
import me.totalfreedom.discord.util.SnowflakeEntry;
|
import me.totalfreedom.discord.util.SnowflakeEntry;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class MinecraftListener
|
public class MinecraftListener
|
||||||
{
|
{
|
||||||
@ -52,7 +48,7 @@ public class MinecraftListener
|
|||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow(IllegalAccessError::new)
|
.orElseThrow(IllegalAccessError::new)
|
||||||
.getId()
|
.getId()
|
||||||
.equals(SnowflakeEntry.chatChannelID))
|
.equals(SnowflakeEntry.CHAT_CHANNEL_ID.getSnowflake()))
|
||||||
.filter(m ->
|
.filter(m ->
|
||||||
{
|
{
|
||||||
Boolean b = m.getMessage()
|
Boolean b = m.getMessage()
|
||||||
@ -67,98 +63,44 @@ public class MinecraftListener
|
|||||||
{
|
{
|
||||||
Member member = m.getMember().orElseThrow();
|
Member member = m.getMember().orElseThrow();
|
||||||
Message msg = m.getMessage();
|
Message msg = m.getMessage();
|
||||||
String tag = getDisplay(member);
|
String tag = bot.getTFM().getDisplay(member);
|
||||||
TextComponent[] emsg = {Component.empty()}; // We are using a single value arrays here to silence SonarLint's "return value never used" bullshit.
|
|
||||||
|
|
||||||
emsg[0] = emsg[0].append(Component.text("[", NamedTextColor.DARK_GRAY));
|
TextComponent.Builder builder = Component.text();
|
||||||
TextComponent[] inviteLink = {Component.text("Discord")};
|
TextComponent prefix = Component.text("[", NamedTextColor.DARK_GRAY)
|
||||||
inviteLink[0] = inviteLink[0].color(NamedTextColor.DARK_AQUA);
|
.append(Component.text("Discord", NamedTextColor.DARK_AQUA)
|
||||||
HoverEvent<Component> hoverEvent = HoverEvent.showText(Component.text("Click to join our Discord server!"));
|
.hoverEvent(HoverEvent.showText(Component.text("Click to join our Discord server!")))
|
||||||
ClickEvent clickEvent = ClickEvent.openUrl(ConfigEntry.DISCORD_INVITE_LINK.getString());
|
.clickEvent(ClickEvent.openUrl(ConfigEntry.DISCORD_INVITE_LINK.getString())))
|
||||||
inviteLink[0] = inviteLink[0].hoverEvent(hoverEvent);
|
.append(Component.text("] ", NamedTextColor.DARK_GRAY));
|
||||||
inviteLink[0] = inviteLink[0].clickEvent(clickEvent);
|
TextComponent user = Component.empty();
|
||||||
emsg[0] = emsg[0].append(inviteLink[0]);
|
|
||||||
emsg[0] = emsg[0].append(Component.text("] ", NamedTextColor.DARK_GRAY));
|
|
||||||
|
|
||||||
// Tag (if they have one)
|
// Tag (if they have one)
|
||||||
if (tag != null)
|
if (tag != null && !tag.isEmpty())
|
||||||
{
|
{
|
||||||
emsg[0] = emsg[0].append(Component.text(tag));
|
user = LegacyComponentSerializer.legacyAmpersand().deserialize(tag).append(Component.space());
|
||||||
}
|
}
|
||||||
|
|
||||||
emsg[0] = emsg[0].append(Component.space());
|
user = user.append(Component.text(FUtil.stripColors(member.getDisplayName()).trim(), NamedTextColor.RED));
|
||||||
|
|
||||||
// User
|
TextComponent message = Component.text(": ", NamedTextColor.DARK_GRAY)
|
||||||
TextComponent[] user = {Component.text(FUtil.stripColors(member.getDisplayName()))};
|
.append(Component.text(FUtil.stripColors(msg.getContent()), NamedTextColor.WHITE));
|
||||||
user[0] = user[0].color(NamedTextColor.RED);
|
|
||||||
emsg[0] = emsg[0].append(user[0]);
|
|
||||||
|
|
||||||
// Message
|
|
||||||
emsg[0] = emsg[0].append(Component.text(": ", NamedTextColor.DARK_GRAY));
|
|
||||||
emsg[0] = emsg[0].append(Component.text(FUtil.stripColors(msg.getContent()), NamedTextColor.WHITE));
|
|
||||||
// Attachments
|
// Attachments
|
||||||
if (!msg.getAttachments().isEmpty())
|
if (!msg.getAttachments().isEmpty())
|
||||||
{
|
{
|
||||||
if (!msg.getContent().isEmpty())
|
if (!msg.getContent().isEmpty())
|
||||||
emsg[0] = emsg[0].append(Component.space());
|
{
|
||||||
|
message = message.append(Component.space());
|
||||||
|
}
|
||||||
|
|
||||||
for (Attachment attachment : msg.getAttachments())
|
for (Attachment attachment : msg.getAttachments())
|
||||||
{
|
{
|
||||||
TextComponent[] media = {Component.text("[Media] ")};
|
message = message.append(Component.text("[Media] ", NamedTextColor.YELLOW)
|
||||||
media[0] = media[0].color(NamedTextColor.YELLOW);
|
.hoverEvent(HoverEvent.showText(Component.text(attachment.getUrl())))
|
||||||
HoverEvent<Component> hover = HoverEvent.showText(Component.text(attachment.getUrl()));
|
.clickEvent(ClickEvent.openUrl(attachment.getUrl())));
|
||||||
ClickEvent click = ClickEvent.openUrl(attachment.getUrl());
|
|
||||||
media[0] = media[0].clickEvent(click);
|
|
||||||
media[0] = media[0].hoverEvent(hover);
|
|
||||||
emsg[0] = emsg[0].append(media[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bukkit.broadcast(builder.append(prefix, user, message).build());
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord())
|
|
||||||
{
|
|
||||||
player.sendMessage(emsg[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FLog.info(emsg[0].content(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplay(Member member)
|
|
||||||
{
|
|
||||||
Guild server = tfd4j.getBot().getGuildById().block();
|
|
||||||
// Server Owner
|
|
||||||
assert server != null;
|
|
||||||
return member.getRoles().map(role ->
|
|
||||||
{
|
|
||||||
if (role.getId().equals(SnowflakeEntry.ownerRoleID))
|
|
||||||
{
|
|
||||||
return Title.OWNER.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.developerRoleID))
|
|
||||||
{
|
|
||||||
return Title.DEVELOPER.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.executiveRoleID))
|
|
||||||
{
|
|
||||||
return Title.EXECUTIVE.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.assistantRoleID))
|
|
||||||
{
|
|
||||||
return Title.ASSTEXEC.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.seniorRoleID))
|
|
||||||
{
|
|
||||||
return Rank.SENIOR_ADMIN.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.adminRoleID))
|
|
||||||
{
|
|
||||||
return Rank.ADMIN.getColoredTag();
|
|
||||||
} else if (role.getId().equals(SnowflakeEntry.builderRoleID))
|
|
||||||
{
|
|
||||||
return Title.MASTER_BUILDER.getColoredTag();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}).blockFirst();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,10 @@ import discord4j.core.event.domain.message.ReactionAddEvent;
|
|||||||
import discord4j.core.object.Embed;
|
import discord4j.core.object.Embed;
|
||||||
import discord4j.core.object.entity.Member;
|
import discord4j.core.object.entity.Member;
|
||||||
import discord4j.core.object.entity.Message;
|
import discord4j.core.object.entity.Message;
|
||||||
import discord4j.core.object.entity.channel.Channel;
|
|
||||||
import discord4j.core.object.entity.channel.TextChannel;
|
import discord4j.core.object.entity.channel.TextChannel;
|
||||||
import discord4j.discordjson.json.MessageCreateRequest;
|
import discord4j.discordjson.json.MessageCreateRequest;
|
||||||
import me.totalfreedom.discord.TFD4J;
|
import me.totalfreedom.discord.TFD4J;
|
||||||
import me.totalfreedom.discord.util.SnowflakeEntry;
|
import me.totalfreedom.discord.util.SnowflakeEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
|
|
||||||
public class ReactionListener
|
public class ReactionListener
|
||||||
{
|
{
|
||||||
@ -34,7 +32,7 @@ public class ReactionListener
|
|||||||
.equals(tfd4j.getBot().getClient().getSelfId()))
|
.equals(tfd4j.getBot().getClient().getSelfId()))
|
||||||
.filter(r -> !r.getChannel()
|
.filter(r -> !r.getChannel()
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow().getId().equals(SnowflakeEntry.reportChannelID))
|
.orElseThrow().getId().equals(SnowflakeEntry.REPORT_CHANNEL_ID.getSnowflake()))
|
||||||
.filter(r -> r.getEmoji()
|
.filter(r -> r.getEmoji()
|
||||||
.asUnicodeEmoji()
|
.asUnicodeEmoji()
|
||||||
.orElseThrow(UnsupportedOperationException::new)
|
.orElseThrow(UnsupportedOperationException::new)
|
||||||
@ -47,7 +45,7 @@ public class ReactionListener
|
|||||||
{
|
{
|
||||||
final TextChannel archiveChannel = tfd4j.getBot()
|
final TextChannel archiveChannel = tfd4j.getBot()
|
||||||
.getClient()
|
.getClient()
|
||||||
.getChannelById(SnowflakeEntry.archiveChannelID)
|
.getChannelById(SnowflakeEntry.ARCHIVE_REPORT_CHANNEL_ID.getSnowflake())
|
||||||
.ofType(TextChannel.class)
|
.ofType(TextChannel.class)
|
||||||
.blockOptional()
|
.blockOptional()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
@ -3,18 +3,33 @@ package me.totalfreedom.discord.util;
|
|||||||
import discord4j.common.util.Snowflake;
|
import discord4j.common.util.Snowflake;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
|
||||||
public class SnowflakeEntry
|
public enum SnowflakeEntry
|
||||||
{
|
{
|
||||||
public static final Snowflake adminChatChannelID = Snowflake.of(ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID.getString());
|
ADMIN_CHAT_CHANNEL_ID(ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID),
|
||||||
public static final Snowflake chatChannelID = Snowflake.of(ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString());
|
CHAT_CHANNEL_ID(ConfigEntry.DISCORD_CHAT_CHANNEL_ID),
|
||||||
public static final Snowflake serverID = Snowflake.of(ConfigEntry.DISCORD_SERVER_ID.getString());
|
REPORT_CHANNEL_ID(ConfigEntry.DISCORD_REPORT_CHANNEL_ID),
|
||||||
public static final Snowflake ownerRoleID = Snowflake.of(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString());
|
ARCHIVE_REPORT_CHANNEL_ID(ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID),
|
||||||
public static final Snowflake developerRoleID = Snowflake.of(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString());
|
//--
|
||||||
public static final Snowflake executiveRoleID = Snowflake.of(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString());
|
SERVER_ID(ConfigEntry.DISCORD_SERVER_ID),
|
||||||
public static final Snowflake assistantRoleID = Snowflake.of(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString());
|
//--
|
||||||
public static final Snowflake seniorRoleID = Snowflake.of(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString());
|
OWNER_ROLE_ID(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID),
|
||||||
public static final Snowflake adminRoleID = Snowflake.of(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString());
|
DEVELOPER_ROLE_ID(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID),
|
||||||
public static final Snowflake builderRoleID = Snowflake.of(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString());
|
EXECUTIVE_ROLE_ID(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID),
|
||||||
public static final Snowflake reportChannelID = Snowflake.of(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString());
|
ASSISTANT_EXECUTIVE_ROLE_ID(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID),
|
||||||
public static final Snowflake archiveChannelID = Snowflake.of(ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString());
|
SENIOR_ADMIN_ROLE_ID(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID),
|
||||||
|
ADMIN_ROLE_ID(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID),
|
||||||
|
MASTERBUILDER_ROLE_ID(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID);
|
||||||
|
|
||||||
|
|
||||||
|
private ConfigEntry entry;
|
||||||
|
|
||||||
|
SnowflakeEntry(ConfigEntry entry)
|
||||||
|
{
|
||||||
|
this.entry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snowflake getSnowflake()
|
||||||
|
{
|
||||||
|
return Snowflake.of(entry.getString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,36 +31,46 @@ public class TFM_Bridge
|
|||||||
{
|
{
|
||||||
Guild server = bot.getGuildById().block();
|
Guild server = bot.getGuildById().block();
|
||||||
// Server Owner
|
// Server Owner
|
||||||
if (server == null)
|
assert server != null;
|
||||||
{
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Snowflake ownerID = Snowflake.of(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString());
|
|
||||||
Snowflake developerID = Snowflake.of(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString());
|
|
||||||
Snowflake executiveID = Snowflake.of(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString());
|
|
||||||
Snowflake assistantExecutiveID = Snowflake.of(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString());
|
|
||||||
Snowflake seniorAdminID = Snowflake.of(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString());
|
|
||||||
Snowflake adminID = Snowflake.of(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString());
|
|
||||||
Snowflake masterBuilderID = Snowflake.of(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString());
|
|
||||||
|
|
||||||
Snowflake[] ids = {ownerID, developerID, executiveID, assistantExecutiveID, seniorAdminID, adminID, masterBuilderID};
|
|
||||||
String[] titles = {Title.OWNER.getColoredTag(), Title.DEVELOPER.getColoredTag(), Title.EXECUTIVE.getColoredTag(), Title.ASSTEXEC.getColoredTag(), Rank.SENIOR_ADMIN.getColoredTag(), Rank.ADMIN.getColoredTag(), Title.MASTER_BUILDER.getColoredTag()};
|
|
||||||
|
|
||||||
return member.getRoles().map(role ->
|
return member.getRoles().map(role ->
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ids.length; i++)
|
if (role.getId().equals(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
if (role.getId().equals(ids[i]))
|
return Title.OWNER.getColoredTag();
|
||||||
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake()))
|
||||||
{
|
{
|
||||||
return titles[i];
|
return Title.DEVELOPER.getColoredTag();
|
||||||
}
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||||
|
{
|
||||||
|
return Title.EXECUTIVE.getColoredTag();
|
||||||
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.ASSISTANT_EXECUTIVE_ROLE_ID.getSnowflake()))
|
||||||
|
{
|
||||||
|
return Title.ASSTEXEC.getColoredTag();
|
||||||
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake()))
|
||||||
|
{
|
||||||
|
return Rank.SENIOR_ADMIN.getColoredTag();
|
||||||
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake()))
|
||||||
|
{
|
||||||
|
return Rank.ADMIN.getColoredTag();
|
||||||
|
}
|
||||||
|
else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()))
|
||||||
|
{
|
||||||
|
return Title.MASTER_BUILDER.getColoredTag();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}).blockFirst();
|
}).blockFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TotalFreedomMod getCommons() {
|
public TotalFreedomMod getCommons()
|
||||||
|
{
|
||||||
return commons;
|
return commons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user