async def ban_member(self, ctx, member: FetchMember, days: typing.Optional[int] = 0, *, reason=""): """Bans a user from the server. OP+ only. Optional: [days] Specify up to 7 days of messages to delete.""" if await check_bot_or_staff(ctx, member, "ban"): return if days > 7: days = 7 elif days < 0: days = 0 if isinstance(member, discord.Member): msg = f"You were banned from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban does not expire." await utils.send_dm_message(member, msg) try: await ctx.cog.remove_timed_restriction(member.id, 'timeban') self.bot.actions.append("ub:" + str(member.id)) await ctx.guild.ban(member, reason=reason, delete_message_days=days) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now b&. 👍") msg = f"⛔ **Ban**: {ctx.author.mention} banned {member.mention} | {self.bot.escape_text(member)}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." if reason == "" else ""))
async def softwarn(self, ctx, member: Union[discord.Member, discord.User], *, reason=""): """Warn a user without automated action. Staff and Helpers only.""" issuer = ctx.author channel = ctx.channel if await check_bot_or_staff(ctx, member, "warn"): return warn_count = len(await crud.get_warns(member.id)) if warn_count >= 5: await ctx.send("A user can't have more than 5 warns!") return warn_count += 1 await crud.add_warn(member.id, ctx.author.id, reason) if isinstance(member, discord.Member): msg = f"You were warned on {ctx.guild}." if reason != "": # much \n msg += " The given reason is: " + reason msg += f"\n\nThis is warn #{warn_count}." msg += "\n\nThis won't trigger any action." await utils.send_dm_message(member, msg, ctx) await ctx.send( f"{member.mention} softwarned. User has {warn_count} warning(s)") msg = f"⚠️ **Warned**: {issuer.mention} softwarned {member.mention} in {channel.mention} ({self.bot.escape_text(channel)}) (warn #{warn_count}) | {self.bot.escape_text(member)}" signature = utils.command_signature(self.warn) if reason != "": # much \n msg += "\n✏️ __Reason__: " + reason await self.bot.channels['mod-logs'].send(msg + ( f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." if reason == "" else ""))
async def mute(self, ctx, member: discord.Member, *, reason=""): """Mutes a user so they can't speak. Staff only.""" if await check_bot_or_staff(ctx, member, "mute"): return if not await crud.add_permanent_role(member.id, self.bot.roles['Muted'].id): # Check if the user has a timed restriction. # If there is one, this will convert it to a permanent one. # If not, it will display that it was already taken. if not await crud.get_time_restrictions_by_user_type( member.id, 'timemute'): return await ctx.send("User is already muted!") else: await crud.remove_timed_restriction(member.id, 'timemute') await member.add_roles(self.bot.roles['Muted']) await member.remove_roles(self.bot.roles['#elsewhere'], self.bot.roles['#art-discussion']) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason await utils.send_dm_message(member, msg_user, ctx) await ctx.send(f"{member.mention} can no longer speak.") msg = f"🔇 **Muted**: {ctx.author.mention} muted {member.mention} | {self.bot.escape_text(member)}" if reason != "": msg += "\n✏️ __Reason__: " + reason else: signature = utils.command_signature(ctx.command) msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def helpmute(self, ctx, member: Union[discord.Member, discord.User], *, reason=""): """Remove speak perms to the assistance channels. Staff and Helpers only.""" if await check_bot_or_staff(ctx, member, "helpmute"): return if not await crud.add_permanent_role(member.id, self.bot.roles['help-mute'].id): if not await crud.get_time_restrictions_by_user_type( member.id, 'timehelpmute'): return await ctx.send("This user is already helpmuted!") else: await crud.remove_timed_restriction(member.id, 'timehelpmute') msg_user = "******" if isinstance(member, discord.Member): await member.add_roles(self.bot.roles['help-mute']) if reason != "": msg_user += " The given reason is: " + reason msg_user += "\n\nIf you feel this was unjustified, you may appeal in <#270890866820775946>." await utils.send_dm_message(member, msg_user, ctx) await ctx.send( f"{member.mention} can no longer speak in the help channels.") msg = f"🚫 **Help mute**: {ctx.author.mention} removed speak access in help channels from {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def kick_member(self, ctx: GuildContext, member: discord.Member, *, reason: str = ""): """Kicks a user from the server. Staff only.""" if await check_bot_or_staff(ctx, member, "kick"): return msg = f"You were kicked from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += "\n\nYou are able to rejoin the server, but please read the rules in #welcome-and-rules before participating again." await send_dm_message(member, msg, ctx) try: self.bot.actions.append("uk:" + str(member.id)) await member.kick(reason=reason) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now gone. 👌") msg = f"👢 **Kick**: {ctx.author.mention} kicked {member.mention} | {self.bot.escape_text(member)}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. " f"In the future, it is recommended to use `{signature}`" f" as the reason is automatically sent to the user." if reason == "" else ""))
async def probate(self, ctx, member: Union[discord.Member, discord.User], *, reason=""): """Probate a user. Staff and Helpers only.""" if await check_bot_or_staff(ctx, member, "probate"): return if not await crud.add_permanent_role(member.id, self.bot.roles['Probation'].id): return await ctx.send("This user is already probated!") if isinstance(member, discord.Member): await member.add_roles(self.bot.roles['Probation']) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason await utils.send_dm_message(member, msg_user, ctx) await ctx.send(f"{member.mention} is now in probation.") msg = f"🚫 **Probated**: {ctx.author.mention} probated {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def timeban_member(self, ctx: GuildContext, member: Union[discord.Member, discord.User], length: int = commands.parameter(converter=DateOrTimeToSecondsConverter), *, reason=""): """Bans a user for a limited period of time. OP+ only.\n\nLength format: #d#h#m#s""" if await check_bot_or_staff(ctx, member, "timeban"): return timestamp = datetime.datetime.now() delta = datetime.timedelta(seconds=length) unban_time = timestamp + delta unban_time_string = format_dt(unban_time) if isinstance(member, discord.Member): msg = f"You were banned from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += f"\n\nThis ban lasts until {unban_time_string}." await send_dm_message(member, msg, ctx) try: self.bot.actions.append("ub:" + str(member.id)) await ctx.guild.ban(member, reason=reason, delete_message_days=0) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await crud.add_timed_restriction(member.id, unban_time, 'timeban') await ctx.send(f"{member} is now b& until {unban_time_string}. 👍") msg = f"⛔ **Time ban**: {ctx.author.mention} banned {member.mention} until {unban_time_string} | {member}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. " f"In the future, it is recommended to use `{signature}`" f" as the reason is automatically sent to the user." if reason == "" else ""))
async def superban(self, ctx: GuildContext, member: Union[discord.Member, discord.User], days: Optional[Literal[0, 1, 2, 3, 4, 5, 6, 7]] = 0, *, reason=""): """Bans a user from the server. OP+ only. Optional: [days] Specify up to 7 days of messages to delete.""" if await check_bot_or_staff(ctx, member, "ban"): return if isinstance(member, discord.Member): msg = f"You were superbanned from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban does not expire.\n\nhttps://nintendohomebrew.com/assets/img/banned.gif" await send_dm_message(member, msg, ctx) try: await crud.remove_timed_restriction(member.id, 'timeban') self.bot.actions.append("ub:" + str(member.id)) await ctx.guild.ban(member, reason=reason, delete_message_days=days) # type: ignore except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now SUPER BANNED. 👍 https://nintendohomebrew.com/assets/img/banned.gif") msg = f"⛔ **Ban**: {ctx.author.mention} banned {member.mention} | {self.bot.escape_text(member)}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. " f"In the future, it is recommended to use `{signature}`" f" as the reason is automatically sent to the user." if reason == "" else ""))
async def silentban_member(self, ctx, member: discord.Member, days: Optional[int] = 0, *, reason=""): """Bans a user from the server, without a notification. OP+ only. Optional: [days] Specify up to 7 days of messages to delete.""" if await check_bot_or_staff(ctx, member, "ban"): return if days > 7: days = 7 elif days < 0: days = 0 try: self.bot.actions.append("ub:" + str(member.id)) await ctx.cog.remove_timed_restriction(member.id, 'timeban') await member.ban(reason=reason, delete_message_days=days) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now b&. 👍") msg = f"⛔ **Silent ban**: {ctx.author.mention} banned {member.mention} | {self.bot.escape_text(member)}\n"\ f"🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + ( f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}`." if reason == "" else ""))
async def taketech(self, ctx, member: Union[discord.Member, discord.User], *, reason=""): """Remove access to the tech channel. Staff and Helpers only.""" if await check_bot_or_staff(ctx, member, "taketech"): return if not await crud.add_permanent_role(member.id, self.bot.roles['No-Tech'].id): # Check if the user has a timed restriction. # If there is one, this will convert it to a permanent one. # If not, it will display that it was already taken. if not await crud.get_time_restrictions_by_user_type( member.id, 'timenotech'): return await ctx.send("This user's tech is already taken!") else: await crud.remove_timed_restriction(member.id, 'timenotech') msg_user = "******" if isinstance(member, discord.Member): await member.add_roles(self.bot.roles['No-Tech']) if reason != "": msg_user += " The given reason is: " + reason msg_user += "\n\nIf you feel this was unjustified, you may appeal in <#270890866820775946>." await utils.send_dm_message(member, msg_user, ctx) await ctx.send( f"{member.mention} can no longer access the tech channel.") msg = f"🚫 **Help access removed**: {ctx.author.mention} removed access to tech channel from {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def warn(self, ctx: GuildContext, member: Union[discord.Member, discord.User], *, reason=""): """Warn a user. Staff and Helpers only.""" issuer = ctx.author channel = ctx.channel if await check_bot_or_staff(ctx, member, "warn"): return warn_count = len(await crud.get_warns(member.id)) if warn_count >= 5: await ctx.send("A user can't have more than 5 warns!") return await crud.add_warn(member.id, issuer.id, reason) warn_count += 1 if isinstance(member, discord.Member): msg = f"You were warned on {ctx.guild.name}." if reason != "": # much \n msg += " The given reason is: " + reason msg += f"\n\nPlease read the rules in {self.bot.channels['welcome-and-rules'].mention}. This is warn #{warn_count}." if warn_count == 2: msg += " __The next warn will automatically kick.__" elif warn_count == 3: msg += "\n\nYou were kicked because of this warning. You can join again right away. Two more warnings will result in an automatic ban." elif warn_count == 4: msg += "\n\nYou were kicked because of this warning. This is your final warning. You can join again, but **one more warn will result in a ban**." elif warn_count == 5: msg += "\n\nYou were automatically banned due to five warnings." await send_dm_message(member, msg, ctx) if warn_count in {3, 4}: try: self.bot.actions.append("wk:" + str(member.id)) await member.kick(reason=f"{warn_count} warns.") except discord.Forbidden: await ctx.send("I can't kick this user!") if warn_count >= 5: # just in case self.bot.actions.append("wb:" + str(member.id)) try: await ctx.guild.ban(member, reason="5 warns.", delete_message_days=0) except discord.Forbidden: await ctx.send("I can't ban this user!") await ctx.send( f"{member.mention} warned. User has {warn_count} warning(s)") msg = f"⚠️ **Warned**: {issuer.mention} warned {member.mention} in {channel.mention} ({self.bot.escape_text(channel)}) (warn #{warn_count}) | {self.bot.escape_text(member)}" signature = command_signature(ctx.command) if reason != "": # much \n msg += "\n✏️ __Reason__: " + reason await self.bot.channels['mod-logs'].send(msg + ( f"\nPlease add an explanation below." f" In the future, it is recommended to use `{signature}`" f" as the reason is automatically sent to the user." if reason == "" else ""))
async def watch(self, ctx, member: converters.SafeMember, *, reason=""): if await self.is_watched(member.id): await ctx.send("User is already being watched!") return await self.add_watch(member.id) await ctx.send(f"{member.mention} is being watched.") msg = f"👀 **Watch**: {ctx.author.mention} put {member.mention} on watch | {member}" if reason != "": # much \n msg += "\n✏️ __Reason__: " + reason signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + ( f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is very useful for saving time." if reason == "" else "")) await self.bot.channels['watch-logs'].send(msg + ( "\nNo reason provided." if reason == "" else ""))
async def noart(self, ctx, member: SafeMember, *, reason=""): """Removes art-discussion access from a user. Staff only.""" if not await self.add_restriction(member.id, self.bot.roles['No-art']): return await ctx.send("This user is already restricted from art channels.") try: await member.add_roles(self.bot.roles['No-art']) except discord.Forbidden: await ctx.send("💢 I don't have permission to do this.") await ctx.send(f"{member.mention} can no longer access art-discussion.") msg = f"🚫 **Removed art**: {ctx.message.author.mention} removed art access from {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def noelsewhere(self, ctx, member: discord.Member, *, reason=""): """Removes elsewhere access from a user. Staff only.""" try: if not await crud.add_permanent_role( member.id, self.bot.roles['No-elsewhere'].id): return await ctx.send( "This user is already restricted from elsewhere!") await member.add_roles(self.bot.roles['No-elsewhere']) await member.remove_roles(self.bot.roles['#elsewhere']) await ctx.send(f"{member.mention} can no longer access elsewhere.") msg = f"🚫 **Removed elsewhere**: {ctx.author.mention} removed elsewhere access from {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.")
async def metamute(self, ctx, member: discord.Member, *, reason=""): """Mutes a user so they can't speak in meta. Staff only.""" if not await crud.add_permanent_role(member.id, self.bot.roles['meta-mute'].id): await ctx.send("User is already meta muted!") return await member.add_roles(self.bot.roles['meta-mute']) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason await utils.send_dm_message(member, msg_user, ctx) await ctx.send(f"{member.mention} can no longer speak in meta.") msg = f"🔇 **Meta muted**: {ctx.author.mention} meta muted {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def metamute(self, ctx, member: SafeMember, *, reason=""): """Mutes a user so they can't speak in meta. Staff only.""" if not await self.add_restriction(member.id, self.bot.roles['meta-mute']): await ctx.send("User is already meta muted!") return await member.add_roles(self.bot.roles['meta-mute']) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason try: await member.send(msg_user) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot await ctx.send(f"{member.mention} can no longer speak in meta.") msg = f"🔇 **Meta muted**: {ctx.author.mention} meta muted {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg)
async def noembed(self, ctx, member: SafeMember, *, reason=""): """Removes embed permissions from a user. Staff only.""" if await check_bot_or_staff(ctx, member, "noembed"): return try: await self.add_restriction(member.id, self.bot.roles['No-Embed']) await member.add_roles(self.bot.roles['No-Embed']) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason msg_user += "\n\nIf you feel this was unjustified, you may appeal in <#270890866820775946>." await utils.send_dm_message(member, msg_user) await ctx.send(f"{member.mention} can no longer embed links or attach files.") msg = f"🚫 **Removed Embed**: {ctx.author.mention} removed embed from {member.mention} | {self.bot.escape_text(member)}" signature = utils.command_signature(ctx.command) if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.")
class KickBan(DatabaseCog): """ Kicking and banning users. """ async def cog_check(self, ctx): if ctx.guild is None: raise commands.NoPrivateMessage() return True async def meme(self, beaner: discord.Member, beaned: discord.Member, action: str, channel: discord.TextChannel, reason: str): await channel.send(f"Seriously? What makes you think it's okay to try and {action} another staff or helper like that?") msg = f"{beaner.mention} attempted to {action} {beaned.mention}|{beaned} in {channel.mention} " if reason != "": msg += "for the reason " + reason await self.bot.channels['meta'].send(msg + (" without a reason" if reason == "" else "")) @is_staff("HalfOP") @commands.bot_has_permissions(kick_members=True) @commands.command(name="kick") async def kick_member(self, ctx, member: SafeMember, *, reason=""): """Kicks a user from the server. Staff only.""" if await check_bot_or_staff(ctx, member, "kick"): return msg = f"You were kicked from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += "\n\nYou are able to rejoin the server, but please read the rules in #welcome-and-rules before participating again." await utils.send_dm_message(member, msg) try: self.bot.actions.append("uk:" + str(member.id)) await member.kick(reason=reason) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now gone. 👌") msg = f"👢 **Kick**: {ctx.author.mention} kicked {member.mention} | {self.bot.escape_text(member)}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." if reason == "" else "")) @is_staff("OP") @commands.bot_has_permissions(ban_members=True) @commands.command(name="ban", aliases=["yeet"]) async def ban_member(self, ctx, member: FetchMember, days: typing.Optional[int] = 0, *, reason=""): """Bans a user from the server. OP+ only. Optional: [days] Specify up to 7 days of messages to delete.""" if await check_bot_or_staff(ctx, member, "ban"): return if days > 7: days = 7 elif days < 0: days = 0 if isinstance(member, discord.Member): msg = f"You were banned from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban does not expire." await utils.send_dm_message(member, msg) try: await ctx.cog.remove_timed_restriction(member.id, 'timeban') self.bot.actions.append("ub:" + str(member.id)) await ctx.guild.ban(member, reason=reason, delete_message_days=days) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now b&. 👍") msg = f"⛔ **Ban**: {ctx.author.mention} banned {member.mention} | {self.bot.escape_text(member)}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." if reason == "" else "")) @is_staff("OP") @commands.bot_has_permissions(ban_members=True) @commands.command(name="unban", aliases=["unyeet"]) async def unban_member(self, ctx, user: FetchMember, reason): """Unbans a user from the server. OP+ only.""" try: await ctx.guild.fetch_ban(user) except discord.errors.NotFound: return await ctx.send(f"{user} is not banned!") await ctx.cog.remove_timed_restriction(user.id, 'timeban') self.bot.actions.append("tbr:"+str(user.id)) await ctx.guild.unban(user, reason=reason) await ctx.send(f"{user} is now unbanned.") msg = f"⚠ **Unban**: {ctx.author.mention} unbanned {user.mention} | {self.bot.escape_text(user)}\n🏷 __User ID__: {user.id}\n✏️ __Reason__: {reason}" await self.bot.channels['mod-logs'].send(msg) await self.bot.channels['server-logs'].send(msg) @is_staff("OP") @commands.bot_has_permissions(ban_members=True) @commands.command(name="silentban", aliases=["quietyeet"]) async def silentban_member(self, ctx, member: SafeMember, days: typing.Optional[int] = 0, *, reason=""): """Bans a user from the server, without a notification. OP+ only. Optional: [days] Specify up to 7 days of messages to delete.""" if await check_bot_or_staff(ctx, member, "ban"): return if days > 7: days = 7 elif days < 0: days = 0 try: self.bot.actions.append("ub:" + str(member.id)) await ctx.cog.remove_timed_restriction(member.id, 'timeban') await member.ban(reason=reason, delete_message_days=days) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await ctx.send(f"{member} is now b&. 👍") msg = f"⛔ **Silent ban**: {ctx.author.mention} banned {member.mention} | {self.bot.escape_text(member)}\n"\ f"🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}`." if reason == "" else "")) @is_staff("OP") @commands.bot_has_permissions(ban_members=True) @commands.command(name="timeban", aliases=["timeyeet"]) async def timeban_member(self, ctx, member: FetchMember, length, *, reason=""): """Bans a user for a limited period of time. OP+ only.\n\nLength format: #d#h#m#s""" if await check_bot_or_staff(ctx, member, "timeban"): return if (seconds := utils.parse_time(length)) == -1: return await ctx.send("💢 I don't understand your time format.") timestamp = datetime.datetime.now() delta = datetime.timedelta(seconds=seconds) unban_time = timestamp + delta unban_time_string = unban_time.strftime("%Y-%m-%d %H:%M:%S") if isinstance(member, discord.Member): msg = f"You were banned from {ctx.guild.name}." if reason != "": msg += " The given reason is: " + reason msg += f"\n\nThis ban expires {unban_time_string} {time.tzname[0]}." await utils.send_dm_message(member, msg) try: self.bot.actions.append("ub:" + str(member.id)) await ctx.guild.ban(member, reason=reason, delete_message_days=0) except discord.errors.Forbidden: await ctx.send("💢 I don't have permission to do this.") return await self.add_timed_restriction(member.id, unban_time_string, 'timeban') await ctx.send(f"{member} is now b& until {unban_time_string} {time.tzname[0]}. 👍") msg = f"⛔ **Time ban**: {ctx.author.mention} banned {member.mention} until {unban_time_string} | {member}\n🏷 __User ID__: {member.id}" if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.channels['server-logs'].send(msg) signature = utils.command_signature(ctx.command) await self.bot.channels['mod-logs'].send(msg + (f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." if reason == "" else ""))
return await ctx.send("💢 I don't understand your time format.") timestamp = datetime.datetime.now() delta = datetime.timedelta(seconds=seconds) unmute_time = timestamp + delta unmute_time_string = unmute_time.strftime("%Y-%m-%d %H:%M:%S") old_timestamp = await crud.add_timed_restriction( member.id, unmute_time, 'timemute') await crud.add_permanent_role(member.id, self.bot.roles['Muted'].id) msg_user = "******" if reason != "": msg_user += " The given reason is: " + reason msg_user += f"\n\nThis mute expires {unmute_time_string} {time.tzname[0]}." await utils.send_dm_message(member, msg_user, ctx) signature = utils.command_signature(ctx.command) if not old_timestamp: await ctx.send(f"{member.mention} can no longer speak.") msg = f"🔇 **Timed mute**: {issuer.mention} muted {member.mention}| {self.bot.escape_text(member)} for {delta}, until {unmute_time_string} " else: await ctx.send(f"{member.mention} mute was updated.") msg = f"🔇 **Timed mute**: {issuer.mention} updated {member.mention}| {self.bot.escape_text(member)} time mute from {old_timestamp} until {unmute_time_string}" if reason != "": msg += "\n✏️ __Reason__: " + reason else: msg += f"\nPlease add an explanation below. In the future, it is recommended to use `{signature}` as the reason is automatically sent to the user." await self.bot.channels['mod-logs'].send(msg) @is_staff("HalfOP") @commands.guild_only() @commands.command()