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