geforkt von SteamWar/BungeeCore
Port Discord Bot to JDA 5.0
Dieser Commit ist enthalten in:
Ursprung
8a20d41f95
Commit
40e61f7000
@ -97,7 +97,7 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly 'de.steamwar:waterfall:RELEASE'
|
compileOnly 'de.steamwar:waterfall:RELEASE'
|
||||||
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
|
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
|
||||||
implementation("net.dv8tion:JDA:4.4.0_352") {
|
implementation("net.dv8tion:JDA:5.0.0-beta.4") {
|
||||||
exclude module: 'opus-java'
|
exclude module: 'opus-java'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ package de.steamwar.bungeecore.bot;
|
|||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -56,9 +56,9 @@ public class AuthManager {
|
|||||||
Member member = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).retrieveMemberById(TOKENS.get(code).longValue()).complete();
|
Member member = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).retrieveMemberById(TOKENS.get(code).longValue()).complete();
|
||||||
if(member == null) return null;
|
if(member == null) return null;
|
||||||
user.setDiscordId(member.getIdLong());
|
user.setDiscordId(member.getIdLong());
|
||||||
MessageBuilder builder = new MessageBuilder();
|
MessageCreateBuilder builder = new MessageCreateBuilder();
|
||||||
builder.setContent(":white_check_mark: Dein Discord Konto wurde mit **" + user.getUserName() + "** verknüpft");
|
builder.setContent(":white_check_mark: Dein Discord Konto wurde mit **" + user.getUserName() + "** verknüpft");
|
||||||
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht")));
|
builder.setComponents(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
member.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(builder.build()).queue());
|
member.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(builder.build()).queue());
|
||||||
|
@ -76,11 +76,7 @@ public class SteamwarDiscordBot {
|
|||||||
JDABuilder builder = JDABuilder.createDefault(SteamwarDiscordBotConfig.TOKEN);
|
JDABuilder builder = JDABuilder.createDefault(SteamwarDiscordBotConfig.TOKEN);
|
||||||
builder.setStatus(OnlineStatus.ONLINE);
|
builder.setStatus(OnlineStatus.ONLINE);
|
||||||
builder.setMemberCachePolicy(MemberCachePolicy.ONLINE);
|
builder.setMemberCachePolicy(MemberCachePolicy.ONLINE);
|
||||||
try {
|
jda = builder.build();
|
||||||
jda = builder.build();
|
|
||||||
} catch (LoginException e) {
|
|
||||||
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
|
||||||
}
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
jda.awaitReady();
|
jda.awaitReady();
|
||||||
@ -131,8 +127,8 @@ public class SteamwarDiscordBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {
|
private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {
|
||||||
commands.addCommands(basicDiscordCommand);
|
commands.addCommands(basicDiscordCommand.getData());
|
||||||
discordCommandMap.put(basicDiscordCommand.getName(), basicDiscordCommand);
|
discordCommandMap.put(basicDiscordCommand.getData().getName(), basicDiscordCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.Message;
|
|||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -33,13 +33,13 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
public BanCommand() {
|
public BanCommand() {
|
||||||
super("ban", "Banne einen Nutzer, wenn du die Rechte hast.");
|
super("ban", "Banne einen Nutzer, wenn du die Rechte hast.");
|
||||||
|
|
||||||
addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
getData().addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
||||||
addOption(OptionType.STRING, "time", "Bis Wann", true);
|
getData().addOption(OptionType.STRING, "time", "Bis Wann", true);
|
||||||
addOption(OptionType.STRING, "reason", "Warum", true);
|
getData().addOption(OptionType.STRING, "reason", "Warum", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
if (!testPermission(event)) {
|
if (!testPermission(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,27 +22,33 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class BasicDiscordCommand extends CommandData {
|
public abstract class BasicDiscordCommand {
|
||||||
|
|
||||||
|
private final SlashCommandData data;
|
||||||
|
|
||||||
protected BasicDiscordCommand(String name, String description) {
|
protected BasicDiscordCommand(String name, String description) {
|
||||||
super(name, description);
|
data = Commands.slash(name, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void run(SlashCommandEvent event);
|
public SlashCommandData getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
protected SteamwarUser getSteamwarUser(SlashCommandEvent event) {
|
public abstract void run(SlashCommandInteractionEvent event);
|
||||||
|
|
||||||
|
protected SteamwarUser getSteamwarUser(SlashCommandInteractionEvent event) {
|
||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return steamwarUser;
|
return steamwarUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean testPermission(SlashCommandEvent event) {
|
protected boolean testPermission(SlashCommandInteractionEvent event) {
|
||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) {
|
if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public class ListCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
de.steamwar.bungeecore.commands.ListCommand.getCustomTablist();
|
de.steamwar.bungeecore.commands.ListCommand.getCustomTablist();
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle("List");
|
embedBuilder.setTitle("List");
|
||||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.Message;
|
|||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -33,13 +33,13 @@ public class MuteCommand extends BasicDiscordCommand {
|
|||||||
public MuteCommand() {
|
public MuteCommand() {
|
||||||
super("mute", "Mute einen Nutzer, wenn du die Rechte hast.");
|
super("mute", "Mute einen Nutzer, wenn du die Rechte hast.");
|
||||||
|
|
||||||
addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
getData().addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
||||||
addOption(OptionType.STRING, "time", "Bis Wann", true);
|
getData().addOption(OptionType.STRING, "time", "Bis Wann", true);
|
||||||
addOption(OptionType.STRING, "reason", "Warum", true);
|
getData().addOption(OptionType.STRING, "reason", "Warum", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
if (!testPermission(event)) {
|
if (!testPermission(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ 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.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
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;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
@ -40,7 +40,7 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
public TeamCommand() {
|
public TeamCommand() {
|
||||||
super("team", "Alle Team bezogenen Befehle");
|
super("team", "Alle Team bezogenen Befehle");
|
||||||
|
|
||||||
addSubcommands(new SubcommandData("info", "Infos über das Team oder deins")
|
getData().addSubcommands(new SubcommandData("info", "Infos über das Team oder deins")
|
||||||
.addOption(OptionType.STRING, "team", "Name oder Kuerzel", false)
|
.addOption(OptionType.STRING, "team", "Name oder Kuerzel", false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
private Emoji emoji = Emoji.fromUnicode("U+1F7E2");
|
private Emoji emoji = Emoji.fromUnicode("U+1F7E2");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
SteamwarUser steamwarUser = getSteamwarUser(event);
|
SteamwarUser steamwarUser = getSteamwarUser(event);
|
||||||
|
|
||||||
if (event.getSubcommandName() != null) {
|
if (event.getSubcommandName() != null) {
|
||||||
@ -78,8 +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(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsReactionCode() : "") + user.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("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsReactionCode() : "") + user.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).queue();
|
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -32,11 +32,11 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
public UnbanCommand() {
|
public UnbanCommand() {
|
||||||
super("unban", "Entbannt einen Nutzer, wenn du die Rechte hast.");
|
super("unban", "Entbannt einen Nutzer, wenn du die Rechte hast.");
|
||||||
|
|
||||||
addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
getData().addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
if (!testPermission(event)) {
|
if (!testPermission(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import de.steamwar.bungeecore.sql.Punishment;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -35,11 +35,11 @@ public class WhoisCommand extends BasicDiscordCommand {
|
|||||||
public WhoisCommand() {
|
public WhoisCommand() {
|
||||||
super("whois", "Der whois Befehl");
|
super("whois", "Der whois Befehl");
|
||||||
|
|
||||||
addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
getData().addOption(OptionType.STRING, "user", "Der Benutzer", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(SlashCommandEvent event) {
|
public void run(SlashCommandInteractionEvent event) {
|
||||||
if (!testPermission(event)) {
|
if (!testPermission(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.bot.config;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import net.dv8tion.jda.api.interactions.components.ButtonStyle;
|
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.config;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.bot.config;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
import net.dv8tion.jda.api.interactions.components.ButtonStyle;
|
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -27,12 +27,15 @@ import de.steamwar.bungeecore.sql.Team;
|
|||||||
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.selections.SelectionMenu;
|
import net.dv8tion.jda.api.interactions.components.Component;
|
||||||
|
import net.dv8tion.jda.api.interactions.components.selections.SelectMenu;
|
||||||
|
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -50,7 +53,7 @@ public class EventManager {
|
|||||||
static {
|
static {
|
||||||
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL);
|
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
if(textChannel.hasLatestMessage()) {
|
if(textChannel.getLatestMessageIdLong() != 0) {
|
||||||
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +73,7 @@ public class EventManager {
|
|||||||
embedBuilder.setAuthor("SteamWar", "https://www.steamwar.de");
|
embedBuilder.setAuthor("SteamWar", "https://www.steamwar.de");
|
||||||
|
|
||||||
Timestamp now = Timestamp.from(Instant.now());
|
Timestamp now = Timestamp.from(Instant.now());
|
||||||
SelectionMenu.Builder menuBuilder = SelectionMenu.create("eventName");
|
StringSelectMenu.Builder menuBuilder = StringSelectMenu.create("eventName");
|
||||||
menuBuilder.setPlaceholder("Wähle ein Event aus!")
|
menuBuilder.setPlaceholder("Wähle ein Event aus!")
|
||||||
.setMinValues(1)
|
.setMinValues(1)
|
||||||
.setMaxValues(1);
|
.setMaxValues(1);
|
||||||
@ -91,15 +94,15 @@ public class EventManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) {
|
if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) {
|
||||||
messageBuilder.setActionRows(ActionRow.of(menuBuilder.build()));
|
messageBuilder.setComponents(ActionRow.of(menuBuilder.build()));
|
||||||
}
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message = textChannel.sendMessage(messageBuilder.build()).complete();
|
message = textChannel.sendMessage(messageBuilder.build()).complete();
|
||||||
} else {
|
} else {
|
||||||
message.editMessage(messageBuilder.build()).complete();
|
message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +134,12 @@ public class EventManager {
|
|||||||
embedBuilder.addField(teamBlue.getTeamKuerzel() + " vs. " + teamRed.getTeamKuerzel(), st.toString(), true);
|
embedBuilder.addField(teamBlue.getTeamKuerzel() + " vs. " + teamRed.getTeamKuerzel(), st.toString(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
||||||
} else {
|
} else {
|
||||||
message.editMessage(messageBuilder.build()).complete();
|
message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,10 @@ import de.steamwar.bungeecore.commands.CheckCommand;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ public class SchematicsManager {
|
|||||||
static {
|
static {
|
||||||
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.SCHEMATICS_CHANNEL);
|
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.SCHEMATICS_CHANNEL);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
if(textChannel.hasLatestMessage()) {
|
if(textChannel.getLatestMessageIdLong() != 0) {
|
||||||
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,12 +63,12 @@ public class SchematicsManager {
|
|||||||
embedBuilder.addField(schematic.getName(), st.toString(), true);
|
embedBuilder.addField(schematic.getName(), st.toString(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
||||||
} else {
|
} else {
|
||||||
message.editMessage(messageBuilder.build()).queue();
|
message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,18 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AnnouncementListener extends BasicDiscordListener {
|
public class AnnouncementListener extends BasicDiscordListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||||
|
if(!event.isFromGuild()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL)) {
|
if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,8 +46,8 @@ public class AnnouncementListener extends BasicDiscordListener {
|
|||||||
public void announce(String message) {
|
public void announce(String message) {
|
||||||
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL);
|
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.append(message.replace("&", ""));
|
messageBuilder.setContent(message.replace("&", ""));
|
||||||
textChannel.sendMessage(messageBuilder.build()).queue();
|
textChannel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
import de.steamwar.bungeecore.bot.AuthManager;
|
import de.steamwar.bungeecore.bot.AuthManager;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.entities.ChannelType;
|
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ import de.steamwar.bungeecore.listeners.ChatListener;
|
|||||||
import de.steamwar.bungeecore.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -48,7 +48,10 @@ public class DiscordChatListener extends BasicDiscordListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||||
|
if(!event.isFromGuild()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!event.getChannel().getId().equals(channel) || event.getAuthor().isBot())
|
if (!event.getChannel().getId().equals(channel) || event.getAuthor().isBot())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -64,8 +67,8 @@ public class DiscordChatListener extends BasicDiscordListener {
|
|||||||
public void send(String message) {
|
public void send(String message) {
|
||||||
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(channel);
|
TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(channel);
|
||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
|
messageBuilder.setContent(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
|
||||||
textChannel.sendMessage(messageBuilder.build()).queue();
|
textChannel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import de.steamwar.bungeecore.sql.Event;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
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.events.interaction.SelectionMenuEvent;
|
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.components.Component;
|
import net.dv8tion.jda.api.interactions.components.Component;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ public class DiscordEventListener extends BasicDiscordListener {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionMenu(@NotNull SelectionMenuEvent event) {
|
public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent event) {
|
||||||
if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.EVENTS_CHANNEL) && event.getComponentType() == Component.Type.SELECTION_MENU) {
|
if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.EVENTS_CHANNEL) && event.getComponentType() == Component.Type.STRING_SELECT) {
|
||||||
if(event.getSelectedOptions().isEmpty()) {
|
if(event.getSelectedOptions().isEmpty()) {
|
||||||
event.deferReply(true).queue();
|
event.deferReply(true).queue();
|
||||||
return;
|
return;
|
||||||
|
@ -25,18 +25,22 @@ import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
|||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.*;
|
import net.dv8tion.jda.api.entities.*;
|
||||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.entities.channel.concrete.Category;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
@ -44,22 +48,21 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
||||||
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getParent() != null && event.getTextChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getChannel().asTextChannel().getParentCategoryIdLong() != 0 && event.getChannel().asTextChannel().getParentCategoryId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
||||||
if(event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) {
|
if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) {
|
||||||
DiscordTicketType ticketType = SteamwarDiscordBotConfig.TICKET_TYPES.get(event.getComponentId());
|
DiscordTicketType ticketType = SteamwarDiscordBotConfig.TICKET_TYPES.get(event.getComponentId());
|
||||||
Category ct = event.getGuild().getCategoryById(SteamwarDiscordBotConfig.TICKET_CATEGORY);
|
Category ct = event.getGuild().getCategoryById(SteamwarDiscordBotConfig.TICKET_CATEGORY);
|
||||||
SteamwarUser swUser = SteamwarUser.get(event.getUser().getIdLong());
|
SteamwarUser swUser = SteamwarUser.get(event.getUser().getIdLong());
|
||||||
TextChannel ticketChannel = ct.createTextChannel((swUser == null?event.getUser().getName():swUser.getUserName()) + "-" + event.getComponentId() + "-" + System.currentTimeMillis() % 1000).complete();
|
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,
|
ticketChannel.upsertPermissionOverride(event.getMember()).setAllowed(Permission.VIEW_CHANNEL,
|
||||||
Permission.MESSAGE_WRITE,
|
Permission.MESSAGE_SEND,
|
||||||
Permission.MESSAGE_ATTACH_FILES,
|
Permission.MESSAGE_ATTACH_FILES,
|
||||||
Permission.MESSAGE_ADD_REACTION,
|
Permission.MESSAGE_ADD_REACTION,
|
||||||
Permission.MESSAGE_READ,
|
|
||||||
Permission.MESSAGE_EMBED_LINKS,
|
Permission.MESSAGE_EMBED_LINKS,
|
||||||
Permission.MESSAGE_HISTORY).complete();
|
Permission.MESSAGE_HISTORY).complete();
|
||||||
ticketChannel.getManager().setTopic(event.getUser().getId()).complete();
|
ticketChannel.getManager().setTopic(event.getUser().getId()).complete();
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
EmbedBuilder builder = new EmbedBuilder();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
builder.setDescription(ticketType.getPreMessage());
|
builder.setDescription(ticketType.getPreMessage());
|
||||||
builder.setTitle("Steamwar Ticket");
|
builder.setTitle("Steamwar Ticket");
|
||||||
@ -67,7 +70,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
|
|
||||||
Button closeButton = Button.danger("close-" + ticketChannel.getName(), "Schließen").withEmoji(Emoji.fromUnicode("U+26A0"));
|
Button closeButton = Button.danger("close-" + ticketChannel.getName(), "Schließen").withEmoji(Emoji.fromUnicode("U+26A0"));
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(closeButton));
|
messageBuilder.setComponents(ActionRow.of(closeButton));
|
||||||
|
|
||||||
ticketChannel.sendMessage(messageBuilder.build()).complete();
|
ticketChannel.sendMessage(messageBuilder.build()).complete();
|
||||||
event.reply(SteamwarDiscordBotConfig.TICKET_CREATED.replace("%channel%", ticketChannel.getAsMention())).setEphemeral(true).complete();
|
event.reply(SteamwarDiscordBotConfig.TICKET_CREATED.replace("%channel%", ticketChannel.getAsMention())).setEphemeral(true).complete();
|
||||||
@ -78,7 +81,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
LinkedList<StringBuilder> stringBuilders = new LinkedList<>();
|
LinkedList<StringBuilder> stringBuilders = new LinkedList<>();
|
||||||
stringBuilders.add(new StringBuilder());
|
stringBuilders.add(new StringBuilder());
|
||||||
|
|
||||||
new LinkedList<>(event.getTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> {
|
new LinkedList<>(event.getChannel().asTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> {
|
||||||
if(message.getAuthor().isSystem() || message.getAuthor().isBot()) return;
|
if(message.getAuthor().isSystem() || message.getAuthor().isBot()) return;
|
||||||
StringBuilder currentBuilder = new StringBuilder();
|
StringBuilder currentBuilder = new StringBuilder();
|
||||||
currentBuilder.append("<t:").append(message.getTimeCreated().toInstant().getEpochSecond()).append("> ")
|
currentBuilder.append("<t:").append(message.getTimeCreated().toInstant().getEpochSecond()).append("> ")
|
||||||
@ -112,39 +115,42 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
|
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setColor(Color.GREEN);
|
embedBuilder.setColor(Color.GREEN);
|
||||||
User user = event.getJDA().retrieveUserById(event.getTextChannel().getTopic()).complete();
|
User user = event.getJDA().retrieveUserById(event.getChannel().asTextChannel().getTopic()).complete();
|
||||||
SteamwarUser swuser = SteamwarUser.get(user.getIdLong());
|
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.setAuthor(user.getName(), swuser==null?"https://steamwar.de/":("https://steamwar.de/users/" + swuser.getUserName().toLowerCase() + "/"), user.getAvatarUrl());
|
||||||
embedBuilder.setTimestamp(Instant.now());
|
embedBuilder.setTimestamp(Instant.now());
|
||||||
embedBuilder.setTitle(event.getTextChannel().getName());
|
embedBuilder.setTitle(event.getChannel().asTextChannel().getName());
|
||||||
stringBuilders.forEach(stringBuilder -> {
|
stringBuilders.forEach(stringBuilder -> {
|
||||||
embedBuilder.setDescription(stringBuilder.toString());
|
embedBuilder.setDescription(stringBuilder.toString());
|
||||||
MessageBuilder builder = new MessageBuilder();
|
MessageCreateBuilder builder = new MessageCreateBuilder();
|
||||||
builder.setEmbeds(embedBuilder.build());
|
builder.setEmbeds(embedBuilder.build());
|
||||||
|
|
||||||
logChannel.sendMessage(builder.build()).queue();
|
logChannel.sendMessage(builder.build()).queue();
|
||||||
});
|
});
|
||||||
|
|
||||||
Message.team("DISCORD_TICKET_CLOSED", event.getTextChannel().getName());
|
Message.team("DISCORD_TICKET_CLOSED", event.getChannel().getName());
|
||||||
event.getTextChannel().delete().reason("Closed").queue();
|
event.getChannel().asTextChannel().delete().reason("Closed").queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||||
if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
if(!event.isFromGuild()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(event.getChannel().asTextChannel().getParentCategoryIdLong() != 0 && event.getChannel().asTextChannel().getParentCategoryId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
||||||
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
boolean sendMessage;
|
boolean sendMessage;
|
||||||
if(user.getDiscordId() == null) {
|
if(user.getDiscordId() == null) {
|
||||||
sendMessage = user.getUserGroup().isCheckSchematics();
|
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||||
} else {
|
} else {
|
||||||
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
|
if(event.getAuthor().getIdLong() == user.getDiscordId()) return;
|
||||||
sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.getUserGroup().isCheckSchematics();
|
sendMessage = user.getDiscordId().toString().equals(event.getChannel().asTextChannel().getTopic()) || user.getUserGroup().isCheckSchematics();
|
||||||
}
|
}
|
||||||
if(sendMessage) {
|
if(sendMessage) {
|
||||||
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());
|
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());
|
||||||
|
@ -23,15 +23,20 @@ import de.steamwar.bungeecore.sql.Punishment;
|
|||||||
import de.steamwar.bungeecore.sql.SchematicNode;
|
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class PrivateMessageListener extends BasicDiscordListener {
|
public class PrivateMessageListener extends BasicDiscordListener {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
|
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
|
||||||
|
if(!event.isFromType(ChannelType.PRIVATE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!event.getMessage().getAttachments().isEmpty()) {
|
if(!event.getMessage().getAttachments().isEmpty()) {
|
||||||
SteamwarUser user = SteamwarUser.get(event.getAuthor().getIdLong());
|
SteamwarUser user = SteamwarUser.get(event.getAuthor().getIdLong());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@ -47,7 +52,7 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
|||||||
for (Message.Attachment attachment : event.getMessage().getAttachments()) {
|
for (Message.Attachment attachment : event.getMessage().getAttachments()) {
|
||||||
if(attachment.getFileExtension() == null ||
|
if(attachment.getFileExtension() == null ||
|
||||||
(!attachment.getFileExtension().equalsIgnoreCase("schem") &&
|
(!attachment.getFileExtension().equalsIgnoreCase("schem") &&
|
||||||
!attachment.getFileExtension().equalsIgnoreCase("schematic"))) {
|
!attachment.getFileExtension().equalsIgnoreCase("schematic"))) {
|
||||||
event.getMessage().reply("`" + attachment.getFileName() + "` wird ignoriert, da die Datei keine Schematic ist").queue();
|
event.getMessage().reply("`" + attachment.getFileName() + "` wird ignoriert, da die Datei keine Schematic ist").queue();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,17 @@
|
|||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import net.dv8tion.jda.api.entities.ChannelType;
|
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class RolesInteractionButtonListener extends BasicDiscordListener {
|
public class RolesInteractionButtonListener extends BasicDiscordListener {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
|
||||||
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) {
|
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) {
|
||||||
if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) {
|
if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) {
|
||||||
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
||||||
event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
|
event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SlashCommandListener extends BasicDiscordListener {
|
public class SlashCommandListener extends BasicDiscordListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlashCommand(@NotNull SlashCommandEvent event) {
|
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||||
SteamwarDiscordBot.getDiscordCommandMap().get(event.getName()).run(event);
|
SteamwarDiscordBot.getDiscordCommandMap().get(event.getName()).run(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,12 @@ package de.steamwar.bungeecore.bot.util;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,17 +40,17 @@ public class DiscordRolesMessage {
|
|||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
|
|
||||||
MessageBuilder builder = new MessageBuilder();
|
MessageCreateBuilder builder = new MessageCreateBuilder();
|
||||||
builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE);
|
builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE);
|
||||||
List<Button> buttons = new ArrayList<>();
|
List<Button> buttons = new ArrayList<>();
|
||||||
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
|
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
|
||||||
builder.setActionRows(ActionRow.of(buttons));
|
builder.setComponents(ActionRow.of(buttons));
|
||||||
|
|
||||||
if(channel.hasLatestMessage()) {
|
if(channel.getLatestMessageIdLong() != 0) {
|
||||||
channel.getIterableHistory().queue(messages -> {
|
channel.getIterableHistory().queue(messages -> {
|
||||||
Message message = messages.stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
Message message = messages.stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.editMessage(builder.build()).queue();
|
message.editMessage(MessageEditData.fromCreateData(builder.build())).queue();
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(builder.build()).queue();
|
channel.sendMessage(builder.build()).queue();
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,13 @@ import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
|||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -41,7 +42,7 @@ public class DiscordRulesMessage {
|
|||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.RULES_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.RULES_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
Message message = null;
|
Message message = null;
|
||||||
if(channel.hasLatestMessage()) {
|
if(channel.getLatestMessageIdLong() != 0) {
|
||||||
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,11 +57,11 @@ public class DiscordRulesMessage {
|
|||||||
|
|
||||||
Button authButton = Button.primary("auth", Emoji.fromUnicode("U+2705")).withLabel("Minecraft verknüpfen");
|
Button authButton = Button.primary("auth", Emoji.fromUnicode("U+2705")).withLabel("Minecraft verknüpfen");
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
|
messageBuilder.setComponents(ActionRow.of(buttons), ActionRow.of(authButton));
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.editMessage(messageBuilder.build()).queue();
|
message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).queue();
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).queue();
|
channel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ import de.steamwar.bungeecore.sql.SchematicNode;
|
|||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -46,7 +46,7 @@ public class DiscordSchemAlert {
|
|||||||
builder.setDescription("Deine Schematic **" + schematic.getName() + "** wurde abgelehnt. **Grund:** \n" + reason);
|
builder.setDescription("Deine Schematic **" + schematic.getName() + "** wurde abgelehnt. **Grund:** \n" + reason);
|
||||||
builder.setTimestamp(Instant.now());
|
builder.setTimestamp(Instant.now());
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
try {
|
try {
|
||||||
dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).queue();
|
dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).queue();
|
||||||
@ -66,9 +66,9 @@ public class DiscordSchemAlert {
|
|||||||
builder.setDescription("Deine Schematic **" + schematic.getName() + "** wurde angenommen.");
|
builder.setDescription("Deine Schematic **" + schematic.getName() + "** wurde angenommen.");
|
||||||
builder.setTimestamp(Instant.now());
|
builder.setTimestamp(Instant.now());
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
|
messageBuilder.setComponents(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
|
||||||
try {
|
try {
|
||||||
dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).queue();
|
dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -24,11 +24,12 @@ import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
|||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
import net.dv8tion.jda.api.interactions.components.ActionRow;
|
||||||
import net.dv8tion.jda.api.interactions.components.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
|
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -42,7 +43,7 @@ public class DiscordTicketMessage {
|
|||||||
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.TICKET_CHANNEL);
|
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.TICKET_CHANNEL);
|
||||||
assert channel != null;
|
assert channel != null;
|
||||||
Message message = null;
|
Message message = null;
|
||||||
if(channel.hasLatestMessage()) {
|
if(channel.getLatestMessageIdLong() != 0) {
|
||||||
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,11 +57,11 @@ public class DiscordTicketMessage {
|
|||||||
buttons.add(discordTicketTypes.stream().map(DiscordTicketType::toButton).collect(Collectors.toList()));
|
buttons.add(discordTicketTypes.stream().map(DiscordTicketType::toButton).collect(Collectors.toList()));
|
||||||
});
|
});
|
||||||
|
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageCreateBuilder messageBuilder = new MessageCreateBuilder();
|
||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(buttons.stream().map(ActionRow::of).collect(Collectors.toList()));
|
messageBuilder.setComponents(buttons.stream().map(ActionRow::of).collect(Collectors.toList()));
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.editMessage(messageBuilder.build()).queue();
|
message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).queue();
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).queue();
|
channel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren