Files
HidekoBot/src/main/java/wtf/beatrice/hidekobot/commands/message/MessageTimeoutCommand.java
Beatrice Dellacà 1f2bafa7f8
All checks were successful
continuous-integration/drone/push Build is passing
(wip) migrate commands to components
2025-09-06 22:14:44 +02:00

74 lines
1.8 KiB
Java

package wtf.beatrice.hidekobot.commands.message;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wtf.beatrice.hidekobot.commands.base.UserPunishment;
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@Component
public class MessageTimeoutCommand implements MessageCommand
{
private final UserPunishment userPunishment;
public MessageTimeoutCommand(@Autowired UserPunishment userPunishment)
{
this.userPunishment = userPunishment;
}
@Override
public LinkedList<String> getCommandLabels()
{
return new LinkedList<>(Collections.singletonList("timeout"));
}
@Nullable
@Override
public List<Permission> getPermissions()
{
return new ArrayList<Permission>(Collections.singletonList(Permission.MODERATE_MEMBERS));
}
@Override
public boolean passRawArgs()
{
return false;
}
@NotNull
@Override
public CommandCategory getCategory()
{
return CommandCategory.MODERATION;
}
@NotNull
@Override
public String getDescription()
{
return "Timeout the mentioned user.";
}
@Nullable
@Override
public String getUsage()
{
return "<mentioned user> <duration> [reason]";
}
@Override
public void runCommand(MessageReceivedEvent event, String label, String[] args)
{
userPunishment.handle(event, args, UserPunishment.PunishmentType.TIMEOUT);
}
}