[Mod] [p]mute|unmute voice now take action instantly #4064

Merged
Vexed01 merged 4 commits from voicemute-move into V3/develop 2020-07-12 18:44:35 +02:00
Vexed01 commented 2020-07-10 09:17:26 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

When [p]mute|unmute voice is run, now the changes will take into effect instantly, instead of when the user rejoins. This is done via the move members permission, moving the user into the channel they are already in. Fixes #4028. However, as jack said in #4028:

I don't know if it's intended, but as long as nobody in Discord says it isn't, we could just use that.

### Type - [x] Bugfix - [ ] Enhancement - [ ] New feature ### Description of the changes When `[p]mute|unmute voice` is run, now the changes will take into effect instantly, instead of when the user rejoins. This is done via the move members permission, moving the user into the channel they are already in. Fixes #4028. However, as jack said in #4028: > I don't know if it's intended, but as long as nobody in Discord says it isn't, we could just use that.
palmtree5 (Migrated from github.com) reviewed 2020-07-10 09:17:26 +02:00
Jackenmen (Migrated from github.com) requested changes 2020-07-10 22:36:26 +02:00
Jackenmen (Migrated from github.com) left a comment

Looks mostly good, just small string changes needed and preemptive checks.

There's one thing that could be done differently, although I don't think it's really a better way (just thought, it's worth mentioning) - the call to _voice_perm_check() in line 179 and 302 could have move_members=True argument passed and the command would just early-fail in such case. But since the moving isn't entirely necessary, it probably doesn't make that much sense to do in this way.

Looks mostly good, just small string changes needed and preemptive checks. There's one thing that *could* be done differently, although *I don't think* it's really a better way (just thought, it's worth mentioning) - the call to `_voice_perm_check()` in line 179 and 302 could have `move_members=True` argument passed and the command would just early-fail in such case. But since the moving isn't entirely necessary, it probably doesn't make that much sense to do in this way.
@ -207,6 +207,17 @@ class MuteMixin(MixinMeta):
await ctx.send(
Jackenmen (Migrated from github.com) commented 2020-07-10 22:22:06 +02:00

Permission name should be title-cased same as it is presented in Discord's UI.

                        "Because I don't have the Move Members permission, this will take into effect when the user rejoins."
Permission name should be title-cased same as it is presented in Discord's UI. ```suggestion "Because I don't have the Move Members permission, this will take into effect when the user rejoins." ```
Jackenmen (Migrated from github.com) commented 2020-07-10 22:32:01 +02:00

This should be in an if checking whether the bot has that permission so that we don't make API request if we already know that it's gonna fail.

                if channel.permissions_for(ctx.me).move_members:
                    await user.move_to(channel)
                else:
                    raise RuntimeError
            except (discord.Forbidden, RuntimeError):
This should be in an `if` checking whether the bot has that permission so that we don't make API request if we already know that it's gonna fail. ```suggestion if channel.permissions_for(ctx.me).move_members: await user.move_to(channel) else: raise RuntimeError except (discord.Forbidden, RuntimeError): ```
Jackenmen (Migrated from github.com) commented 2020-07-10 22:22:12 +02:00

Permission name should be title-cased same as it is presented in Discord's UI.

                        "Because I don't have the Move Members permission, this will take into effect when the user rejoins."
Permission name should be title-cased same as it is presented in Discord's UI. ```suggestion "Because I don't have the Move Members permission, this will take into effect when the user rejoins." ```
Jackenmen (Migrated from github.com) commented 2020-07-10 22:32:35 +02:00

This should be in an if checking whether the bot has that permission so that we don't make API request if we already know that it's gonna fail.

                if channel.permissions_for(ctx.me).move_members:
                    await user.move_to(channel)
                else:
                    raise RuntimeError
            except (discord.Forbidden, RuntimeError):
This should be in an `if` checking whether the bot has that permission so that we don't make API request if we already know that it's gonna fail. ```suggestion if channel.permissions_for(ctx.me).move_members: await user.move_to(channel) else: raise RuntimeError except (discord.Forbidden, RuntimeError): ```
Vexed01 (Migrated from github.com) reviewed 2020-07-10 23:08:26 +02:00
Vexed01 (Migrated from github.com) commented 2020-07-10 23:08:25 +02:00

👍 As you mentioned _voice_perm_check() isn't especially better here as it sends a message in the text channel that could be misleading/otherwise require "unnecessary" perms.
I couldn't get permissions_for to work when I was doing it...

👍 As you mentioned `_voice_perm_check()` isn't especially better here as it sends a message in the text channel that could be misleading/otherwise require "unnecessary" perms. _I couldn't get permissions_for to work when I was doing it..._
Jackenmen (Migrated from github.com) approved these changes 2020-07-12 18:44:15 +02:00
Jackenmen (Migrated from github.com) left a comment

Looks good to me. Thanks for the fix!

Looks good to me. Thanks for the fix!
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!4064
No description provided.