Add support for timeouts to Mutes cog #5604

Merged
TrustyJAID merged 45 commits from mutes-add-timeouts into V3/develop 2024-04-01 02:05:37 +02:00
TrustyJAID commented 2022-03-07 16:03:46 +01:00 (Migrated from github.com)

Description of the changes

Add timeouts support to the Mutes cog. This changes the default server mute behavior to utilize timeouts while maintaining role mutes if they have been previously setup. This adds a new [p]timeout command that exclusively uses discords built in timeout feature. This also allows the [p]activemutes command to list the currently muted and timed out users in the server. This also adds some models that make it easier for managing typed responses for internal muting methods.

Have the changes in this PR been tested?

Yes

### Description of the changes Add timeouts support to the Mutes cog. This changes the default server mute behavior to utilize timeouts while maintaining role mutes if they have been previously setup. This adds a new `[p]timeout` command that exclusively uses discords built in timeout feature. This also allows the `[p]activemutes` command to list the currently muted and timed out users in the server. This also adds some models that make it easier for managing typed responses for internal muting methods. ### Have the changes in this PR been tested? <!-- Choose one (remove the line that doesn't apply): --> Yes <!-- If the question doesn't apply (for example, it's not a code change), choose Yes. Please respond to this question truthfully. We do not delay nor reject PRs based on the answer to this question but it allows to better review this PR. -->
BlizzardTheWolf commented 2023-11-19 15:01:21 +01:00 (Migrated from github.com)

Could we make it so that you can choose wether to use timeouts or mutes by using like [p]muteset usetimeouts, and having the command stay [p]mute, instead of having it be [p]timeout?

Could we make it so that you can choose wether to use timeouts or mutes by using like `[p]muteset usetimeouts`, and having the command stay `[p]mute`, instead of having it be `[p]timeout`?
AAA3A-AAA3A commented 2023-11-19 15:12:38 +01:00 (Migrated from github.com)

Could we make it so that you can choose wether to use timeouts or mutes by using like [p]muteset usetimeouts, and having the command stay [p]mute, instead of having it be [p]timeout?

I think we should have a [p]timeout command, but a setting could redirect [p]mute to [p]timeout if server's admins prefer this option to a real role.

> Could we make it so that you can choose wether to use timeouts or mutes by using like `[p]muteset usetimeouts`, and having the command stay `[p]mute`, instead of having it be `[p]timeout`? I think we should have a `[p]timeout` command, but a setting could redirect `[p]mute` to `[p]timeout` if server's admins prefer this option to a real role.
BlizzardTheWolf commented 2023-11-19 16:20:02 +01:00 (Migrated from github.com)

Yeah that's a good idea!

Could we make it so that you can choose wether to use timeouts or mutes by using like [p]muteset usetimeouts, and having the command stay [p]mute, instead of having it be [p]timeout?

I think we should have a [p]timeout command, but a setting could redirect [p]mute to [p]timeout if server's admins prefer this option to a real role.

Yeah that's a good idea! > > Could we make it so that you can choose wether to use timeouts or mutes by using like `[p]muteset usetimeouts`, and having the command stay `[p]mute`, instead of having it be `[p]timeout`? > > I think we should have a `[p]timeout` command, but a setting could redirect `[p]mute` to `[p]timeout` if server's admins prefer this option to a real role.
Flame442 (Migrated from github.com) requested changes 2024-03-27 00:00:29 +01:00
Flame442 (Migrated from github.com) left a comment

Various developer-facing documentation should be updated to reflect an accurate description of the behavior under timeouts rather than channel override based mutes (lines 101, 315, 771).

I have not yet run the code, these are the issues I found from simply reviewing it.

Various developer-facing documentation should be updated to reflect an accurate description of the behavior under timeouts rather than channel override based mutes (lines 101, 315, 771). I have not yet run the code, these are the issues I found from simply reviewing it.
Flame442 (Migrated from github.com) commented 2024-03-26 23:40:03 +01:00

It seems like this is no longer used, so it should probably be removed from here and the defaults.

It seems like this is no longer used, so it should probably be removed from here and the defaults.
@ -1157,17 +1091,16 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
else:
user_str = user.mention
if mutes["until"]:
Flame442 (Migrated from github.com) commented 2024-03-26 23:28:52 +01:00

If this PR is entirely replacing channel override mutes with timeout mutes, the docstring for this command and the output of [p]muteset force_role_mutes needs to be update to reflect that.

If this PR is entirely replacing channel override mutes with timeout mutes, the docstring for this command and the output of `[p]muteset force_role_mutes` needs to be update to reflect that.
Flame442 (Migrated from github.com) commented 2024-03-26 23:50:06 +01:00

This appears to be appending a failing response twice. I believe the above check is because the failure message for moving users is successful with a reason, however it will also append an issue in cases where there was not a success, since they to have a reason set. They would then be appended again by this line.

This appears to be appending a failing response twice. I believe the above check is because the failure message for moving users is successful with a reason, however it will also append an issue in cases where there was not a success, since they to have a reason set. They would then be appended again by this line.
Flame442 (Migrated from github.com) commented 2024-03-26 23:57:05 +01:00

This isn't strictly an error with your PR, but there is no reason to be translating the strings both here and in the definition of MUTE_UNMUTE_ISSUES. This applies to this whole function, unmute_user, channel_mute_user, and channel_unmute_user.

This isn't strictly an error with your PR, but there is no reason to be translating the strings both here and in the definition of `MUTE_UNMUTE_ISSUES`. This applies to this whole function, `unmute_user`, `channel_mute_user`, and `channel_unmute_user`.
Flame442 (Migrated from github.com) commented 2024-03-26 23:55:07 +01:00

Same issue with potentially double appending as before.

Same issue with potentially double appending as before.
Flame442 commented 2024-03-27 00:04:03 +01:00 (Migrated from github.com)

@BlizzardTheWolf @AAA3A-AAA3A, the PR currently replaces the backup behavior for [p]mute when a mute role is not configured to use timeouts, rather than channel overrides. The [p]timeout command also exists for explicitly timing out a user, regardless of whether or not [p]mute is configured to use a role.

@BlizzardTheWolf @AAA3A-AAA3A, the PR currently replaces the backup behavior for `[p]mute` when a mute role is not configured to use timeouts, rather than channel overrides. The `[p]timeout` command also exists for explicitly timing out a user, regardless of whether or not `[p]mute` is configured to use a role.
TrustyJAID (Migrated from github.com) reviewed 2024-03-31 04:22:35 +02:00
TrustyJAID (Migrated from github.com) commented 2024-03-31 04:22:35 +02:00

Actually this is necessary since the call to translate the string does not actually happen until here with the correct context. The initialized variables can be argued for not needing it and I can't remember the exact reason for why we left it this way and I can't find the discussion on it now. I just tested the change and can confirm that removing the translation _() from any of these cause the result to not correctly translate the message.

Actually this *is* necessary since the call to translate the string does not actually happen until here with the correct context. The initialized variables can be argued for not needing it and I can't remember the exact reason for why we left it this way and I can't find the discussion on it now. I just tested the change and can confirm that removing the translation `_()` from any of these cause the result to not correctly translate the message.
Jackenmen (Migrated from github.com) reviewed 2024-03-31 04:26:25 +02:00
Jackenmen (Migrated from github.com) commented 2024-03-31 04:26:25 +02:00

_() calls in globals are so that redgettext can collect these strings but they're just passthrough and don't do anything (nor should they since the translations need to happen in a context where the locale is properly set).

_() calls in actual code are so that the strings actually get translated but those won't be collected by redgettext since they don't operate on string literals.

`_()` calls in globals are so that redgettext can collect these strings but they're just passthrough and don't do anything (nor should they since the translations need to happen in a context where the locale is properly set). `_()` calls in actual code are so that the strings actually get translated but those won't be collected by redgettext since they don't operate on string literals.
TrustyJAID (Migrated from github.com) reviewed 2024-03-31 04:45:37 +02:00
TrustyJAID (Migrated from github.com) commented 2024-03-31 04:45:37 +02:00

This, and the previous mention of a similar situation, are both intended. There are two lists we're dealing with here one for successful mutes we can largely ignore and another for ones with potential problems.

The only situation where we have successfully muted the user but still have a reason is when the user is currently in a voice channel and the bot was unable to move the user in the voice channel triggering discord to actually mute them. Therefore it should be notified to the command issuer that we were able to mute them but they may still be speaking in the voice channel and further action may need to be taken.

This, and the previous mention of a similar situation, are both intended. There are two lists we're dealing with here one for successful mutes we can largely ignore and another for ones with potential problems. The only situation where we have successfully muted the user but still have a reason is when the user is currently in a voice channel and the bot was unable to move the user in the voice channel triggering discord to actually mute them. Therefore it should be notified to the command issuer that we were able to mute them but they may still be speaking in the voice channel and further action may need to be taken.
Flame442 (Migrated from github.com) reviewed 2024-03-31 05:09:06 +02:00
Flame442 (Migrated from github.com) commented 2024-03-31 05:09:05 +02:00

I missed the if/else block...

I missed the if/else block...
Flame442 (Migrated from github.com) reviewed 2024-03-31 06:12:02 +02:00
Flame442 (Migrated from github.com) commented 2024-03-31 06:12:02 +02:00

I don't think this makes it use timeouts, it just allows timeouts to be used at all. I'm not sure if this setting is even needed, now that there's no API spam to need to opt in to.

I don't think this makes it use timeouts, it just allows timeouts to be used at all. I'm not sure if this setting is even needed, now that there's no API spam to need to opt in to.
Flame442 (Migrated from github.com) reviewed 2024-03-31 21:55:29 +02:00
Flame442 (Migrated from github.com) reviewed 2024-03-31 22:56:29 +02:00
Jackenmen (Migrated from github.com) reviewed 2024-03-31 23:18:31 +02:00
Jackenmen (Migrated from github.com) commented 2024-03-31 23:18:31 +02:00

Nitpick but [p]unmute/[p]channelunmute sets audit_reason generated from reason and passes that to channel_unmute_user() instead:

            audit_reason = get_audit_reason(author, reason, shorten=True)
            issue_list = []
Nitpick but `[p]unmute`/`[p]channelunmute` sets `audit_reason` generated from `reason` and passes that to `channel_unmute_user()` instead: ```suggestion audit_reason = get_audit_reason(author, reason, shorten=True) issue_list = [] ```
Jackenmen (Migrated from github.com) reviewed 2024-04-01 01:25:39 +02:00
@ -1409,3 +1426,3 @@
await ctx.send(
msg.format(users=humanize_list([f"{u}" for u in success_list]), time=time)
msg.format(users=humanize_list([f"`{u}`" for u in success_list]), time=time)
)
Jackenmen (Migrated from github.com) commented 2024-04-01 01:25:28 +02:00
                msg += f"- {issue.user}: {issue.reason}\n"
```suggestion msg += f"- {issue.user}: {issue.reason}\n" ```
@ -1547,3 +1641,3 @@
users=humanize_list([f"{u}" for u in success_list])
users=humanize_list([f"`{u}`" for u in success_list])
)
)
Jackenmen (Migrated from github.com) commented 2024-04-01 01:25:35 +02:00
                msg += f"- {issue.user}: {issue.reason}\n"
```suggestion msg += f"- {issue.user}: {issue.reason}\n" ```
Jackenmen (Migrated from github.com) approved these changes 2024-04-01 02:05:03 +02:00
Jackenmen (Migrated from github.com) left a comment

meow?

![meow?](https://i.fluffy.cc/hc8WTNRNffFv0fTPJDTdFFbsKMCQn5Rz.gif)
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
1 participant
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!5604
No description provided.