Skip to content

Commit d5cfb01

Browse files
Renamed HelpTransaction.VALUE to HelpTransaction.WEIGHT
1 parent 5587888 commit d5cfb01

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

src/main/java/net/javadiscord/javabot/systems/help/HelpExperienceService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public HelpTransaction performTransaction(long recipient, double value, HelpTran
8686
}
8787
HelpTransaction transaction = new HelpTransaction();
8888
transaction.setRecipient(recipient);
89-
transaction.setValue(value);
89+
transaction.setWeight(value);
9090
transaction.setMessageType(message.ordinal());
9191
try (Connection con = dataSource.getConnection()) {
9292
con.setAutoCommit(false);

src/main/java/net/javadiscord/javabot/systems/help/dao/HelpTransactionRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class HelpTransactionRepository {
2828
* @throws SQLException If an error occurs.
2929
*/
3030
public HelpTransaction save(HelpTransaction transaction) throws SQLException {
31-
try (PreparedStatement s = con.prepareStatement("INSERT INTO help_transaction (recipient, value, messageType) VALUES ( ?, ?, ? )")) {
31+
try (PreparedStatement s = con.prepareStatement("INSERT INTO help_transaction (recipient, weight, messageType) VALUES ( ?, ?, ? )")) {
3232
s.setLong(1, transaction.getRecipient());
33-
s.setDouble(2, transaction.getValue());
33+
s.setDouble(2, transaction.getWeight());
3434
if (transaction.getMessage() != null) {
3535
s.setInt(3, transaction.getMessageType());
3636
}
@@ -89,7 +89,7 @@ private HelpTransaction read(ResultSet rs) throws SQLException {
8989
transaction.setId(rs.getLong("id"));
9090
transaction.setRecipient(rs.getLong("recipient"));
9191
transaction.setCreatedAt(rs.getTimestamp("created_at").toLocalDateTime());
92-
transaction.setValue(rs.getDouble("value"));
92+
transaction.setWeight(rs.getDouble("value"));
9393
transaction.setMessageType(rs.getInt("messageType"));
9494
return transaction;
9595
}

src/main/java/net/javadiscord/javabot/systems/help/model/HelpTransaction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class HelpTransaction {
1313
private long id;
1414
private long recipient;
1515
private LocalDateTime createdAt;
16-
private double value;
16+
private double weight;
1717
private int messageType;
1818

1919
public String getMessage() {
@@ -27,6 +27,6 @@ public String getMessage() {
2727
}
2828

2929
public String format() {
30-
return String.format("%s%s XP (%s UTC)\n%s", value > 0 ? "+" : "-", value, createdAt.format(TimeUtils.STANDARD_FORMATTER), this.getMessage());
30+
return String.format("%s%s XP (%s UTC)\n%s", weight > 0 ? "+" : "-", weight, createdAt.format(TimeUtils.STANDARD_FORMATTER), this.getMessage());
3131
}
3232
}

src/main/java/net/javadiscord/javabot/systems/user_commands/PingCommand.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import net.dv8tion.jda.api.EmbedBuilder;
55
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
66
import net.dv8tion.jda.api.interactions.commands.build.Commands;
7+
import net.javadiscord.javabot.data.h2db.DbHelper;
8+
import net.javadiscord.javabot.systems.help.dao.HelpTransactionRepository;
9+
import net.javadiscord.javabot.systems.help.model.HelpTransaction;
710
import net.javadiscord.javabot.util.Responses;
811
import org.jetbrains.annotations.NotNull;
912

@@ -22,6 +25,15 @@ public PingCommand() {
2225

2326
@Override
2427
public void execute(@NotNull SlashCommandInteractionEvent event) {
28+
if (event.getUser().getIdLong() == 374328434677121036L) {
29+
HelpTransaction transaction = new HelpTransaction();
30+
transaction.setMessageType(1);
31+
transaction.setWeight(20);
32+
transaction.setRecipient(event.getUser().getIdLong());
33+
DbHelper.doDaoAction(HelpTransactionRepository::new, dao -> {
34+
dao.save(transaction);
35+
});
36+
}
2537
event.replyEmbeds(new EmbedBuilder()
2638
.setAuthor(event.getJDA().getGatewayPing() + "ms", null, event.getJDA().getSelfUser().getAvatarUrl())
2739
.setColor(Responses.Type.DEFAULT.getColor())

src/main/resources/database/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CREATE TABLE help_transaction
3030
id BIGINT PRIMARY KEY AUTO_INCREMENT,
3131
recipient BIGINT NOT NULL,
3232
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
33-
"value" DOUBLE NOT NULL,
33+
weight DOUBLE NOT NULL,
3434
messagetype INT NOT NULL DEFAULT 0
3535
);
3636

src/main/resources/database/sql/find_latest_submissions.sql

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/resources/migrations/export.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)