use of me.TechsCode.TechDiscordBot.objects.Cooldown in project TechDiscordBot by TechsCode-Team.
the class ModulesManager method onSlashCommand.
@SubscribeEvent
public void onSlashCommand(SlashCommandEvent e) {
CommandModule cmd = cmdModules.stream().filter(c -> c.getName().equalsIgnoreCase(e.getName())).findFirst().orElse(null);
if (cmd == null || e.getMember() == null || e.getUser().isBot())
return;
if (cmd.getCooldown() > 0 && cmd.getCooldowns().containsKey(e.getMember().getId())) {
Cooldown cooldown = cmd.getCooldowns().get(e.getMember().getId());
if (cooldown.isCooldownRemaining()) {
e.deferReply(true).queue();
e.reply("**Woah there... slow down!** There's still **" + cooldown.getRemainingCooldown() + "** seconds left on your cooldown!").queue();
return;
}
cmd.getCooldowns().remove(e.getMember().getId());
}
cmd.onCommand(e.getTextChannel(), e.getMember(), e);
}
Aggregations