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
public void genericCommand(Chatter sender) {
public void genericCommand(@Validator Chatter sender) {
PollSystem.sendPoll(sender);
}

Datei anzeigen

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

Datei anzeigen

@ -37,7 +37,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;
public class ChannelListener extends ListenerAdapter {
@ -81,7 +80,12 @@ public class ChannelListener extends ListenerAdapter {
if(permission != null && !sender.user().perms().contains(permission))
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;
import de.steamwar.messages.Chatter;
import de.steamwar.messages.Message;
import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.channels.DiscordChannel;
import de.steamwar.messages.Chatter;
import lombok.experimental.UtilityClass;
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.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Button;
@ -37,21 +38,27 @@ import java.time.Instant;
public class DiscordAlert {
public static void send(Chatter player, Color color, Message title, Message description, boolean success) {
Long discordId = player.user().getDiscordId();
if(DiscordBot.getInstance() == null || discordId == null)
return;
DiscordBot.withBot(bot -> {
Long discordId = player.user().getDiscordId();
if(discordId == null)
return;
MessageBuilder builder = new MessageBuilder()
.setEmbeds(new EmbedBuilder()
.setAuthor("SteamWar", "https://steamwar.de", "https://cdn.discordapp.com/app-icons/869606970099904562/60c884000407c02671d91d8e7182b8a1.png")
.setColor(color)
.setTitle(player.parseToPlain(title))
.setDescription(player.parseToPlain(description))
.setTimestamp(Instant.now())
.build());
if(success)
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
User user = DiscordBot.getInstance().getJda().getUserById(discordId);
if(user == null)
return;
new DiscordChannel(player.user()).send(builder);
MessageBuilder builder = new MessageBuilder()
.setEmbeds(new EmbedBuilder()
.setAuthor("SteamWar", "https://steamwar.de", "https://cdn.discordapp.com/app-icons/869606970099904562/60c884000407c02671d91d8e7182b8a1.png")
.setColor(color)
.setTitle(player.parseToPlain(title))
.setDescription(player.parseToPlain(description))
.setTimestamp(Instant.now())
.build());
if(success)
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
new DiscordChannel(user).send(builder);
});
}
}