geforkt von SteamWar/BungeeCore
Fix TeamCommand
Fix IngameChatListener
Dieser Commit ist enthalten in:
Ursprung
9e4dbcdbb8
Commit
c0ef12829b
@ -37,7 +37,6 @@ public abstract class BasicDiscordCommand extends CommandData {
|
|||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null) {
|
if (steamwarUser == null) {
|
||||||
event.reply("Du hast keine Verknüpfung registriert.").setEphemeral(true).complete();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return steamwarUser;
|
return steamwarUser;
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.sql.SteamwarUser;
|
|||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.api.entities.Emoji;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -44,6 +45,8 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Emoji emoji = Emoji.fromUnicode("U+1F7E2");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandEvent event) {
|
||||||
SteamwarUser steamwarUser = getSteamwarUser(event);
|
SteamwarUser steamwarUser = getSteamwarUser(event);
|
||||||
@ -75,9 +78,8 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
embedBuilder.setColor(Color.GRAY);
|
embedBuilder.setColor(Color.GRAY);
|
||||||
List<SteamwarUser> members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList());
|
List<SteamwarUser> members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList());
|
||||||
|
|
||||||
embedBuilder.addField("Leader", "`" + members.stream().filter(SteamwarUser::isLeader).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false);
|
embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
||||||
embedBuilder.addField("Member", "`" + members.stream().filter(user -> !user.isLeader()).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false);
|
embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
||||||
embedBuilder.addField("Online", "`" + members.stream().filter(user -> ProxyServer.getInstance().getPlayer(user.getUuid()) != null).map(SteamwarUser::getUserName).collect(Collectors.joining("` `")) + "`", false);
|
|
||||||
embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
|
embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
|
||||||
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
|
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
|
||||||
return;
|
return;
|
||||||
@ -87,4 +89,8 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isOnline(SteamwarUser user) {
|
||||||
|
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class IngameChatListener extends BasicDiscordListener {
|
|||||||
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL);
|
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.INGAME_CHANNEL);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`"));
|
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
|
||||||
textChannel.sendMessage(messageBuilder.build()).complete();
|
textChannel.sendMessage(messageBuilder.build()).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren