Skip to content

Commit 2e22478

Browse files
authored
Merge pull request #403 from danthe1st/fix-changepoints
fix commands directly changing QOTW points
2 parents 47a2f74 + 8e56847 commit 2e22478

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/main/java/net/javadiscord/javabot/systems/qotw/commands/qotw_points/ChangePointsSubcommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
5454
}
5555
boolean quiet = event.getOption("quiet", () -> false, OptionMapping::getAsBoolean);
5656
event.deferReply().queue();
57-
long points = changePoints(event);
57+
long points = changePoints(member, event);
5858
sendNotifications(event, member, points, quiet);
5959
}
6060

61-
private long changePoints(SlashCommandInteractionEvent event) {
62-
return pointsService.increment(event.getMember().getIdLong(), getIncrementCount(event));
61+
private long changePoints(Member targetMember, SlashCommandInteractionEvent event) {
62+
return pointsService.increment(targetMember.getIdLong(), getIncrementCount(targetMember, event));
6363
}
6464

65-
protected abstract int getIncrementCount(SlashCommandInteractionEvent event);
65+
protected abstract int getIncrementCount(Member targetMember, SlashCommandInteractionEvent event);
6666

6767
private void sendNotifications(SlashCommandInteractionEvent event, Member member, long points, boolean quiet) {
6868
MessageEmbed embed = buildIncrementEmbed(member.getUser(), points);

src/main/java/net/javadiscord/javabot/systems/qotw/commands/qotw_points/DecrementPointsSubcommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.jetbrains.annotations.NotNull;
44

55
import net.dv8tion.jda.api.EmbedBuilder;
6+
import net.dv8tion.jda.api.entities.Member;
67
import net.dv8tion.jda.api.entities.User;
78
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
89
import net.javadiscord.javabot.systems.notification.NotificationService;
@@ -19,7 +20,7 @@ public DecrementPointsSubcommand(QOTWPointsService pointsService, NotificationSe
1920
}
2021

2122
@Override
22-
protected int getIncrementCount(SlashCommandInteractionEvent event) {
23+
protected int getIncrementCount(Member targetMember, SlashCommandInteractionEvent event) {
2324
return -1;
2425
}
2526

src/main/java/net/javadiscord/javabot/systems/qotw/commands/qotw_points/IncrementPointsSubcommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.jetbrains.annotations.NotNull;
44

55
import net.dv8tion.jda.api.EmbedBuilder;
6+
import net.dv8tion.jda.api.entities.Member;
67
import net.dv8tion.jda.api.entities.User;
78
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
89
import net.javadiscord.javabot.systems.notification.NotificationService;
@@ -19,7 +20,7 @@ public IncrementPointsSubcommand(QOTWPointsService pointsService, NotificationSe
1920
}
2021

2122
@Override
22-
protected int getIncrementCount(SlashCommandInteractionEvent event) {
23+
protected int getIncrementCount(Member targetMember, SlashCommandInteractionEvent event) {
2324
return 1;
2425
}
2526

0 commit comments

Comments
 (0)