Fixed database query and changed to only unban bans that were with the same reason as the auto ban
This commit is contained in:
parent
16996e95e2
commit
2d05ec61af
|
|
@ -38,6 +38,7 @@ dependencies {
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:1.1.5")
|
annotationProcessor("com.velocitypowered:velocity-api:1.1.5")
|
||||||
// JDA
|
// JDA
|
||||||
implementation("net.dv8tion:JDA:5.0.0-alpha.3") {
|
implementation("net.dv8tion:JDA:5.0.0-alpha.3") {
|
||||||
|
shadow("net.dv8tion:JDA:5.0.0-alpha.3") {
|
||||||
exclude("opus-java") // exclude audio
|
exclude("opus-java") // exclude audio
|
||||||
}
|
}
|
||||||
compileOnly("com.gitlab.ruany:LitebansAPI:0.3.5")
|
compileOnly("com.gitlab.ruany:LitebansAPI:0.3.5")
|
||||||
|
|
@ -47,9 +48,9 @@ dependencies {
|
||||||
runtimeOnly("mysql:mysql-connector-java:8.0.23")
|
runtimeOnly("mysql:mysql-connector-java:8.0.23")
|
||||||
// ShutdownInfo
|
// ShutdownInfo
|
||||||
compileOnly("com.alttd:ShutdownInfo:1.0")
|
compileOnly("com.alttd:ShutdownInfo:1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveFileName.set("${project.name}-${project.version}.jar")
|
archiveFileName.set("${project.name}-${project.version}.jar")
|
||||||
|
|
@ -68,4 +69,5 @@ tasks {
|
||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,21 +4,19 @@ dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
// Altitude
|
// Altitude
|
||||||
// maven {
|
maven {
|
||||||
// name = "maven"
|
name = "maven"
|
||||||
// url = uri("http://leo:8081/")
|
url = uri("https://repo.destro.xyz/snapshots")
|
||||||
// isAllowInsecureProtocol = true
|
credentials(PasswordCredentials::class)
|
||||||
// //credentials(PasswordCredentials::class)
|
}
|
||||||
// }
|
|
||||||
maven("https://jitpack.io")
|
|
||||||
// Velocity
|
// Velocity
|
||||||
maven("https://nexus.velocitypowered.com/repository/maven-public/")
|
maven("https://nexus.velocitypowered.com/repository/maven-public/")
|
||||||
// JDA
|
// JDA
|
||||||
maven("https://m2.dv8tion.net/releases/")
|
maven("https://m2.dv8tion.net/releases/")
|
||||||
// MiniMessage
|
// MiniMessage
|
||||||
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||||
// Local maven repo .m2
|
// LiteBans
|
||||||
mavenLocal()
|
maven("https://jitpack.io")
|
||||||
}
|
}
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class Bot {
|
public class Bot {
|
||||||
|
|
@ -193,10 +194,16 @@ public class Bot {
|
||||||
ALogger.warn("I can't unban members in " + guild.getName() + ".");
|
ALogger.warn("I can't unban members in " + guild.getName() + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
guild.retrieveBanList().queue(bans -> bans.stream()
|
guild.retrieveBanList().queue(bans -> {
|
||||||
|
Optional<Guild.Ban> first = bans.stream()
|
||||||
.filter(ban -> ban.getUser().getIdLong() == userId)
|
.filter(ban -> ban.getUser().getIdLong() == userId)
|
||||||
.findFirst()
|
.findFirst();
|
||||||
.ifPresent(bans::remove));
|
if (first.isEmpty())
|
||||||
|
return;
|
||||||
|
Guild.Ban ban = first.get();
|
||||||
|
if (ban.getReason() != null && ban.getReason().equals("Auto ban due to Minecraft ban"))
|
||||||
|
bans.remove(ban);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void discordBan(long guildId, long userId, @Nullable String optionalReason) {
|
public void discordBan(long guildId, long userId, @Nullable String optionalReason) {
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,9 @@ public class Database {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||||
statement.setInt(1, active ? 1 : 0);
|
statement.setInt(1, active ? 1 : 0);
|
||||||
|
statement.setString(2, uuid.toString());
|
||||||
|
|
||||||
|
statement.executeUpdate();
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user