|
|
@ -12,6 +12,30 @@ from db import connection
|
|
|
|
from settings import enso_embedmod_colours, get_modlog_for_guild, storeRoles, clearRoles
|
|
|
|
from settings import enso_embedmod_colours, get_modlog_for_guild, storeRoles, clearRoles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def check(ctx, members, action):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Check Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Checks if all arguments are given
|
|
|
|
|
|
|
|
- Checks if user mentions themselves
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Error will be thrown in these two cases
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not len(members):
|
|
|
|
|
|
|
|
embed = Embed(description="Not Correct Syntax!"
|
|
|
|
|
|
|
|
f"\nUse **{ctx.prefix}help** to find how to use **{ctx.command}**",
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif ctx.author in members:
|
|
|
|
|
|
|
|
embed = Embed(description=f"**❌ You Can't {action} Yourself Baka! ❌**",
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def ummute_members(message, targets, reason):
|
|
|
|
async def ummute_members(message, targets, reason):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
@ -59,7 +83,7 @@ async def ummute_members(message, targets, reason):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
channel = message.guild.get_channel(int(modlog))
|
|
|
|
channel = message.guild.get_channel(int(modlog))
|
|
|
|
|
|
|
|
|
|
|
|
embed = Embed(title="Member Muted",
|
|
|
|
embed = Embed(title="Member Unmuted",
|
|
|
|
colour=enso_embedmod_colours,
|
|
|
|
colour=enso_embedmod_colours,
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
|
|
|
|
|
|
|
@ -250,19 +274,10 @@ class Moderation(Cog):
|
|
|
|
Multiple Members can be Kicked at Once
|
|
|
|
Multiple Members can be Kicked at Once
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# When no members are entered. Throw an error
|
|
|
|
with ctx.typing():
|
|
|
|
if not len(members):
|
|
|
|
if await check(ctx, members, action="Kick"):
|
|
|
|
embed = Embed(description="Not Correct Syntax!"
|
|
|
|
return
|
|
|
|
"\nUse **{}help** to find how to use **{}**".format(ctx.prefix, ctx.command),
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
# Throw error when user tries to kick themselves
|
|
|
|
|
|
|
|
elif ctx.author in members:
|
|
|
|
|
|
|
|
embed = Embed(description="**❌ You Can't Kick Yourself Baka! ❌**",
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
# As long as all members are valid
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Send embed of the kicked member
|
|
|
|
# Send embed of the kicked member
|
|
|
|
await kick_members(ctx.message, members, reason)
|
|
|
|
await kick_members(ctx.message, members, reason)
|
|
|
|
|
|
|
|
|
|
|
@ -275,31 +290,22 @@ class Moderation(Cog):
|
|
|
|
Multiple Members can be Muted At Once
|
|
|
|
Multiple Members can be Muted At Once
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
with ctx.typing():
|
|
|
|
with ctx.typing():
|
|
|
|
# When no members are entered. Throw an error
|
|
|
|
if await check(ctx, members, action="Mute"):
|
|
|
|
if not len(members):
|
|
|
|
return
|
|
|
|
embed = Embed(description="Not Correct Syntax!"
|
|
|
|
|
|
|
|
"\nUse **{}help** to find how to use **{}**".format(ctx.prefix, ctx.command),
|
|
|
|
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
if role is None:
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
# Setting up the role permissions for the Muted Role
|
|
|
|
# Throw error when user tries to mute themselves
|
|
|
|
muted = await ctx.guild.create_role(name="Muted")
|
|
|
|
elif ctx.author in members:
|
|
|
|
# Removes permission to send messages in all channels
|
|
|
|
embed = Embed(description="**❌ You Can't Mute Yourself Baka! ❌**",
|
|
|
|
for channel in ctx.guild.channels:
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
await channel.set_permissions(muted, send_messages=False, read_messages=True)
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
# Send embed of the kicked member
|
|
|
|
|
|
|
|
await mute_members(ctx.message, members, reason, muted)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
|
|
|
# Send embed of the kicked member
|
|
|
|
if role is None:
|
|
|
|
await mute_members(ctx.message, members, reason, role)
|
|
|
|
# Setting up the role permissions for the Muted Role
|
|
|
|
|
|
|
|
muted = await ctx.guild.create_role(name="Muted")
|
|
|
|
|
|
|
|
# Removes permission to send messages in all channels
|
|
|
|
|
|
|
|
for channel in ctx.guild.channels:
|
|
|
|
|
|
|
|
await channel.set_permissions(muted, send_messages=False, read_messages=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Send embed of the kicked member
|
|
|
|
|
|
|
|
await mute_members(ctx.message, members, reason, muted)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Send embed of the kicked member
|
|
|
|
|
|
|
|
await mute_members(ctx.message, members, reason, role)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@command(name="unmute", aliases=["Unmute"])
|
|
|
|
@command(name="unmute", aliases=["Unmute"])
|
|
|
|
@has_guild_permissions(manage_roles=True)
|
|
|
|
@has_guild_permissions(manage_roles=True)
|
|
|
@ -312,19 +318,8 @@ class Moderation(Cog):
|
|
|
|
unmute = False
|
|
|
|
unmute = False
|
|
|
|
|
|
|
|
|
|
|
|
with ctx.typing():
|
|
|
|
with ctx.typing():
|
|
|
|
|
|
|
|
if await check(ctx, members, action="Unmute"):
|
|
|
|
# When no members are entered. Throw an error
|
|
|
|
return
|
|
|
|
if not len(members):
|
|
|
|
|
|
|
|
embed = Embed(description="Not Correct Syntax!"
|
|
|
|
|
|
|
|
"\nUse **{}help** to find how to use **{}**".format(ctx.prefix, ctx.command),
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Throw error when user tries to unmute themselves
|
|
|
|
|
|
|
|
elif ctx.author in members:
|
|
|
|
|
|
|
|
embed = Embed(description="**❌ You Can't Unmute Yourself Baka! ❌**",
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
|
|
|
role = discord.utils.get(ctx.guild.roles, name="Muted")
|
|
|
|
if role is None:
|
|
|
|
if role is None:
|
|
|
@ -353,19 +348,10 @@ class Moderation(Cog):
|
|
|
|
Multiple Members can be banned at once
|
|
|
|
Multiple Members can be banned at once
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# When no members are entered. Throw an error
|
|
|
|
with ctx.typing():
|
|
|
|
if not len(members):
|
|
|
|
if await check(ctx, members, action="Ban"):
|
|
|
|
embed = Embed(description="Not Correct Syntax!"
|
|
|
|
return
|
|
|
|
"\nUse **{}help** to find how to use **{}**".format(ctx.prefix, ctx.command),
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
# Throw error when user tries to kick themselves
|
|
|
|
|
|
|
|
elif ctx.author in members:
|
|
|
|
|
|
|
|
embed = Embed(description="**❌ You Can't Ban Yourself Baka! ❌**",
|
|
|
|
|
|
|
|
colour=enso_embedmod_colours)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
# As long as all members are valid
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Send embed of the Banned member
|
|
|
|
# Send embed of the Banned member
|
|
|
|
await ban_members(ctx.message, members, reason)
|
|
|
|
await ban_members(ctx.message, members, reason)
|
|
|
|
|
|
|
|
|
|
|
|