SteamWar/BungeeCore
Archiviert
13
2

Latest and Greatest

Dieser Commit ist enthalten in:
Chaoscaot 2021-07-28 21:39:35 +02:00
Ursprung 95ab4d3344
Commit 8de19123b9
4 geänderte Dateien mit 47 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -35,6 +35,7 @@ import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
import net.md_5.bungee.api.ProxyServer;

Datei anzeigen

@ -19,16 +19,22 @@
package de.steamwar.bungeecore.bot.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.interactions.InteractionType;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
import net.dv8tion.jda.api.interactions.components.selections.SelectionMenu;
import net.md_5.bungee.api.chat.ClickEvent;
import org.jetbrains.annotations.NotNull;
import java.awt.Color;
@ -43,7 +49,8 @@ public class DiscordTicketListener extends BasicDiscordListener {
if(event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) {
DiscordTicketType ticketType = SteamwarDiscordBotConfig.TICKET_TYPES.get(event.getComponentId());
Category ct = event.getGuild().getCategoryById(SteamwarDiscordBotConfig.TICKET_CATEGORY);
TextChannel ticketChannel = ct.createTextChannel(event.getUser().getName() + "-" + event.getComponentId() + "-" + System.currentTimeMillis() % 1000).complete();
SteamwarUser swUser = SteamwarUser.get(event.getUser().getIdLong());
TextChannel ticketChannel = ct.createTextChannel((swUser == null?event.getUser().getName():swUser.getUserName()) + "-" + event.getComponentId() + "-" + System.currentTimeMillis() % 1000).complete();
ticketChannel.createPermissionOverride(event.getMember()).setAllow(Permission.VIEW_CHANNEL,
Permission.MESSAGE_WRITE,
Permission.MESSAGE_ATTACH_FILES,
@ -51,6 +58,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
Permission.MESSAGE_READ,
Permission.MESSAGE_EMBED_LINKS,
Permission.MESSAGE_HISTORY).complete();
ticketChannel.getManager().setTopic(event.getUser().getId()).complete();
MessageBuilder messageBuilder = new MessageBuilder();
EmbedBuilder builder = new EmbedBuilder();
@ -64,6 +72,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
ticketChannel.sendMessage(messageBuilder.build()).complete();
event.reply(SteamwarDiscordBotConfig.TICKET_CREATED.replace("%channel%", ticketChannel.getAsMention())).setEphemeral(true).complete();
Message.team("DISCORD_TICKET_NEW", ticketChannel.getName());
} else if(event.getComponentId().startsWith("close-")) {
TextChannel logChannel = event.getGuild().getTextChannelById(SteamwarDiscordBotConfig.TICKET_LOG);
@ -71,6 +80,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
StringBuilder stringBuilder = new StringBuilder();
new LinkedList<>(event.getTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> {
if(message.getAuthor().isSystem() || message.getAuthor().isBot()) return;
stringBuilder.append("<t:").append(message.getTimeCreated().toInstant().getEpochSecond()).append("> ")
.append("**")
.append(message.getAuthor().getName())
@ -87,6 +97,10 @@ public class DiscordTicketListener extends BasicDiscordListener {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(Color.GREEN);
User user = event.getJDA().retrieveUserById(event.getTextChannel().getTopic()).complete();
SteamwarUser swuser = SteamwarUser.get(user.getIdLong());
embedBuilder.setAuthor(user.getName(), swuser==null?"https://steamwar.de/":("https://steamwar.de/users/" + swuser.getUserName().toLowerCase() + "/"), user.getAvatarUrl());
embedBuilder.setTimestamp(Instant.now());
embedBuilder.setTitle(event.getTextChannel().getName());
embedBuilder.setDescription(stringBuilder);
@ -95,8 +109,32 @@ public class DiscordTicketListener extends BasicDiscordListener {
logChannel.sendMessage(builder.build()).complete();
Message.team("DISCORD_TICKET_CLOSED", event.getTextChannel().getName());
event.getTextChannel().delete().reason("Closed").complete();
}
}
}
@Override
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
SteamwarUser user = SteamwarUser.get(player);
if(user.getDiscordId() == null) {
if(user.getUserGroup().isTeamGroup()) {
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
}
} else {
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
Member member = event.getGuild().retrieveMemberById(user.getDiscordId()).complete();
if(member.hasPermission(event.getChannel().getManager().getChannel(), Permission.MESSAGE_WRITE)) {
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
}
}
});
}
}
}
}

Datei anzeigen

@ -59,6 +59,7 @@ public class DiscordRanks {
}
guild.removeRoleFromMember(member, role).complete();
}
if (!needed.isEmpty()) {
guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
}

Datei anzeigen

@ -517,3 +517,8 @@ WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
VERIFY_USAGE=§c/verify [Code]
VERIFY_INVALID=§cInvalider Code
VERIFY_SUCCESS=§eErfolgreich mit dem Discord Account {0} verknüpft
#Discord
DISCORD_TICKET_MESSAGE=§3Ticket {0}§7» §f§l{1}: §7{2}
DISCORD_TICKET_NEW=§3Ticket {0}§7» §aTicket wurde geöffnet!
DISCORD_TICKET_CLOSED=§3Ticket {0}§7» §cTicket wurde geschlossen!