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)
|
.suggester(command)
|
||||||
.then(
|
.then(
|
||||||
GameCommand.stringGreedy("content")
|
GameCommand.stringGreedy("content")
|
||||||
.suggester(command)
|
.suggester((__, ___, ____) -> Collections.emptyList())
|
||||||
.executor(command)
|
.executor(command)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -132,10 +132,6 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
|||||||
GameCommandArguments previousArguments,
|
GameCommandArguments previousArguments,
|
||||||
String currentInput
|
String currentInput
|
||||||
) {
|
) {
|
||||||
if (previousArguments.has("channel")) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
String input = currentInput.toLowerCase(Locale.ROOT);
|
String input = currentInput.toLowerCase(Locale.ROOT);
|
||||||
return discordSRV.channelConfig().getKeys().stream()
|
return discordSRV.channelConfig().getKeys().stream()
|
||||||
.filter(key -> key.toLowerCase(Locale.ROOT).startsWith(input))
|
.filter(key -> key.toLowerCase(Locale.ROOT).startsWith(input))
|
||||||
@ -153,14 +149,19 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
content = getContent(content);
|
|
||||||
|
|
||||||
|
SendableDiscordMessage message = getDiscordContent(content);
|
||||||
for (DiscordMessageChannel messageChannel : channels) {
|
for (DiscordMessageChannel messageChannel : channels) {
|
||||||
messageChannel.sendMessage(SendableDiscordMessage.builder().setContent(content).build());
|
messageChannel.sendMessage(message);
|
||||||
}
|
}
|
||||||
sender.sendMessage(Component.text("Broadcasted!", NamedTextColor.GRAY));
|
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 abstract String getContent(String content);
|
||||||
|
|
||||||
public static class Discord extends BroadcastCommand {
|
public static class Discord extends BroadcastCommand {
|
||||||
@ -169,10 +170,20 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma
|
|||||||
super(discordSRV);
|
super(discordSRV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendableDiscordMessage getDiscordContent(String content) {
|
||||||
|
return SendableDiscordMessage.builder()
|
||||||
|
// Keep as is, allow newlines though
|
||||||
|
.setContent(content.replace("\\n", "\n"))
|
||||||
|
.toFormatter()
|
||||||
|
.applyPlaceholderService()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// See above
|
||||||
@Override
|
@Override
|
||||||
public String getContent(String content) {
|
public String getContent(String content) {
|
||||||
// Keep as is, allow newlines though
|
return null;
|
||||||
return content.replace("\\n", "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user