mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-01 08:39:31 +01:00
Fix broadcast tab complete, add placeholder support to Discord formatted broadcast
This commit is contained in:
parent
eba37d9b6f
commit
a84eef853c
@ -80,7 +80,7 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
||||
.suggester(command)
|
||||
.then(
|
||||
GameCommand.stringGreedy("content")
|
||||
.suggester(command)
|
||||
.suggester((__, ___, ____) -> Collections.emptyList())
|
||||
.executor(command)
|
||||
)
|
||||
)
|
||||
@ -132,10 +132,6 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
||||
GameCommandArguments previousArguments,
|
||||
String currentInput
|
||||
) {
|
||||
if (previousArguments.has("channel")) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String input = currentInput.toLowerCase(Locale.ROOT);
|
||||
return discordSRV.channelConfig().getKeys().stream()
|
||||
.filter(key -> key.toLowerCase(Locale.ROOT).startsWith(input))
|
||||
@ -153,14 +149,19 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
||||
return;
|
||||
}
|
||||
|
||||
content = getContent(content);
|
||||
|
||||
SendableDiscordMessage message = getDiscordContent(content);
|
||||
for (DiscordMessageChannel messageChannel : channels) {
|
||||
messageChannel.sendMessage(SendableDiscordMessage.builder().setContent(content).build());
|
||||
messageChannel.sendMessage(message);
|
||||
}
|
||||
sender.sendMessage(Component.text("Broadcasted!", NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
public SendableDiscordMessage getDiscordContent(String content) {
|
||||
content = getContent(content);
|
||||
return SendableDiscordMessage.builder().setContent(content).build();
|
||||
}
|
||||
|
||||
public abstract String getContent(String content);
|
||||
|
||||
public static class Discord extends BroadcastCommand {
|
||||
@ -170,9 +171,19 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent(String content) {
|
||||
public SendableDiscordMessage getDiscordContent(String content) {
|
||||
return SendableDiscordMessage.builder()
|
||||
// Keep as is, allow newlines though
|
||||
return content.replace("\\n", "\n");
|
||||
.setContent(content.replace("\\n", "\n"))
|
||||
.toFormatter()
|
||||
.applyPlaceholderService()
|
||||
.build();
|
||||
}
|
||||
|
||||
// See above
|
||||
@Override
|
||||
public String getContent(String content) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user