SteamWar/BungeeCore
Archiviert
13
2

Fix DC alerts, DC commands, Poll command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Lixfel 2024-06-29 23:39:09 +02:00
Ursprung ff6fe9eeb5
Commit e7f0e57e9d
4 geänderte Dateien mit 29 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@ public class PollCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(Chatter sender) { public void genericCommand(@Validator Chatter sender) {
PollSystem.sendPoll(sender); PollSystem.sendPoll(sender);
} }

Datei anzeigen

@ -51,10 +51,6 @@ public class DiscordChannel extends Chatter.PlayerlessChatter {
this(userOrPublic(user), user.openPrivateChannel().complete()); this(userOrPublic(user), user.openPrivateChannel().complete());
} }
public DiscordChannel(SteamwarUser user) {
this(user, DiscordBot.getInstance().getJda().getUserById(user.getDiscordId()).openPrivateChannel().complete());
}
public DiscordChannel(String channel) { public DiscordChannel(String channel) {
this(SteamwarUser.get(-1), DiscordBot.getGuild().getTextChannelById(channel)); this(SteamwarUser.get(-1), DiscordBot.getGuild().getTextChannelById(channel));
ChannelListener.getChannels().put(this.channel, this); ChannelListener.getChannels().put(this.channel, this);

Datei anzeigen

@ -37,7 +37,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
public class ChannelListener extends ListenerAdapter { public class ChannelListener extends ListenerAdapter {
@ -81,7 +80,12 @@ public class ChannelListener extends ListenerAdapter {
if(permission != null && !sender.user().perms().contains(permission)) if(permission != null && !sender.user().perms().contains(permission))
return; return;
command.execute(sender, Optional.ofNullable(event.getOption(DiscordBot.ARGUMENT_NAME)).map(OptionMapping::getAsString).orElse("").split(" ")); OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME);
String args = "";
if(option != null)
args = option.getAsString();
command.execute(sender, args.split(" "));
}); });
} }
} }

Datei anzeigen

@ -19,14 +19,15 @@
package de.steamwar.velocitycore.discord.util; package de.steamwar.velocitycore.discord.util;
import de.steamwar.messages.Chatter;
import de.steamwar.messages.Message; import de.steamwar.messages.Message;
import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.channels.DiscordChannel; import de.steamwar.velocitycore.discord.channels.DiscordChannel;
import de.steamwar.messages.Chatter;
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.MessageBuilder;
import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.entities.Emoji;
import net.dv8tion.jda.api.entities.User;
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.Button;
@ -37,8 +38,13 @@ import java.time.Instant;
public class DiscordAlert { public class DiscordAlert {
public static void send(Chatter player, Color color, Message title, Message description, boolean success) { public static void send(Chatter player, Color color, Message title, Message description, boolean success) {
DiscordBot.withBot(bot -> {
Long discordId = player.user().getDiscordId(); Long discordId = player.user().getDiscordId();
if(DiscordBot.getInstance() == null || discordId == null) if(discordId == null)
return;
User user = DiscordBot.getInstance().getJda().getUserById(discordId);
if(user == null)
return; return;
MessageBuilder builder = new MessageBuilder() MessageBuilder builder = new MessageBuilder()
@ -52,6 +58,7 @@ public class DiscordAlert {
if(success) if(success)
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")))); builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
new DiscordChannel(player.user()).send(builder); new DiscordChannel(user).send(builder);
});
} }
} }