|
|
@ -22,6 +22,8 @@ public class PlayCommand extends YoshiCommand { |
|
|
|
|
|
|
|
private static final Map<User, Long> cooldownChecker = new HashMap<>(); |
|
|
|
|
|
|
|
private static final int SECOND_DELAY = 10; |
|
|
|
|
|
|
|
|
|
|
|
public PlayCommand(YoshiCommandContext context) { |
|
|
|
super(context); |
|
|
@ -32,9 +34,9 @@ public class PlayCommand extends YoshiCommand { |
|
|
|
public boolean execute() { |
|
|
|
if (!super.execute()) return false; |
|
|
|
|
|
|
|
for (User user : cooldownChecker.keySet()){ |
|
|
|
for (User user : cooldownChecker.keySet()) { |
|
|
|
Long timestamp = cooldownChecker.get(user); |
|
|
|
if (timestamp - System.currentTimeMillis() > 60000){ |
|
|
|
if (timestamp - System.currentTimeMillis() > SECOND_DELAY * 1000) { |
|
|
|
cooldownChecker.remove(user); |
|
|
|
} |
|
|
|
} |
|
|
@ -95,9 +97,10 @@ public class PlayCommand extends YoshiCommand { |
|
|
|
if (YoshiBot.getInstance().jda.getVoiceChannels().parallelStream() |
|
|
|
.flatMap(vcs -> vcs.getMembers().parallelStream()).map( |
|
|
|
Member::getUser).noneMatch(user -> user == author)) { |
|
|
|
if (PlayCommand.cooldownChecker.containsKey(author)){ |
|
|
|
sendErrorMessage("Иди нахуй (geh auf Schwanz), du musst 60s warten, wenn du nicht in einem Channel " + |
|
|
|
"bist"); |
|
|
|
if (PlayCommand.cooldownChecker.containsKey(author)) { |
|
|
|
sendErrorMessage( |
|
|
|
"Иди нахуй (geh auf Schwanz), du musst " + SECOND_DELAY + "s warten, wenn du nicht in" + |
|
|
|
" einem Channel bist"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
PlayCommand.cooldownChecker.put(author, System.currentTimeMillis()); |
|
|
|