Compare commits
No commits in common. "0d92921b45201f0bedaf07c05a705c55a26eb034" and "98a162a33b6e7ef12cce3906d6b9f4add5fba025" have entirely different histories.
0d92921b45
...
98a162a33b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
target/
|
target/
|
||||||
.idea/
|
.idea/
|
||||||
*.sqlite
|
|
@ -145,7 +145,7 @@ public class ClearChatCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Button deleteButton = Button.danger("clear_delete", "Dismiss").withEmoji(Emoji.fromUnicode("❌"));
|
Button deleteButton = Button.danger("clear_delete", "Delete").withEmoji(Emoji.fromUnicode("❌"));
|
||||||
|
|
||||||
WebhookMessageEditAction<Message> webhookMessageEditAction;
|
WebhookMessageEditAction<Message> webhookMessageEditAction;
|
||||||
|
|
||||||
@ -167,10 +167,8 @@ public class ClearChatCommand
|
|||||||
String replyMessageId = message.getId();
|
String replyMessageId = message.getId();
|
||||||
String replyChannelId = message.getChannel().getId();
|
String replyChannelId = message.getChannel().getId();
|
||||||
String replyGuildId = message.getGuild().getId();
|
String replyGuildId = message.getGuild().getId();
|
||||||
String userId = event.getUser().getId();
|
|
||||||
|
|
||||||
Configuration.getDatabaseManager().queueDisabling(replyGuildId, replyChannelId, replyMessageId);
|
Configuration.getDatabaseManager().queueDisabling(replyGuildId, replyChannelId, replyMessageId);
|
||||||
Configuration.getDatabaseManager().trackRanCommandReply(replyGuildId, replyChannelId, replyMessageId, userId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
@ -178,15 +176,7 @@ public class ClearChatCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteButton(ButtonInteractionEvent event)
|
public void deleteButton(ButtonInteractionEvent event)
|
||||||
{
|
|
||||||
|
|
||||||
if(!(Configuration.getDatabaseManager().isUserTrackedFor(event.getUser().getId(), event.getMessageId())))
|
|
||||||
{
|
|
||||||
event.reply("❌ You did not run this command!").setEphemeral(true).queue();
|
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
event.getInteraction().getMessage().delete().queue();
|
event.getInteraction().getMessage().delete().queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -95,60 +95,6 @@ public class DatabaseManager
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean trackRanCommandReply(String guildId, String channelId, String messageId, String userId)
|
|
||||||
{
|
|
||||||
String query = "INSERT INTO command_runners " +
|
|
||||||
"(guild_id, channel_id, message_id, user_id) VALUES " +
|
|
||||||
" (?, ?, ?, ?);";
|
|
||||||
|
|
||||||
try(PreparedStatement preparedStatement = dbConnection.prepareStatement(query))
|
|
||||||
{
|
|
||||||
preparedStatement.setString(1, guildId);
|
|
||||||
preparedStatement.setString(2, channelId);
|
|
||||||
preparedStatement.setString(3, messageId);
|
|
||||||
preparedStatement.setString(4, userId);
|
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUserTrackedFor(String userId, String messageId)
|
|
||||||
{
|
|
||||||
String trackedUserId = getTrackedReplyUserId(messageId);
|
|
||||||
if(trackedUserId == null) return false;
|
|
||||||
return userId.equals(trackedUserId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTrackedReplyUserId(String messageId)
|
|
||||||
{
|
|
||||||
String query = "SELECT user_id " +
|
|
||||||
"FROM command_runners " +
|
|
||||||
"WHERE message_id = ?;";
|
|
||||||
|
|
||||||
try(PreparedStatement preparedStatement = dbConnection.prepareStatement(query))
|
|
||||||
{
|
|
||||||
preparedStatement.setString(1, messageId);
|
|
||||||
ResultSet resultSet = preparedStatement.executeQuery();
|
|
||||||
if(resultSet.isClosed()) return null;
|
|
||||||
while(resultSet.next())
|
|
||||||
{
|
|
||||||
return resultSet.getString("user_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean queueDisabling(String guildId, String channelId, String messageId)
|
public boolean queueDisabling(String guildId, String channelId, String messageId)
|
||||||
{
|
{
|
||||||
LocalDateTime expiryTime = LocalDateTime.now().plusSeconds(Configuration.getExpiryTimeSeconds());
|
LocalDateTime expiryTime = LocalDateTime.now().plusSeconds(Configuration.getExpiryTimeSeconds());
|
||||||
|
Loading…
Reference in New Issue
Block a user