Update deps, add warn command

This commit is contained in:
floppydiskette 2024-12-22 00:05:45 +00:00
parent cf947432bb
commit f4eb1e79bf
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
2 changed files with 46 additions and 2 deletions

14
pom.xml
View file

@ -6,7 +6,7 @@
<groupId>net.hypr</groupId>
<artifactId>doki</artifactId>
<version>1.0.0</version>
<version>1.0.6</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
@ -39,7 +39,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
<version>1.5.13</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
@ -56,5 +56,15 @@
<artifactId>commons-dbutils</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.5.13</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>4.28.2</version>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,34 @@
package net.hypr.doki.commands.moderation;
import com.freya02.botcommands.api.annotations.BotPermissions;
import com.freya02.botcommands.api.annotations.CommandMarker;
import com.freya02.botcommands.api.annotations.UserPermissions;
import com.freya02.botcommands.api.application.ApplicationCommand;
import com.freya02.botcommands.api.application.annotations.AppOption;
import com.freya02.botcommands.api.application.slash.GuildSlashEvent;
import com.freya02.botcommands.api.application.slash.annotations.JDASlashCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
@CommandMarker
@BotPermissions(Permission.MODERATE_MEMBERS)
@UserPermissions(Permission.MODERATE_MEMBERS)
public class Warn extends ApplicationCommand {
@JDASlashCommand(
name = "warn",
description = "Warns a member"
)
public void warn(GuildSlashEvent event,
@AppOption(name = "member", description = "The member to warn") Member member,
@AppOption(name = "reason", description = "The reason for warning them") String reason) {
EmbedBuilder warnEmbed = new EmbedBuilder()
.setTitle(String.format("You were warned in %s", event.getGuild().getName()))
.setDescription(String.format("**Reason:** %s", reason));
member.getUser().openPrivateChannel().queue((dm) -> dm.sendMessageEmbeds(warnEmbed.build()).queue(
success -> event.replyFormat("Warned %s for %s", member.getAsMention(), reason).setEphemeral(true).queue(),
// User has blocked bot or disabled DMs
error -> event.replyFormat("Warned %s for %s\n-# (Unable to DM user)", member.getAsMention(), reason).queue()
));
}
}