more worky
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package tech.allydoes;
|
||||
|
||||
public class Constants {
|
||||
public static final boolean PRODUCTION = false;
|
||||
public static final boolean PRODUCTION = true;
|
||||
public static final String TESTING_GUILD = "926369143186403329";
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@ import tech.allydoes.discord.DiscordManager;
|
||||
import tech.allydoes.web.HttpServerHandler;
|
||||
|
||||
public class Main {
|
||||
static Logger logger = LogManager.getLogger(Main.class);
|
||||
|
||||
private static DiscordManager discordManager;
|
||||
private static DatabaseManager databaseManager;
|
||||
|
||||
static Logger logger = LogManager.getLogger(Main.class);
|
||||
public final int port;
|
||||
public Main(int port) {
|
||||
this.port = port;
|
||||
|
||||
@@ -36,7 +36,6 @@ public class DatabaseManager {
|
||||
if (!dbExists) {
|
||||
LOGGER.debug("Database does not exist. Creating...");
|
||||
try (Statement statement = conn.createStatement()) {
|
||||
// Use executeUpdate for DDL (CREATE DATABASE) - it does not return a ResultSet
|
||||
statement.executeUpdate(Queries.CREATE_DATABASE);
|
||||
LOGGER.debug("Database created successfully.");
|
||||
} catch (SQLException e) {
|
||||
@@ -115,5 +114,26 @@ public class DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteNotifier(String guildId) {
|
||||
String user = dotenv.get("DB_USER");
|
||||
String password = dotenv.get("DB_PASSWORD");
|
||||
String host = dotenv.get("DB_HOST");
|
||||
String port = dotenv.get("DB_PORT");
|
||||
|
||||
String defaultDbUrl = String.format("jdbc:postgresql://%s:%s/notifier", host, port);
|
||||
try (Connection conn = DriverManager.getConnection(defaultDbUrl, user, password)) {
|
||||
conn.setAutoCommit(true);
|
||||
|
||||
try (PreparedStatement preparedStatement = conn.prepareStatement(Queries.DELETE_SERVER_CHANNEL)) {
|
||||
preparedStatement.setString(1, guildId);
|
||||
if (preparedStatement.execute()) {
|
||||
LOGGER.debug("Notifier for guild {} deleted successfully.", guildId);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
LOGGER.error("deleteNotifier: Failed to connect: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public record Notified(String guildId, String channelId, String messageId) {}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class DiscordManager {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("setDoorStatus: Failed to edit message: {}", e.getMessage());
|
||||
Main.getDatabaseManager().deleteNotifier(notifiedEntry.guildId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Embeds {
|
||||
public static MessageEmbed createOpenLabStatus() {
|
||||
return new EmbedBuilder()
|
||||
.setTitle("Lab is open!")
|
||||
.setDescription("Feel free to come at work!")
|
||||
.setDescription("Feel free to come and work!")
|
||||
.setColor(0x00FF00)
|
||||
.setTimestamp(Instant.now())
|
||||
.build();
|
||||
|
||||
Reference in New Issue
Block a user