Fix DC alerts, DC commands, Poll command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Ursprung
ff6fe9eeb5
Commit
e7f0e57e9d
@ -32,7 +32,7 @@ public class PollCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Chatter sender) {
|
||||
public void genericCommand(@Validator Chatter sender) {
|
||||
PollSystem.sendPoll(sender);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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(" "));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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,8 +38,13 @@ import java.time.Instant;
|
||||
public class DiscordAlert {
|
||||
|
||||
public static void send(Chatter player, Color color, Message title, Message description, boolean success) {
|
||||
DiscordBot.withBot(bot -> {
|
||||
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;
|
||||
|
||||
MessageBuilder builder = new MessageBuilder()
|
||||
@ -52,6 +58,7 @@ public class DiscordAlert {
|
||||
if(success)
|
||||
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389"))));
|
||||
|
||||
new DiscordChannel(player.user()).send(builder);
|
||||
new DiscordChannel(user).send(builder);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren