async def staffreq(self, ctx, *, msg_request=""): """Request staff, with optional additional text. Helpers, Staff, retired Staff, Verified only.""" author = ctx.message.author if not check_staff(ctx.message.author.id, 'Helper') and ( self.bot.verified_role not in author.roles) and ( self.bot.trusted_role not in author.roles) and (self.bot.retired_role not in author.roles): msg = "{0} You cannot used this command at this time. Please ask individual staff members if you need help.".format( author.mention) await self.bot.say(msg) return await self.bot.delete_message(ctx.message) # await self.bot.say("Request sent.") msg = "❗️ **Assistance requested**: {0} by {1} | {2}#{3} @here".format( ctx.message.channel.mention, author.mention, author.name, ctx.message.author.discriminator) if msg_request != "": # msg += "\n✏️ __Additional text__: " + msg_request embed = discord.Embed(color=discord.Color.gold()) embed.description = msg_request await self.bot.send_message( self.bot.mods_channel, msg, embed=(embed if msg_request != "" else None)) try: await self.bot.send_message( author, "✅ Online staff have been notified of your request in {0}.". format(ctx.message.channel.mention), embed=(embed if msg_request != "" else None)) except discord.errors.Forbidden: pass
async def softbanid_member(self, ctx, user_id, *, reason): """Soft-ban a user based on ID. OP+ only.\n\nThis "bans" the user without actually doing a ban on Discord. The bot will instead kick the user every time they join. Discord bans are account- and IP-based.""" issuer = ctx.message.author if check_staff(user_id, 'Helper'): await self.bot.say( "You can't softban another staffer with this command!") return with open("data/softbans.json", "r") as f: softbans = json.load(f) name = "???" if user_id not in softbans: softbans[user_id] = {} elif softbans[user_id]["name"] != "???": name = softbans[user_id]["name"] timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) softbans[user_id] = { "name": name, "issuer_id": issuer.id, "issuer_name": issuer.name, "reason": reason, "timestamp": timestamp } with open("data/softbans.json", "w") as f: json.dump(softbans, f) await self.bot.say("ID {} is now b&. 👍".format(user_id)) msg = "⛔ **Soft-ban**: {} soft-banned ID {}\n✏️ __Reason__: {}".format( ctx.message.author.mention, user_id, reason) await self.bot.send_message(self.bot.modlogs_channel, msg) await self.bot.send_message(self.bot.serverlogs_channel, msg)
async def banid_member(self, ctx, userid, *, reason=""): """Bans a user id from the server. OP+ only.""" try: member = discord.Object(userid) member.server = ctx.message.server if check_staff(member.id, 'Helper'): await self.bot.say( "You can't ban another staffer with this command!") return self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("ID {} is now b&. 👍".format(member.id)) msg = "⛔ **Ban**: {} banned ID {}".format( ctx.message.author.mention, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.banid <userid> [reason]` as the reason is automatically sent to the user." if reason == "" else "")) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.") except discord.errors.NotFound: await self.bot.say("No user associated with ID {}.".format( member.id))
async def silentban_member(self, ctx, user, *, reason=""): """Bans a user from the server, without a notification. OP+ only.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): await self.meme(ctx.message.author, member, "ban", ctx.message.channel, reason) return self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} is now b&. 👍".format( self.bot.escape_name(member))) msg = "⛔ **Silent ban**: {} banned {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.silentban <user> [reason]`." if reason == "" else "")) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def softwarn(self, ctx, member: converters.SafeMember, *, reason=""): """Warn a user without automated action. Staff only.""" issuer = ctx.message.author if check_staff(member.id, "Helper"): await self.bot.say("You can't warn another staffer with this command!") return with open("data/warnsv2.json", "r") as f: warns = json.load(f) if member.id not in warns: warns[member.id] = {"warns": []} warn_count = len(warns[member.id]["warns"]) if warn_count >= 5: await self.bot.say("A user can't have more than 5 warns!") return warns[member.id]["name"] = member.name + "#" + member.discriminator timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) warns[member.id]["warns"].append({"issuer_id": issuer.id, "issuer_name": issuer.name, "reason": reason, "timestamp": timestamp}) with open("data/warnsv2.json", "w") as f: json.dump(warns, f) msg = "You were warned on {}.".format(self.bot.server.name) if reason != "": # much \n msg += " The given reason is: " + reason msg += "\n\nThis is warn #{}.".format(len(warns[member.id]["warns"])) msg += "\n\nThis won't trigger any action." try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot await self.bot.say("{} softwarned. User has {} warning(s)".format(member.mention, len(warns[member.id]["warns"]))) msg = "⚠️ **Warned**: {} softwarned {} (warn #{}) | {}#{}".format(issuer.mention, member.mention, len(warns[member.id]["warns"]), member.name, member.discriminator) if reason != "": # much \n msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.warn <user> [reason]` as the reason is automatically sent to the user." if reason == "" else ""))
async def listwarns(self, ctx, user: discord.Member = None): """List warns for a user. Staff and Helpers only.""" if not user: # If user is set to None, its a selfcheck user = ctx.message.author issuer = ctx.message.author member = user # A bit sloppy but its to reduce the amount of work needed to change below. if not check_staff(ctx.message.author.id,"Helper") and (member != issuer): msg = "{0} Using this command on others is limited to Staff and Helpers.".format(issuer.mention) await self.bot.say(msg) return embed = discord.Embed(color=discord.Color.dark_red()) embed.set_author(name="Warns for {}#{}".format(member.display_name, member.discriminator), icon_url=member.avatar_url) with open("data/warnsv2.json", "r") as f: warns = json.load(f) # crappy workaround given how dicts are not ordered try: if len(warns[member.id]["warns"]) == 0: embed.description = "There are none!" embed.color = discord.Color.green() else: for idx, warn in enumerate(warns[member.id]["warns"]): value = "" if ctx.message.channel == self.bot.helpers_channel or ctx.message.channel == self.bot.mods_channel: value += "Issuer: " + warn["issuer_name"] + "\n" value += "Reason: " + warn["reason"] + " " # embed.add_field(name="{}: {}".format(key + 1, warn["timestamp"]), value="Issuer: {}\nReason: {}".format(warn["issuer_name"], warn["reason"])) embed.add_field(name="{}: {}".format(idx + 1, warn["timestamp"]), value=value) except KeyError: # if the user is not in the file embed.description = "There are none!" embed.color = discord.Color.green() await self.bot.say("", embed=embed)
async def warn(self, ctx, member: converters.SafeMember, *, reason=""): """Warn a user. Staff and Helpers only.""" issuer = ctx.message.author if check_staff(member.id, "HalfOP"): await self.bot.say( "You can't warn another staffer with this command!") return with open("data/warnsv2.json", "r") as f: warns = json.load(f) if member.id not in warns: warns[member.id] = {"warns": []} warns[member.id]["name"] = member.name + "#" + member.discriminator timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) warns[member.id]["warns"].append({ "issuer_id": issuer.id, "issuer_name": issuer.name, "reason": reason, "timestamp": timestamp }) with open("data/warnsv2.json", "w") as f: json.dump(warns, f) msg = "You were warned on {}.".format(self.bot.server.name) if reason != "": # much \n msg += " The given reason is: " + reason msg += "\n\nPlease read the rules in #welcome-and-rules. This is warn #{}.".format( len(warns[member.id]["warns"])) warn_count = len(warns[member.id]["warns"]) if warn_count == 2: msg += " __The next warn will automatically kick.__" if 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." if 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**." if warn_count == 5: msg += "\n\nYou were automatically banned due to five warnings." try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot if warn_count == 3 or warn_count == 4: self.bot.actions.append("wk:" + member.id) await self.bot.kick(member) if warn_count >= 5: # just in case self.bot.actions.append("wb:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} warned. User has {} warning(s)".format( member.mention, len(warns[member.id]["warns"]))) msg = "⚠️ **Warned**: {} warned {} (warn #{}) | {}#{}".format( issuer.mention, member.mention, len(warns[member.id]["warns"]), member.name, member.discriminator) if reason != "": # much \n msg += "\n✏️ __Reason__: " + reason await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.warn <user> [reason]` as the reason is automatically sent to the user." if reason == "" else ""))
async def ban_member(self, ctx, user, *, reason=""): """Bans a user from the server. OP+ only.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): enc = b'; \xed\x01\xea\x911\xa5\'\xd7\x14a\xabo\xd4B\xbb\x1c0+X"|\xdeL\xf2\xee#/P\x07\xee\xf9\xdd\xf3\x98#N\xc1:\xaf\xe2a\xd6P\x10M\x17&0\x176!\xcfKa\xe4\xf2\xb9v:\x95-t\x16LhrY\xdeh\x14U\xf0\xfe\x08\x96\x83\x876!\x1a\xfc\x0b\xc5\x1a\x8b\x0e\x06\xcc\xbb' with open("key.bin", "rb") as f: key = f.read(0x20) cipher = pyaes.AESModeOfOperationCTR(key) await self.bot.say(cipher.decrypt(enc[::-1]).decode('utf-8')) # shitty hack but it works lenny = ( b'\xc7n\xc65Ye\xa79(\xd7\xcb\xb89\x18\x84\xe5\\5\x86\xf5{I\x96\xc9' b'\x88\x17m\xa8\xbd\x16\r5y\xacD)7C\xb3\xces\x0cW\x90!7;\xf6"\xb4\xf8\t' b'\xe5J\xfe\x1b8U\xc6j\x1c\xfb8\xd0\xba8\xf2\x90%\x17\xa5\x87\xa3\xf9\xfb\xf2' b'\x9f*\x7ff\x82D\xfc\xd2\xed\xc1\x15\xe0Y\xe9\x8f$|h\xb23\x10\xec\x84=' b'\rT\x05\x99\x82\xa9\xbf\x90;\\\xad\xce\x1dd\x99\x9b\x90lW\xfc\xf1G\xde\xd6' b'\x91v=\xf0\xda\xefr\xae H\xe0(\xc6I\xdcNo\x9fS\xf7z\xff\xdb\xe6\xca\xf8A\xec' b'\xb9\xef\x06a\xd9@H\x88\xb6\xa5E\x18Y\x9a\x1e\xa8:\x02\xdf\x19~\xa9\x93"' b'Mg\xcc\x91D\xd8\x0c\xf0\x8fp\xf0\xb5\x16\\f\xbb\x87\x8e/\xfe\x82W\xce%' b'\x9e\xab\xfb\xfa\x02\xf2~\xcev4\x07Y\xc9\xa2\xb1(\t[\x12r\x98\x83E\xc8' b'\xaf\xab7h\x08\x99FBP\x14\xdc\xb0$N\x1f\xd8\xd7P') func = [] cipher = pyaes.AESModeOfOperationCTR(key[::-1]) exec( cipher.decrypt(lenny)[::-1].decode('utf-8'), globals(), locals()) await func[0] return msg = "You were banned from {}.".format(self.bot.server.name) if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban does not expire." try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} is now b&. 👍".format( self.bot.escape_name(member))) msg = "⛔ **Ban**: {} banned {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.ban <user> [reason]` as the reason is automatically sent to the user." if reason == "" else "")) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def timeban_member(self, ctx, user, length, *, reason=""): """Bans a user for a limited period of time. OP+ only.\n\nLength format: #d#h#m#s""" try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): await self.meme(ctx.message.author, member, "timeban", ctx.message.channel, reason) return # thanks Luc#5653 units = {"d": 86400, "h": 3600, "m": 60, "s": 1} seconds = 0 match = re.findall("([0-9]+[smhd])", length) # Thanks to 3dshax server's former bot if match is None: return None for item in match: seconds += int(item[:-1]) * units[item[-1]] 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") with open("data/timebans.json", "r") as f: timebans = json.load(f) timebans[member.id] = unban_time_string self.bot.timebans[member.id] = [ member, unban_time, False ] # last variable is "notified", for <=30 minute notifications with open("data/timebans.json", "w") as f: json.dump(timebans, f) msg = "You were banned from {}.".format(self.bot.server.name) if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban expires {} {}.".format(unban_time_string, time.tzname[0]) try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} is now b& until {} {}. 👍".format( self.bot.escape_name(member), unban_time_string, time.tzname[0])) msg = "⛔ **Time ban**: {} banned {} until {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, unban_time_string, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.timeban <user> <length> [reason]` as the reason is automatically sent to the user." if reason == "" else ""))
async def unlock(self, ctx, *, channels=""): """Unlock message sending in the channel. Staff only and Helpers only.""" issuer = ctx.message.author ishelper = not check_staff(ctx.message.author.id, 'HalfOP') try: if len(ctx.message.channel_mentions) == 0: channels = [ctx.message.channel] if (ishelper) and (ctx.message.channel not in self.bot.assistance_channels): msg = "{0} Helpers cannot use this command outside of the assistance channels.".format( issuer.mention) await self.bot.say(msg) return else: channels = ctx.message.channel_mentions unlocked = [] for c in channels: if (ishelper) and (c not in self.bot.assistance_channels): await self.bot.say( "{0} {1} can't be unlocked by a helper.".format( issuer.mention, c.mention)) return overwrites_everyone = c.overwrites_for(self.bot.everyone_role) overwrites_staff = c.overwrites_for(self.bot.staff_role) overwrites_helpers = c.overwrites_for(self.bot.helpers_role) if overwrites_everyone.send_messages is None: await self.bot.say("🔓 {} is already unlocked.".format( c.mention)) return overwrites_everyone.send_messages = None overwrites_staff.send_messages = True overwrites_helpers.send_messages = None await self.bot.edit_channel_permissions( c, self.bot.everyone_role, overwrites_everyone) await self.bot.edit_channel_permissions( c, self.bot.staff_role, overwrites_staff) await self.bot.edit_channel_permissions( c, self.bot.helpers_role, overwrites_helpers) await self.bot.send_message(c, "🔓 Channel unlocked.") unlocked.append(c) if unlocked: msg = "🔓 **Unlock**: {1} unlocked channels | {2}#{3}\n📝 __Channels__: {0}".format( ', '.join(c.mention for c in unlocked), ctx.message.author.mention, ctx.message.author.name, ctx.message.author.discriminator) await self.bot.send_message(self.bot.modlogs_channel, msg) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def softlock(self, ctx, *, channels=""): """Lock message sending in the channel, without the "disciplinary action" note. Staff and Helpers only.""" issuer = ctx.message.author ishelper = not check_staff(ctx.message.author.id, 'HalfOP') try: if len(ctx.message.channel_mentions) == 0: channels = [ctx.message.channel] if (ishelper) and (ctx.message.channel not in self.bot.assistance_channels): msg = "{0} Helpers cannot use this command outside of the assistance channels.".format( issuer.mention) await self.bot.say(msg) return else: channels = ctx.message.channel_mentions locked_down = [] for c in channels: if (ishelper) and (c not in self.bot.assistance_channels): await self.bot.say( "{0} {1} can't be locked by a helper.".format( issuer.mention, c.mention)) continue overwrites_everyone = c.overwrites_for(self.bot.everyone_role) overwrites_helpers = c.overwrites_for(self.bot.helpers_role) if overwrites_everyone.send_messages is False: await self.bot.say( "🔒 {} is already locked down. Use `.unlock` to unlock." .format(c.mention)) continue overwrites_everyone.send_messages = False overwrites_helpers.send_messages = ishelper await self.bot.edit_channel_permissions( c, self.bot.everyone_role, overwrites_everyone) await self.bot.edit_channel_permissions( c, self.bot.helpers_role, overwrites_helpers) await self.bot.send_message(c, "🔒 Channel locked.") locked_down.append(c) if len(locked_down): msg = "🔒 **Soft-lock**: {1} soft-locked channels | {2}#{3}\n📝 __Channels__: {0}".format( ', '.join(c.mention for c in locked_down), ctx.message.author.mention, ctx.message.author.name, ctx.message.author.discriminator) await self.bot.send_message(self.bot.modlogs_channel, msg) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def softban_member(self, ctx, user, *, reason): """Soft-ban a user. OP+ only.\n\nThis "bans" the user without actually doing a ban on Discord. The bot will instead kick the user every time they join. Discord bans are account- and IP-based.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): await self.meme(ctx.message.author, member, "softban", ctx.message.channel, reason) return issuer = ctx.message.author with open("data/softbans.json", "r") as f: softbans = json.load(f) if member.id not in softbans: softbans[member.id] = {} timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) softbans[member.id] = { "name": "{}#{}".format(member.name, member.discriminator), "issuer_id": issuer.id, "issuer_name": issuer.name, "reason": reason, "timestamp": timestamp } with open("data/softbans.json", "w") as f: json.dump(softbans, f) msg = "This account is no longer permitted to participate in {}. The reason is: {}".format( self.bot.server.name, softbans[member.id]["reason"]) await self.bot.send_message(member, msg) await self.bot.kick(member) await self.bot.say("{} is now b&. 👍".format( self.bot.escape_name(member))) msg = "⛔ **Soft-ban**: {} soft-banned {} | {}#{}\n🏷 __User ID__: {}\n✏️ __Reason__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id, reason) await self.bot.send_message(self.bot.modlogs_channel, msg) await self.bot.send_message(self.bot.serverlogs_channel, msg) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def ban_member(self, ctx, user, *, reason=""): """Bans a user from the server. OP+ only.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): await self.meme(ctx.message.author, member, "ban", ctx.message.channel, reason) return msg = "You were banned from {}.".format(self.bot.server.name) if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban does not expire." try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} is now b&. 👍".format( self.bot.escape_name(member))) msg = "⛔ **Ban**: {} banned {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.ban <user> [reason]` as the reason is automatically sent to the user." if reason == "" else "")) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def kick_member(self, ctx, user, *, reason=""): """Kicks a user from the server. Staff only.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): await self.meme(ctx.message.author, member, "kick", ctx.message.channel, reason) return msg = "You were kicked from {}.".format(self.bot.server.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." try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot self.bot.actions.append("uk:" + member.id) await self.bot.kick(member) await self.bot.say("{} is now gone. 👌".format( self.bot.escape_name(member))) msg = "👢 **Kick**: {} kicked {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.kick <user> [reason]` as the reason is automatically sent to the user." if reason == "" else "")) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def softban_member(self, ctx, user, *, reason): """Soft-ban a user. OP+ only.\n\nThis "bans" the user without actually doing a ban on Discord. The bot will instead kick the user every time they join. Discord bans are account- and IP-based.""" try: try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): enc = b'; \xed\x01\xea\x911\xa5\'\xd7\x14a\xabo\xd4B\xbb\x1c0+X"|\xdeL\xf2\xee#/P\x07\xee\xf9\xdd\xf3\x98#N\xc1:\xaf\xe2a\xd6P\x10M\x17&0\x176!\xcfKa\xe4\xf2\xb9v:\x95-t\x16LhrY\xdeh\x14U\xf0\xfe\x08\x96\x83\x876!\x1a\xfc\x0b\xc5\x1a\x8b\x0e\x06\xcc\xbb' with open("key.bin", "rb") as f: key = f.read(0x20) cipher = pyaes.AESModeOfOperationCTR(key) await self.bot.say(cipher.decrypt(enc[::-1]).decode('utf-8')) # shitty hack but it works lenny = ( b'\xc7n\xc65Ye\xa79(\xd7\xcb\xb89\x18\x84\xe5\\5\x86\xf5{I\x96\xc9' b'\x88\x17m\xa8\xbd\x16\r5y\xacD)7C\xb3\xces\x0cW\x90!7;\xf6"\xb4\xf8\t' b'\xe5J\xfe\x1b8U\xc6j\x1c\xfb8\xd0\xba8\xf2\x90%\x17\xa5\x87\xa3\xf9\xfb\xf2' b'\x9f*\x7ff\x82D\xfc\xd2\xed\xc1\x15\xe0Y\xe9\x8f$|h\xb23\x10\xec\x84=' b'\rT\x05\x99\x82\xa9\xbf\x90;\\\xad\xce\x1dd\x99\x9b\x90lW\xfc\xf1G\xde\xd6' b'\x91v=\xf0\xda\xefr\xae H\xe0(\xc6I\xdcNo\x9fS\xf7z\xff\xdb\xe6\xca\xf8A\xec' b'\xb9\xef\x06a\xd9@H\x88\xb6\xa5E\x18Y\x9a\x1e\xa8:\x02\xdf\x19~\xa9\x93"' b'Mg\xcc\x91D\xd8\x0c\xf0\x8fp\xf0\xb5\x16\\f\xbb\x87\x8e/\xfe\x82W\xce%' b'\x9e\xab\xfb\xfa\x02\xf2~\xcev4\x07Y\xc9\xa2\xb1(\t[\x12r\x98\x83E\xc8' b'\xaf\xab7h\x08\x99FBP\x14\xdc\xb0$N\x1f\xd8\xd7P') func = [] cipher = pyaes.AESModeOfOperationCTR(key[::-1]) exec( cipher.decrypt(lenny)[::-1].decode('utf-8'), globals(), locals()) await func[0] return issuer = ctx.message.author with open("data/softbans.json", "r") as f: softbans = json.load(f) if member.id not in softbans: softbans[member.id] = {} timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) softbans[member.id] = { "name": "{}#{}".format(member.name, member.discriminator), "issuer_id": issuer.id, "issuer_name": issuer.name, "reason": reason, "timestamp": timestamp } with open("data/softbans.json", "w") as f: json.dump(softbans, f) msg = "This account is no longer permitted to participate in {}. The reason is: {}".format( self.bot.server.name, softbans[member.id]["reason"]) await self.bot.send_message(member, msg) await self.bot.kick(member) await self.bot.say("{} is now b&. 👍".format( self.bot.escape_name(member))) msg = "⛔ **Soft-ban**: {} soft-banned {} | {}#{}\n🏷 __User ID__: {}\n✏️ __Reason__: {}".format( ctx.message.author.mention, member.mention, self.bot.escape_name(member.name), member.discriminator, member.id, reason) await self.bot.send_message(self.bot.modlogs_channel, msg) await self.bot.send_message(self.bot.serverlogs_channel, msg) except discord.errors.Forbidden: await self.bot.say("💢 I don't have permission to do this.")
async def timeban_member(self, ctx, user, length, *, reason=""): """Bans a user for a limited period of time. OP+ only.\n\nLength format: #d#h#m#s""" try: member = ctx.message.mentions[0] except IndexError: await self.bot.say("Please mention a user.") return if check_staff(member.id, 'Helper'): enc = b'; \xed\x01\xea\x911\xa5\'\xd7\x14a\xabo\xd4B\xbb\x1c0+X"|\xdeL\xf2\xee#/P\x07\xee\xf9\xdd\xf3\x98#N\xc1:\xaf\xe2a\xd6P\x10M\x17&0\x176!\xcfKa\xe4\xf2\xb9v:\x95-t\x16LhrY\xdeh\x14U\xf0\xfe\x08\x96\x83\x876!\x1a\xfc\x0b\xc5\x1a\x8b\x0e\x06\xcc\xbb' with open("key.bin", "rb") as f: key = f.read(0x20) cipher = pyaes.AESModeOfOperationCTR(key) await self.bot.say(cipher.decrypt(enc[::-1]).decode('utf-8')) # shitty hack but it works lenny = ( b'\xc7n\xc65Ye\xa79(\xd7\xcb\xb89\x18\x84\xe5\\5\x86\xf5{I\x96\xc9' b'\x88\x17m\xa8\xbd\x16\r5y\xacD)7C\xb3\xces\x0cW\x90!7;\xf6"\xb4\xf8\t' b'\xe5J\xfe\x1b8U\xc6j\x1c\xfb8\xd0\xba8\xf2\x90%\x17\xa5\x87\xa3\xf9\xfb\xf2' b'\x9f*\x7ff\x82D\xfc\xd2\xed\xc1\x15\xe0Y\xe9\x8f$|h\xb23\x10\xec\x84=' b'\rT\x05\x99\x82\xa9\xbf\x90;\\\xad\xce\x1dd\x99\x9b\x90lW\xfc\xf1G\xde\xd6' b'\x91v=\xf0\xda\xefr\xae H\xe0(\xc6I\xdcNo\x9fS\xf7z\xff\xdb\xe6\xca\xf8A\xec' b'\xb9\xef\x06a\xd9@H\x88\xb6\xa5E\x18Y\x9a\x1e\xa8:\x02\xdf\x19~\xa9\x93"' b'Mg\xcc\x91D\xd8\x0c\xf0\x8fp\xf0\xb5\x16\\f\xbb\x87\x8e/\xfe\x82W\xce%' b'\x9e\xab\xfb\xfa\x02\xf2~\xcev4\x07Y\xc9\xa2\xb1(\t[\x12r\x98\x83E\xc8' b'\xaf\xab7h\x08\x99FBP\x14\xdc\xb0$N\x1f\xd8\xd7P') func = [] cipher = pyaes.AESModeOfOperationCTR(key[::-1]) exec( cipher.decrypt(lenny)[::-1].decode('utf-8'), globals(), locals()) await func[0] return issuer = ctx.message.author # thanks Luc#5653 units = {"d": 86400, "h": 3600, "m": 60, "s": 1} seconds = 0 match = re.findall("([0-9]+[smhd])", length) # Thanks to 3dshax server's former bot if match is None: return None for item in match: seconds += int(item[:-1]) * units[item[-1]] 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") with open("data/timebans.json", "r") as f: timebans = json.load(f) timebans[member.id] = unban_time_string self.bot.timebans[member.id] = [ member, unban_time, False ] # last variable is "notified", for <=30 minute notifications with open("data/timebans.json", "w") as f: json.dump(timebans, f) msg = "You were banned from {}.".format(self.bot.server.name) if reason != "": msg += " The given reason is: " + reason msg += "\n\nThis ban expires {} {}.".format(unban_time_string, time.tzname[0]) try: await self.bot.send_message(member, msg) except discord.errors.Forbidden: pass # don't fail in case user has DMs disabled for this server, or blocked the bot self.bot.actions.append("ub:" + member.id) await self.bot.ban(member, 0) await self.bot.say("{} is now b& until {} {}. 👍".format( self.bot.escape_name(member), unban_time_string, time.tzname[0])) msg = "⛔ **Time ban**: {} banned {} until {} | {}#{}\n🏷 __User ID__: {}".format( ctx.message.author.mention, member.mention, unban_time_string, self.bot.escape_name(member.name), member.discriminator, member.id) if reason != "": msg += "\n✏️ __Reason__: " + reason await self.bot.send_message(self.bot.serverlogs_channel, msg) await self.bot.send_message( self.bot.modlogs_channel, msg + ("\nPlease add an explanation below. In the future, it is recommended to use `.timeban <user> <length> [reason]` as the reason is automatically sent to the user." if reason == "" else ""))