Skip to content

Implements Voice Channel Muting#1297

Merged
kosayoda merged 82 commits into
python-discord:mainfrom
HassanAbouelela:voicechannel-mute
Jul 8, 2021
Merged

Implements Voice Channel Muting#1297
kosayoda merged 82 commits into
python-discord:mainfrom
HassanAbouelela:voicechannel-mute

Conversation

@HassanAbouelela
Copy link
Copy Markdown
Contributor

@HassanAbouelela HassanAbouelela commented Nov 22, 2020

Description

Adds voice channel muting functionality, similar to text channel muting.

  • Allows muting any channel from any other channel or itself
  • Allows unmuting any channel from any other channel or itself
  • Relays mute confirmation/failure to both the invocation channel and the muted channel (in the case of VC, the muted channel is replaced with the text-channel with the same name).
  • Updates shh and unshh commands to match the silence and unsilence interface.

Closes #1160, closes #1282.

ToDo

Tests

  • Write tests for silence command
  • Write tests for unsilence command
  • Write tests for error handler (shh, unshh)

Other

  • Relay failure messages to invocation channel when muting VC
  • Replace hardcoded matching of VC to VC-chat channel names
  • Make member kicking in voice channel optional.

Adds a converter that can decipher more forms of channel mentions, to
lay foundation for voice channel muting.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Adds an optional channel parameter to silence and unsilence commands,
and adds ability to silence voice channels.
TODO: New Tests

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
- Allows spaces in channel name
- Allows channel name to have any capitalization
- Fixed inherited class to general Converter class

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Refactors imports of silence class to be more inline with the original
import structure.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Adds and calls a function to force a voice channel member to sync
permissions. See #1160 for why this is necessary.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
@HassanAbouelela HassanAbouelela added t: feature New feature or request a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 2 - normal Normal Priority labels Nov 22, 2020
@HassanAbouelela HassanAbouelela self-assigned this Nov 22, 2020
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 22, 2020

Coverage Status

Coverage increased (+1.1%) to 57.809% when pulling 1343a1c on HassanAbouelela:voicechannel-mute into 5ade0dc on python-discord:master.

Notifies invocation channel that the silence command failed to silence
the channel because it could not move members, but roles were updated.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Adds an optional parameter to the silence command to enable moderators
to choose if they only update permissions, or kick members too.

As an accompanying feature, the unsilence command now syncs voice
channel permissions too.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Fixes the channel reported as muted to voice channel chat channels when
silencing voice channels.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Adds tests for helper functions in the silence cog.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

Note on 985b681 which implements an optional kick parameter:

Ideally, the kick parameter would be the last parameter, as it is optional even if other arguments such as channel are passed, but because channel is starred, that wouldn't be possible.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
@HassanAbouelela HassanAbouelela marked this pull request as ready for review November 23, 2020 21:02
@HassanAbouelela HassanAbouelela requested a review from a team as a code owner November 23, 2020 21:02
@HassanAbouelela HassanAbouelela requested review from MarkKoz and lemonsaurus and removed request for a team November 23, 2020 21:02
@ghost ghost added the needs 2 approvals label Nov 23, 2020
MarkKoz
MarkKoz previously approved these changes May 8, 2021
@HassanAbouelela HassanAbouelela requested a review from mbaruh May 8, 2021 23:38
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py Outdated
Comment thread bot/exts/moderation/silence.py
Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Changes logging statement levels and messages to correctly express
intent.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Restructures silence cog helper methods to group relation functions in a
 more logical manner.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

I'm not sure how good an idea this is when we're this far along the development process, but I'm thinking of changing up the interface for the silence command. When testing recently, I found it very clunky, especially compared to the other moderation tools. Most commands (ban, mute, etc) have the format: !<command> <target> <duration> <other args>, compared to silence which has <duration> <target>.

This was originally done because the current usage of silence is either !silence or !silence duration, and I wanted to minimize the changes the mods experience. Because this is a mod-only command, I'll make this same suggestion internally, but I think the mods will find it most useful to have the <target> <duration> format.

Another idea I had was making the second argument accept both duration and target. This should be doable by having the argument type as [TextChannel, VoiceChannel, int].

Uses `.format` to create silence and unsilence messages instead of
`.replace`.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Updates the silence command to accept the silence duration or channel as
 the first argument to the command. Updates tests.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

I put it up to a vote with the mods, and most people were leaning towards making the first argument accept either the duration or the channel, so I did that. From my testing, the converters are able to properly choose between a channel, and an int, so not much work was needed.

The subject of the !shh command did come up during discussions. One concern raised was the disparity between the interface of two very similar commands. I'll try adding an optional channel argument, but I'm not sure how that'll work out yet.

@HassanAbouelela HassanAbouelela requested a review from MarkKoz May 12, 2021 21:39
Updates the shh and unshh commands from the error handler to accept
channel and kick arguments, to give them the same interface as the
silence and unsilence command.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

It took some figuring out, but now both changes have been made, and the PR is ready for review again.

@Xithrius Xithrius requested review from Akarys42, Den4200 and Xithrius May 23, 2021 06:36
Copy link
Copy Markdown
Contributor

@kosayoda kosayoda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost everything I've tried works to my expectation (almost merged it :x), but |silence forever only silences the channel for the fallback 10 minutes. I suspect this has something to do with dpy's parser, would you mind looking into it?

Fixes a bug that stopped the duration `forever` from getting used as a
valid duration for silence.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@HassanAbouelela
Copy link
Copy Markdown
Contributor Author

@kosayoda thanks for your review, good catch! I missed adding in the behavior for that argument when redesigning the first argument, but I've fixed that in f92338e.

@HassanAbouelela HassanAbouelela requested a review from kosayoda June 5, 2021 11:05
@HassanAbouelela HassanAbouelela dismissed stale reviews from mbaruh and MarkKoz June 5, 2021 11:05

Stale.

Copy link
Copy Markdown
Contributor

@kosayoda kosayoda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚂

@kosayoda kosayoda enabled auto-merge June 5, 2021 15:11
Copy link
Copy Markdown
Contributor

@Xithrius Xithrius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it with author of this PR, it works very well!

@kosayoda kosayoda merged commit 292cad8 into python-discord:main Jul 8, 2021
@HassanAbouelela HassanAbouelela deleted the voicechannel-mute branch July 9, 2021 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 1 - high High Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability for mods to shut down a voice channel !shh Equivalent Command for Voice Chat

9 participants