1
Fork 0
mirror of https://github.com/Steffo99/nortrom.git synced 2024-11-24 10:24:18 +00:00

🔧 Check permissions before deafening/muting

This commit is contained in:
Steffo 2021-03-27 00:16:01 +01:00
parent 792ac1b307
commit d227dfd703
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 29 additions and 0 deletions

View file

@ -46,5 +46,10 @@
<inspection_tool class="RegExpRepeatedSpace" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> <inspection_tool class="RegExpRepeatedSpace" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="RegExpUnexpectedAnchor" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="RegExpUnexpectedAnchor" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="ShellCheck" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="ShellCheck" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile> </profile>
</component> </component>

View file

@ -19,6 +19,12 @@ async def _mute(ctx: ds.SlashContext):
return return
channel: d.VoiceChannel = voice.channel channel: d.VoiceChannel = voice.channel
permissions: d.Permissions = ctx.author.permissions_in(channel=channel)
if not permissions.mute_members:
await ctx.send(content="⚠️ You don't have the _Mute Members_ permission.", hidden=True)
return
members: list[d.Member] = channel.members members: list[d.Member] = channel.members
for member in members: for member in members:
await member.edit(mute=True) await member.edit(mute=True)
@ -34,6 +40,12 @@ async def _unmute(ctx: ds.SlashContext):
return return
channel: d.VoiceChannel = voice.channel channel: d.VoiceChannel = voice.channel
permissions: d.Permissions = ctx.author.permissions_in(channel=channel)
if not permissions.mute_members:
await ctx.send(content="⚠️ You don't have the _Mute Members_ permission.", hidden=True)
return
members: list[d.Member] = channel.members members: list[d.Member] = channel.members
for member in members: for member in members:
await member.edit(mute=False) await member.edit(mute=False)
@ -49,6 +61,12 @@ async def _deafen(ctx: ds.SlashContext):
return return
channel: d.VoiceChannel = voice.channel channel: d.VoiceChannel = voice.channel
permissions: d.Permissions = ctx.author.permissions_in(channel=channel)
if not permissions.deafen_members:
await ctx.send(content="⚠️ You don't have the _Deafen Members_ permission.", hidden=True)
return
members: list[d.Member] = channel.members members: list[d.Member] = channel.members
for member in members: for member in members:
await member.edit(deafen=True) await member.edit(deafen=True)
@ -64,6 +82,12 @@ async def _undeafen(ctx: ds.SlashContext):
return return
channel: d.VoiceChannel = voice.channel channel: d.VoiceChannel = voice.channel
permissions: d.Permissions = ctx.author.permissions_in(channel=channel)
if not permissions.deafen_members:
await ctx.send(content="⚠️ You don't have the _Deafen Members_ permission.", hidden=True)
return
members: list[d.Member] = channel.members members: list[d.Member] = channel.members
for member in members: for member in members:
await member.edit(deafen=False) await member.edit(deafen=False)