Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added voice kicking. #2639

Merged
merged 5 commits into from May 3, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions redbot/cogs/mod/abc.py
Expand Up @@ -19,6 +19,7 @@ def __init__(self, *_args):
self.cache: dict
self.ban_queue: List[Tuple[int, int]]
self.unban_queue: List[Tuple[int, int]]
self._voice_perm_check
Copy link
Contributor

Choose a reason for hiding this comment

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

This should defined as an abstractmethod (see below)


@classmethod
@abstractmethod
Expand Down
6 changes: 6 additions & 0 deletions redbot/cogs/mod/casetypes.py
Expand Up @@ -97,4 +97,10 @@
"case_str": "Server Unmute",
"audit_type": "overwrite_update",
},
{
"name": "vkick",
"default_setting": False,
"image": "\N{SPEAKER WITH CANCELLATION STROKE}",
"case_str": "Voice Kick",
},
]
55 changes: 55 additions & 0 deletions redbot/cogs/mod/kickban.py
Expand Up @@ -495,6 +495,61 @@ async def softban(self, ctx: commands.Context, user: discord.Member, *, reason:
await ctx.send(e)
await ctx.send(_("Done. Enough chaos."))

@commands.command()
@commands.guild_only()
@commands.mod_or_permissions(move_members=True)
async def voicekick(
self, ctx: commands.Context, member: discord.Member, *, reason: str = None
):
"""Kick a member from a voice channel."""
author = ctx.author
guild = ctx.guild
user_voice_state: discord.VoiceState = member.voice

if (
await self._voice_perm_check(
ctx, user_voice_state, move_members=True
)
is False
):
return
elif not await is_allowed_by_hierarchy(self.bot, self.settings, guild, author, member):
await ctx.send(
_(
"I cannot let you do that. You are "
"not higher than the user in the role "
"hierarchy."
)
)
return
case_channel = member.voice.channel
# Store this channel for the case channel.

try:
await member.move_to(discord.Object(id=None))
# Work around till we get D.py 1.1.0, whereby we can directly do None.
except discord.Forbidden: # Very unlikely that this will ever occur
mikeshardmind marked this conversation as resolved.
Show resolved Hide resolved
await ctx.send(_("I am unable to kick this member from the voice channel."))
return
except discord.HTTPException:
await ctx.send(_("Something went wrong while attempting to kick that member"))
return
else:
try:
await modlog.create_case(
self.bot,
guild,
ctx.message.created_at,
"vkick",
member,
author,
reason,
until=None,
channel=case_channel,
)
except RuntimeError as e:
await ctx.send(e)

@commands.command()
@commands.guild_only()
@commands.bot_has_permissions(ban_members=True)
Expand Down