Compare commits
No commits in common. "master" and "v1.0.5" have entirely different histories.
7 changed files with 16 additions and 93 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<list size="1">
|
<list size="1">
|
||||||
|
|
26
README.md
26
README.md
|
@ -7,14 +7,13 @@
|
||||||
<br>
|
<br>
|
||||||
A multipurpose Discord bot written in Java.
|
A multipurpose Discord bot written in Java.
|
||||||
|
|
||||||
## Required Environment
|
## Tested Environments
|
||||||
- Java 17+ (May work on older versions but untested)
|
- Java 21+ (May work on older versions but untested)
|
||||||
- Maven
|
- Maven
|
||||||
|
|
||||||
### Tested Operating Systems
|
### Tested Operating Systems
|
||||||
- macOS 14 & 15 (arm64)
|
- macOS 14.4.1
|
||||||
- Windows 10 22H2 (x86_64)
|
- Windows 10 (22H2)
|
||||||
- Debian 12 (x86_64)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ A multipurpose Discord bot written in Java.
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"token": "your_token",
|
"token": "your_token",
|
||||||
"warningChannel": 0
|
"prefix": "oki!"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -30,12 +29,9 @@ A multipurpose Discord bot written in Java.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
| Command | Description | Arguments |
|
| Command | Description | Arguments | Aliases |
|
||||||
|-------------------|------------------------------------------------------------------------------|-----------------------------------------------------------|
|
|---------|------------------------------------------------------------------------------|-------------------------------------|---------|
|
||||||
| `/ping` | Gets the bot's gateway & rest ping | None |
|
| `about` | Gets information about the bot | None | None |
|
||||||
| `/whois` | Gets information about the specified user (message author if none specified) | `[member]` |
|
| `ping` | Gets the bot's gateway & rest ping | None | None |
|
||||||
| `/timeout set` | Times out a member for a specified amount of time | `[member]`, `[duration]`, `(reason)` |
|
| `whois` | Gets information about the specified user (message author if none specified) | `[user ping]` | None |
|
||||||
| `/timeout get` | Gets the current timeout status of the specified member | `[member]` |
|
| `mute` | Mutes a member for a specified amount of time | `[user ping]`, `[timeout duration]` | None |
|
||||||
| `/timeout cancel` | Cancels the specified users timeout | `[member]`, `(reason)` |
|
|
||||||
| `/poll` | Creates a poll | `[title]`, `[duration]`, `[options]`, `(multiple-choice)` |
|
|
||||||
| `/warn` | Warns a user | `[member]`, `[reason]` |
|
|
|
@ -1,4 +1,3 @@
|
||||||
{
|
{
|
||||||
"token": "CHANGEME",
|
"token": "CHANGEME"
|
||||||
"warningChannel": 0
|
|
||||||
}
|
}
|
16
pom.xml
16
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>net.hypr</groupId>
|
<groupId>net.hypr</groupId>
|
||||||
<artifactId>doki</artifactId>
|
<artifactId>doki</artifactId>
|
||||||
<version>1.0.8</version>
|
<version>1.0.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>5.2.1</version>
|
<version>5.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.freya022</groupId>
|
<groupId>io.github.freya022</groupId>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>logback-classic</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>1.5.13</version>
|
<version>1.5.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
@ -56,15 +56,5 @@
|
||||||
<artifactId>commons-dbutils</artifactId>
|
<artifactId>commons-dbutils</artifactId>
|
||||||
<version>1.8.1</version>
|
<version>1.8.1</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -11,7 +11,6 @@ import java.nio.charset.StandardCharsets;
|
||||||
//You will need a valid config.json in the resources folder for this to work
|
//You will need a valid config.json in the resources folder for this to work
|
||||||
public class Config {
|
public class Config {
|
||||||
@SuppressWarnings("unused") private String token;
|
@SuppressWarnings("unused") private String token;
|
||||||
@SuppressWarnings("unused") private long warningChannel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration object for this bot
|
* Returns the configuration object for this bot
|
||||||
|
@ -34,7 +33,4 @@ public class Config {
|
||||||
public String getToken() {
|
public String getToken() {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
public long getWarningChannel() {
|
|
||||||
return warningChannel;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -22,10 +22,6 @@ public class Doki {
|
||||||
public static JDA getJDA() {
|
public static JDA getJDA() {
|
||||||
return jda;
|
return jda;
|
||||||
}
|
}
|
||||||
public static Config getConfig() { return config; }
|
|
||||||
public static Logger getLogger() {
|
|
||||||
return log;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void start() throws IOException, InterruptedException {
|
public static void start() throws IOException, InterruptedException {
|
||||||
config = Config.readConfig();
|
config = Config.readConfig();
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
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;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|
||||||
import net.hypr.doki.Doki;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
@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) {
|
|
||||||
Logger log = Doki.getLogger();
|
|
||||||
Member actingMod = event.getMember();
|
|
||||||
EmbedBuilder warnEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(String.format("You were warned in %s", event.getGuild().getName()))
|
|
||||||
.setDescription(String.format("**Reason:** %s", reason))
|
|
||||||
.setFooter(String.format("Warned by %s (%s)", actingMod.getEffectiveName(), actingMod.getId()), actingMod.getEffectiveAvatarUrl())
|
|
||||||
.setColor(new Color(239, 148, 60));
|
|
||||||
log.debug(String.format("%s", Doki.getConfig().getWarningChannel()));
|
|
||||||
TextChannel warningChannel = Doki.getJDA().getTextChannelById(Doki.getConfig().getWarningChannel());
|
|
||||||
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()
|
|
||||||
),
|
|
||||||
error -> event.replyFormat("Warned %s for %s\n-# (Unable to DM user)", member.getAsMention(), reason).queue()
|
|
||||||
);
|
|
||||||
warnEmbed.setTitle(String.format("%s (%s) was warned", member.getEffectiveName(), member.getId()));
|
|
||||||
try {
|
|
||||||
assert warningChannel != null;
|
|
||||||
warningChannel.sendMessage(member.getAsMention()).addEmbeds(warnEmbed.build()).queue();
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
log.warn("Failed to send message to warning log channel");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue