Skip to content

Commit f038fa4

Browse files
Fix issue with /unmute not affecting role persist
1 parent ea86a83 commit f038fa4

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/main/java/technobot/commands/staff/UnMuteCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void execute(SlashCommandInteractionEvent event) {
7474

7575
// Remove muted role to user
7676
event.getGuild().removeRoleFromMember(target, muteRole).queue();
77+
moderationHandler.unMuteUser(target.getIdLong());
7778
user.openPrivateChannel().queue(privateChannel -> {
7879
// Private message user with reason for kick
7980
MessageEmbed msg = moderationHandler.createCaseMessage(event.getUser().getIdLong(),"Un-Mute", EmbedColor.SUCCESS.color);

src/main/java/technobot/data/cache/moderation/Moderation.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@ public Moderation(long guild) {
4040
* @param userID the ID of the user to mute.
4141
*/
4242
public void addMute(long userID) {
43-
//if (mutes == null) mutes = new HashSet<>();
4443
mutes.add(userID);
4544
}
4645

46+
/**
47+
* Remove a user ID from the mute list
48+
*
49+
* @param userID the ID of the user to unmute.
50+
*/
51+
public void removeMute(long userID) {
52+
mutes.remove(userID);
53+
}
54+
4755
/**
4856
* Adds a warning to the database.
4957
*

src/main/java/technobot/handlers/ModerationHandler.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,17 @@ public void setMuteRole(long roleID) {
277277
*/
278278
public void muteUser(long userID) {
279279
moderation.addMute(userID);
280-
bot.database.moderation.updateOne(filter, Updates.push("mutes", userID));
280+
bot.database.moderation.updateOne(filter, Updates.addToSet("mutes", userID));
281+
}
282+
283+
/**
284+
* Removes a user from the list of mutes (for role persists).
285+
*
286+
* @param userID the ID of the user to unmute.
287+
*/
288+
public void unMuteUser(long userID) {
289+
moderation.removeMute(userID);
290+
bot.database.moderation.updateOne(filter, Updates.pull("mutes", userID));
281291
}
282292

283293
/**

0 commit comments

Comments
 (0)