Allow mute commands to update duration of the mute #4992

Manually merged
davidhu99 merged 0 commits from davidhu99/V3/develop into V3/develop 2026-11-21 16:09:28 +01:00
davidhu99 commented 2021-04-15 22:02:05 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Previously, when the author wanted to mute an already muted user, if muted user already inside muted list (if statement on line 1666), "That user is already muted in this channel." would be sent to the text channel and the user's current mute duration would not get updated.

Currently, when author mutes an already muted user, there will be an update to the mute duration. One case we accounted for is if the author changes the mute duration and happens to hit it after the mute task has been created. In this case, there may be an extra unmute task in the self.unmute_tasks cache, which will do nothing. We accounted for this by checking if an unmute task is in the unmute_tasks cache, and cancelling it if there is.

Closes #4834

### Type - [ ] Bugfix - [x] Enhancement - [ ] New feature ### Description of the changes Previously, when the author wanted to mute an already muted user, if muted user already inside muted list (if statement on line 1666), "That user is already muted in this channel." would be sent to the text channel and the user's current mute duration would not get updated. Currently, when author mutes an already muted user, there will be an update to the mute duration. One case we accounted for is if the author changes the mute duration and happens to hit it after the mute task has been created. In this case, there may be an extra unmute task in the _self._unmute_tasks__ cache, which will do nothing. We accounted for this by checking if an unmute task is in the unmute_tasks cache, and cancelling it if there is. Closes #4834
TrustyJAID (Migrated from github.com) reviewed 2021-04-15 22:02:05 +02:00
Kowlin (Migrated from github.com) reviewed 2021-04-15 22:02:05 +02:00
bobloy commented 2021-04-15 22:27:47 +02:00 (Migrated from github.com)

Is it correct to allow the mute command to shorten the duration of the mute too?

Is it correct to allow the mute command to *shorten* the duration of the mute too?
davidhu99 commented 2021-04-15 22:30:33 +02:00 (Migrated from github.com)

Is it correct to allow the mute command to shorten the duration of the mute too?

Good point, in my opinion it should not. However, in the original issue the author said to "update" which would be both shorten and lengthen. Let me know whether to only shorten!

> Is it correct to allow the mute command to _shorten_ the duration of the mute too? Good point, in my opinion it should not. However, in the original issue the author said to "update" which would be both shorten and lengthen. Let me know whether to only shorten!
TrustyJAID commented 2021-04-16 00:47:17 +02:00 (Migrated from github.com)

@bobloy Yes the mute command should allow shortening the duration of a mute as well as extending it, it is the moderators perogative to choose when to mute until and maybe they want to lessen the time to unmute.

Something that wasn't really discussed but should be addressed for consistency is the mute function should also check if there is an existing server unmute task when a user is server muted and cancel the task the same way you did for channel mutes.

@bobloy Yes the mute command should allow shortening the duration of a mute as well as extending it, it is the moderators perogative to choose when to mute until and maybe they want to lessen the time to unmute. Something that wasn't really discussed but should be addressed for consistency is the mute function should also check if there is an existing server unmute task when a user is server muted and cancel the task the same way you did for channel mutes.
davidhu99 commented 2021-04-16 03:06:40 +02:00 (Migrated from github.com)

@bobloy Yes the mute command should allow shortening the duration of a mute as well as extending it, it is the moderators perogative to choose when to mute until and maybe they want to lessen the time to unmute.

Something that wasn't really discussed but should be addressed for consistency is the mute function should also check if there is an existing server unmute task when a user is server muted and cancel the task the same way you did for channel mutes.

I believe I did that with my if condition on line 1668. Let me know if that's not the correct way to do it

> @bobloy Yes the mute command should allow shortening the duration of a mute as well as extending it, it is the moderators perogative to choose when to mute until and maybe they want to lessen the time to unmute. > > Something that wasn't really discussed but should be addressed for consistency is the mute function should also check if there is an existing server unmute task when a user is server muted and cancel the task the same way you did for channel mutes. I believe I did that with my if condition on line 1668. Let me know if that's not the correct way to do it
TrustyJAID commented 2021-04-16 03:12:59 +02:00 (Migrated from github.com)

You handled it for channel mutes but role-based server mutes still suffer from the same issue.

You handled it for channel mutes but role-based server mutes still suffer from the same issue.
davidhu99 commented 2021-04-16 19:58:05 +02:00 (Migrated from github.com)

You handled it for channel mutes but role-based server mutes still suffer from the same issue.

I see, please check out my last commit for the solution to that :)

> You handled it for channel mutes but role-based server mutes still suffer from the same issue. I see, please check out my last commit for the solution to that :)
TrustyJAID (Migrated from github.com) reviewed 2021-04-16 20:00:23 +02:00
@ -1532,6 +1532,14 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if guild.id not in self._server_mutes:
TrustyJAID (Migrated from github.com) commented 2021-04-16 20:00:23 +02:00

This file has logging setup. So if you really want to keep this here I recommend changing to log.debug rather than print or remove this entirely. It might be worth considering doing a log.info(f"{user} has had their mute time updated in {guild}") but I don't think that's entirely necessary.

This file has logging setup. So if you really want to keep this here I recommend changing to `log.debug` rather than print or remove this entirely. It might be worth considering doing a `log.info(f"{user} has had their mute time updated in {guild}")` but I don't think that's entirely necessary.
davidhu99 (Migrated from github.com) reviewed 2021-04-16 20:06:57 +02:00
@ -1532,6 +1532,14 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
if guild.id not in self._server_mutes:
davidhu99 (Migrated from github.com) commented 2021-04-16 20:06:57 +02:00

This file has logging setup. So if you really want to keep this here I recommend changing to log.debug rather than print or remove this entirely. It might be worth considering doing a log.info(f"{user} has had their mute time updated in {guild}") but I don't think that's entirely necessary.

Oh sorry that was just a sanity check for me, I'll delete it.

> This file has logging setup. So if you really want to keep this here I recommend changing to `log.debug` rather than print or remove this entirely. It might be worth considering doing a `log.info(f"{user} has had their mute time updated in {guild}")` but I don't think that's entirely necessary. Oh sorry that was just a sanity check for me, I'll delete it.
Mrcoolgamer11 manually merged commit cd090b0211 into V3/develop 2026-11-21 16:09:28 +01:00
Owner

This PR was ported to the current codebase in 28c1a1c79 instead of being merged as-is:

Allow updating the duration of existing mutes. Pending automatic unmutes are
cancelled and, for channel mutes, the cached original permission overwrites
are kept instead of being replaced with the already-muted overwrites.

This PR was ported to the current codebase in 28c1a1c79 instead of being merged as-is: Allow updating the duration of existing mutes. Pending automatic unmutes are cancelled and, for channel mutes, the cached original permission overwrites are kept instead of being replaced with the already-muted overwrites.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!4992
No description provided.