parent
3ca194e638
commit
ae1d32b485
1 changed files with 14 additions and 7 deletions
|
@ -1,8 +1,9 @@
|
|||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Union
|
||||
|
||||
import pymongo
|
||||
from discord import Member, Role, TextChannel, User
|
||||
from discord import Member, Role, TextChannel, User, VoiceChannel
|
||||
from discord.ext import commands
|
||||
from discord.utils import find, get
|
||||
from discord_slash import SlashContext, cog_ext
|
||||
|
@ -556,24 +557,30 @@ class AdminCog(commands.Cog):
|
|||
|
||||
async def _lock_channel(
|
||||
self,
|
||||
channel: TextChannel,
|
||||
channel: Union[TextChannel, VoiceChannel],
|
||||
role: Role,
|
||||
admin: User,
|
||||
reason: str,
|
||||
allow_send=False,
|
||||
):
|
||||
overrides = channel.overwrites_for(role)
|
||||
overrides.send_messages = allow_send
|
||||
if isinstance(channel, TextChannel):
|
||||
overrides.send_messages = allow_send
|
||||
elif isinstance(channel, VoiceChannel):
|
||||
overrides.speak = allow_send
|
||||
await channel.set_permissions(role, overwrite=overrides, reason=reason)
|
||||
|
||||
async def _unlock_channel(
|
||||
self,
|
||||
channel: TextChannel,
|
||||
channel: Union[TextChannel, VoiceChannel],
|
||||
role: Role,
|
||||
admin: User,
|
||||
):
|
||||
overrides = channel.overwrites_for(role)
|
||||
overrides.send_messages = None
|
||||
if isinstance(channel, TextChannel):
|
||||
overrides.send_messages = None
|
||||
elif isinstance(channel, VoiceChannel):
|
||||
overrides.speak = None
|
||||
await channel.set_permissions(role, overwrite=overrides)
|
||||
|
||||
@cog_ext.cog_slash(
|
||||
|
@ -607,7 +614,7 @@ class AdminCog(commands.Cog):
|
|||
ctx: SlashContext,
|
||||
reason: str,
|
||||
duration: int = 10,
|
||||
channel: TextChannel = None,
|
||||
channel: Union[TextChannel, VoiceChannel] = None,
|
||||
):
|
||||
await ctx.defer()
|
||||
if not channel:
|
||||
|
@ -647,7 +654,7 @@ class AdminCog(commands.Cog):
|
|||
async def _unlock(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
channel: TextChannel = None,
|
||||
channel: Union[TextChannel, VoiceChannel] = None,
|
||||
):
|
||||
await ctx.defer()
|
||||
if not channel:
|
||||
|
|
Loading…
Add table
Reference in a new issue