From b91f141c083905a01f8018b74d50ed923af569a2 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Thu, 15 Sep 2022 23:08:28 +0200 Subject: [PATCH] Update output channel if it was previously defined --- .../queries/commandOutputChannels/CommandOutputChannels.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alttd/database/queries/commandOutputChannels/CommandOutputChannels.java b/src/main/java/com/alttd/database/queries/commandOutputChannels/CommandOutputChannels.java index 67d7049..b1a38a3 100644 --- a/src/main/java/com/alttd/database/queries/commandOutputChannels/CommandOutputChannels.java +++ b/src/main/java/com/alttd/database/queries/commandOutputChannels/CommandOutputChannels.java @@ -10,12 +10,13 @@ import java.sql.SQLException; public class CommandOutputChannels { public static boolean setOutputChannel(long guildId, OutputType outputType, long channelId) { - String sql = "INSERT INTO output_channels (guild, output_type, channel) VALUES (?, ?, ?)"; + String sql = "INSERT INTO output_channels (guild, output_type, channel) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE channel = ?"; try { PreparedStatement preparedStatement = Database.getDatabase().getConnection().prepareStatement(sql); preparedStatement.setLong(1, guildId); preparedStatement.setString(2, outputType.name()); preparedStatement.setLong(3, channelId); + preparedStatement.setLong(4, channelId); return preparedStatement.executeUpdate() == 1; } catch (SQLException e) {