Add option to log channels to console

This commit is contained in:
Josh Roy 2021-07-05 15:21:56 -04:00
parent 12cc0b99f9
commit db027bced3
3 changed files with 17 additions and 0 deletions

View File

@ -121,6 +121,10 @@ public class DiscordSettings implements IConf {
return config.getBoolean("chat.show-all-chat", false); return config.getBoolean("chat.show-all-chat", false);
} }
public List<String> getRelayToConsoleList() {
return config.getList("chat.relay-to-console", String.class);
}
public String getConsoleChannelDef() { public String getConsoleChannelDef() {
return config.getString("console.channel", "none"); return config.getString("console.channel", "none");
} }

View File

@ -88,12 +88,20 @@ public class DiscordListener extends ListenerAdapter {
event.getChannel().getName(), user.getName(), user.getDiscriminator(), user.getAsTag(), event.getChannel().getName(), user.getName(), user.getDiscriminator(), user.getAsTag(),
member.getEffectiveName(), DiscordUtil.getRoleColorFormat(member), finalMessage, DiscordUtil.getRoleFormat(member)), EmojiParser.FitzpatrickAction.REMOVE); member.getEffectiveName(), DiscordUtil.getRoleColorFormat(member), finalMessage, DiscordUtil.getRoleFormat(member)), EmojiParser.FitzpatrickAction.REMOVE);
for (final String group : keys) {
if (plugin.getSettings().getRelayToConsoleList().contains(group)) {
logger.info(formattedMessage);
break;
}
}
for (IUser essUser : plugin.getPlugin().getEss().getOnlineUsers()) { for (IUser essUser : plugin.getPlugin().getEss().getOnlineUsers()) {
for (String group : keys) { for (String group : keys) {
final String perm = "essentials.discord.receive." + group; final String perm = "essentials.discord.receive." + group;
final boolean primaryOverride = plugin.getSettings().isAlwaysReceivePrimary() && group.equalsIgnoreCase("primary"); final boolean primaryOverride = plugin.getSettings().isAlwaysReceivePrimary() && group.equalsIgnoreCase("primary");
if (primaryOverride || (essUser.isPermissionSet(perm) && essUser.isAuthorized(perm))) { if (primaryOverride || (essUser.isPermissionSet(perm) && essUser.isAuthorized(perm))) {
essUser.sendMessage(formattedMessage); essUser.sendMessage(formattedMessage);
break;
} }
} }
} }

View File

@ -61,6 +61,11 @@ chat:
# Whether or not to show all Minecraft chat messages that are not shown to all players. # Whether or not to show all Minecraft chat messages that are not shown to all players.
# You shouldn't need to enable this unless you're not seeing all chat messages go through to Discord. # You shouldn't need to enable this unless you're not seeing all chat messages go through to Discord.
show-all-chat: false show-all-chat: false
# A list of Discord channels which should be logged to console.
# If you want to use the channels below, remember to uncomment the line by removing the '#' before the '-'.
relay-to-console:
#- primary
#- chat
# Console relay settings # Console relay settings
# The console relay sends every message shown in the console to a Discord channel. # The console relay sends every message shown in the console to a Discord channel.