Skip to content

Commit c60eddd

Browse files
committed
fix QOTW decrement embed
1 parent 20a28ff commit c60eddd

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

src/main/java/net/javadiscord/javabot/systems/notification/QOTWNotificationService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public void sendAccountIncrementedNotification() {
4949
notificationService.withUser(user).sendDirectMessage(c -> c.sendMessageEmbeds(buildAccountIncrementEmbed(account.getPoints())));
5050
}
5151

52+
public void sendAccountDecrementedNotification() {
53+
notificationService.withUser(user).sendDirectMessage(c -> c.sendMessageEmbeds(buildAccountDecrementEmbed(account.getPoints())));
54+
}
55+
5256
/**
5357
* Sends a "your submission was declined"-notification to the {@link QOTWNotificationService#user}.
5458
*
@@ -92,6 +96,17 @@ public void sendSubmissionDeclinedEmbed(SubmissionStatus status) {
9296
.build();
9397
}
9498

99+
private @NotNull MessageEmbed buildAccountDecrementEmbed(long points) {
100+
return buildQOTWNotificationEmbed()
101+
.setColor(Responses.Type.WARN.getColor())
102+
.setDescription(String.format(
103+
"""
104+
Your QOTW score has been decremented.
105+
**`1 QOTW-Point`** has been deducted from your score! (monthly total: %s)
106+
In case you want to know why exactly this happened, please contact our staff team.""", points))
107+
.build();
108+
}
109+
95110
private @NotNull MessageEmbed buildSubmissionDeclinedEmbed(String reason) {
96111
return this.buildQOTWNotificationEmbed()
97112
.setColor(Responses.Type.ERROR.getColor())
@@ -102,4 +117,5 @@ public void sendSubmissionDeclinedEmbed(SubmissionStatus status) {
102117
user.getAsMention(), reason))
103118
.build();
104119
}
120+
105121
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import net.dv8tion.jda.api.interactions.commands.OptionType;
1111
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
1212
import net.javadiscord.javabot.systems.notification.NotificationService;
13+
import net.javadiscord.javabot.systems.notification.QOTWNotificationService;
1314
import net.javadiscord.javabot.systems.qotw.QOTWPointsService;
1415
import net.javadiscord.javabot.util.Responses;
1516
import org.jetbrains.annotations.NotNull;
@@ -68,11 +69,14 @@ private void sendNotifications(SlashCommandInteractionEvent event, Member member
6869
MessageEmbed embed = buildIncrementEmbed(member.getUser(), points);
6970
notificationService.withGuild(event.getGuild()).sendToModerationLog(c -> c.sendMessageEmbeds(embed));
7071
if (!quiet) {
71-
notificationService.withQOTW(event.getGuild(), member.getUser()).sendAccountIncrementedNotification();
72+
sendUserNotification(notificationService.withQOTW(event.getGuild(), member.getUser()));
73+
7274
}
7375
event.getHook().sendMessageEmbeds(embed).queue();
7476
}
7577

78+
protected abstract void sendUserNotification(@NotNull QOTWNotificationService notificationService);
79+
7680
protected @NotNull MessageEmbed buildIncrementEmbed(@NotNull User user, long points) {
7781
return createIncrementEmbedBuilder(user, points)
7882
.build();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.dv8tion.jda.api.entities.User;
88
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
99
import net.javadiscord.javabot.systems.notification.NotificationService;
10+
import net.javadiscord.javabot.systems.notification.QOTWNotificationService;
1011
import net.javadiscord.javabot.systems.qotw.QOTWPointsService;
1112

1213
/**
@@ -29,4 +30,9 @@ protected int getIncrementCount(Member targetMember, SlashCommandInteractionEven
2930
return super.createIncrementEmbedBuilder(user, points)
3031
.setTitle("QOTW Account decremented");
3132
}
33+
34+
@Override
35+
protected void sendUserNotification(@NotNull QOTWNotificationService notificationService) {
36+
notificationService.sendAccountDecrementedNotification();
37+
}
3238
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.dv8tion.jda.api.entities.User;
88
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
99
import net.javadiscord.javabot.systems.notification.NotificationService;
10+
import net.javadiscord.javabot.systems.notification.QOTWNotificationService;
1011
import net.javadiscord.javabot.systems.qotw.QOTWPointsService;
1112

1213
/**
@@ -30,4 +31,9 @@ protected int getIncrementCount(Member targetMember, SlashCommandInteractionEven
3031
.setTitle("QOTW Account incremented");
3132
}
3233

34+
@Override
35+
protected void sendUserNotification(@NotNull QOTWNotificationService notificationService) {
36+
notificationService.sendAccountIncrementedNotification();
37+
}
38+
3339
}

0 commit comments

Comments
 (0)