async def mod_unban(self, ctx, user: discord.User, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("unban", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **unban** command." )) return if reason: chanmsg = f"{user.mention} has been unbanned from the server.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been unbanned from the server." try: await ctx.send(embed=interface.success_message( "Unban", chanmsg, f"User ID: {user.id}")) db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "unban", reason) await ctx.author.guild.unban(user, reason=reason) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the unban you just attempted to issue.", ))
async def mod_warn(self, ctx, user: discord.Member, *, reason: str): """ Warn a user and record the warning in the log. <user> must be a Discord tag, ID number, or mention. <message> can be anything. """ await ctx.message.delete() if not perms.check_command_priv("warn", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **warn** command." )) return try: db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "warn", reason) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the warning you just attempted to issue.", )) else: await ctx.send(embed=interface.error_message( "Warning", f"{user.mention} has received a warning:\n\n**{reason}**", f"User ID: {user.id}")) await user.send(embed=interface.error_message( f"{ctx.message.guild} - Warning", f"You have received a warning:\n\n**{reason}**"))
async def mod_softban(self, ctx, user: discord.Member, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("softban", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **softban** command." )) return if user.id == ctx.message.author.id: await ctx.send(embed=interface.error_message( "Error", f"You can't softban yourself.")) return if ctx.author.guild.get_member(user.id): if perms.get_staff_rank( ctx.message.author) <= perms.get_staff_rank(user): await ctx.send(embed=interface.error_message( "Error", f"You can't softban someone of the same staff rank or higher." )) return if reason: chanmsg = f"{user.mention} has been softbanned.\n\nReason: **{reason}**" dmmsg = f"You have been softbanned.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been softbanned." dmmsg = f"You have been softbanned." try: await ctx.send(embed=interface.error_message( "Soft Ban", chanmsg, f"User ID: {user.id}")) if ctx.author.guild.get_member(user.id): await user.send(embed=interface.error_message( f"{ctx.message.guild} - Soft Ban", dmmsg)) db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "softban", reason) await ctx.author.guild.ban(user, reason=reason, delete_message_days=7) await ctx.author.guild.unban(user, reason=reason) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the ban you just attempted to issue.", ))
async def mod_jail(self, ctx, user: discord.Member, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("jail", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **jail** command." )) return if user.id == ctx.message.author.id: await ctx.send(embed=interface.error_message( "Error", f"You can't jail yourself.")) return if perms.get_staff_rank( ctx.message.author) <= perms.get_staff_rank(user): await ctx.send(embed=interface.error_message( "Error", f"You can't jail someone of the same staff rank or higher.")) return if defs.jail_role_id in [r.id for r in user.roles]: await ctx.send(embed=interface.error_message( "Error", f"{user} is already jailed.", f"User ID: {user.id}")) return if reason: chanmsg = f"{user.mention} has been placed in jail.\n\nReason: **{reason}**" dmmsg = f"You have been placed in jail.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been placed in jail." dmmsg = f"You have been placed in jail." try: db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "jail", reason) db.add_jail(ctx.message.author, user, reason) await user.remove_roles(*user.roles[1:], atomic=True) await user.add_roles(user.guild.get_role(defs.jail_role_id), atomic=True) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the jail you just attempted to issue.", )) else: await ctx.send(embed=interface.error_message( "Jail", chanmsg, f"User ID: {user.id}")) await user.send(embed=interface.error_message( f"{ctx.message.guild} - Jail", dmmsg))
async def mod_unmute(self, ctx, user: discord.Member, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("unmute", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **unmute** command." )) return if user.id == ctx.message.author.id: await ctx.send(embed=interface.error_message( "Error", f"You can't unmute yourself.")) return if perms.get_staff_rank( ctx.message.author) <= perms.get_staff_rank(user): await ctx.send(embed=interface.error_message( "Error", f"You can't unmute someone of the same staff rank or higher.")) return if defs.mute_role_id not in [r.id for r in user.roles]: await ctx.send(embed=interface.error_message( "Error", f"{user} is not muted.", f"User ID: {user.id}")) return if reason: chanmsg = f"{user.mention} has been unmuted.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been unmuted." try: db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "unmute", reason) await self.do_unmute(db.get_mute_record(user)) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the unmute you just attempted.") ) else: await ctx.send(embed=interface.success_message( "Unmute", chanmsg, f"User ID: {user.id}"))
async def mod_unjail(self, ctx, user: discord.Member, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("unjail", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **unjail** command." )) return if user.id == ctx.message.author.id: await ctx.send(embed=interface.error_message( "Error", f"You can't unjail yourself.")) return if perms.get_staff_rank( ctx.message.author) <= perms.get_staff_rank(user): await ctx.send(embed=interface.error_message( "Error", f"You can't unjail someone of the same staff rank or higher.")) return if defs.jail_role_id not in [r.id for r in user.roles]: await ctx.send(embed=interface.error_message( "Error", f"{user} is not jailed.", f"User ID: {user.id}")) return if reason: chanmsg = f"{user.mention} has been released from jail.\n\nReason: **{reason}**" dmmsg = f"You have been released from jail.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been released from jail." dmmsg = f"You have been released from jail." try: db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, "unjail", reason) jail = db.get_jail_record(user) roles = [user.guild.get_role(rid) for rid in jail["roles"]] roles = [ r for r in roles if r is not None and r.name != "@everyone" ] db.remove_jail(user) await user.remove_roles(user.guild.get_role(defs.jail_role_id), atomic=True) await user.add_roles(*roles, atomic=True) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the unjail you just attempted to issue.", )) else: await ctx.send(embed=interface.success_message( "Unjail", chanmsg, f"User ID: {user.id}")) await user.send(embed=interface.success_message( f"{ctx.message.guild} - Unjail", dmmsg))
async def mod_mute(self, ctx, user: discord.Member, duration: str, *, reason: str = None): await ctx.message.delete() if not perms.check_command_priv("mute", ctx.message.author.roles): await ctx.send(embed=interface.error_message( "Access Denied", f"**{ctx.message.author}** does not have access to the **mute** command." )) return if user.id == ctx.message.author.id: await ctx.send(embed=interface.error_message( "Error", f"You can't mute yourself.")) return if perms.get_staff_rank( ctx.message.author) <= perms.get_staff_rank(user): await ctx.send(embed=interface.error_message( "Error", f"You can't mute someone of the same staff rank or higher.")) return if defs.mute_role_id in [r.id for r in user.roles]: await ctx.send(embed=interface.error_message( "Error", f"{user} is already muted.", f"User ID: {user.id}")) return dur_num = 0 num = int(duration[:-1]) if duration.endswith("s"): dur_num = num elif duration.endswith("m"): dur_num = num * 60 elif duration.endswith("h"): dur_num = num * 3600 elif duration.endswith("d"): dur_num = num * 86400 exp_time = utils.get_timestamp() + dur_num if reason: chanmsg = f"{user.mention} has been muted for {utils.get_durationstr(dur_num)}.\n\nReason: **{reason}**" dmmsg = f"You have been muted for {utils.get_durationstr(dur_num)}.\n\nReason: **{reason}**" else: chanmsg = f"{user.mention} has been muted for {utils.get_durationstr(dur_num)}." dmmsg = f"You have been muted for {utils.get_durationstr(dur_num)}." try: db.log_staff_action(utils.get_timestamp(), ctx.message.author, user, f"mute ({duration})", reason) db.add_mute(ctx.message.author, user, exp_time, reason) await user.remove_roles(*user.roles[1:], atomic=True) await user.add_roles(user.guild.get_role(defs.mute_role_id), atomic=True) except: raise await ctx.author.send(embed=interface.error_message( f"{ctx.message.guild} - Error", "There was an error processing the mute you just attempted to issue.", )) else: await ctx.send(embed=interface.error_message( "Mute", chanmsg, f"User ID: {user.id}")) await user.send(embed=interface.error_message( f"{ctx.message.guild} - Mute", dmmsg))