Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @commands.command(pass_context=True, name="softlock")
- 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 = None
- if (self.bot.helpers_role not in issuer.roles) and (self.bot.staff_role not in issuer.roles):
- msg = "{0} This command is limited to Staff and Helpers.".format(issuer.mention)
- await self.bot.say(msg)
- return
- if (self.bot.staff_role not in issuer.roles):
- ishelper = True
- 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
- if (ishelper) and (channels not in self.bot.assistance_channels):
- msg = "{0} Helpers cannot use this command to lock other channels.".format(issuer.mention)
- await self.bot.say(msg)
- return
- locked_down = []
- for c in channels:
- overwrites_everyone = c.overwrites_for(self.bot.everyone_role)
- overwrites_helpers = c.overwrites_for(self.bot.everyone_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)
- 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.")
- @commands.command(pass_context=True, name="unlock")
- async def unlock(self, ctx, *, channels=""):
- """Unlock message sending in the channel. Staff only and Helpers only."""
- issuer = ctx.message.author
- if (self.bot.helpers_role not in issuer.roles) and (self.bot.staff_role not in issuer.roles):
- msg = "{0} This command is limited to Staff and Helpers.".format(issuer.mention)
- await self.bot.say(msg)
- return
- try:
- if len(ctx.message.channel_mentions) == 0:
- channels = [ctx.message.channel]
- if (self.bot.staff_role not in issuer.roles) 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
- if (self.bot.staff_role not in issuer.roles) and (channels not in self.bot.assistance_channels):
- msg = "{0} Helpers cannot use this command to unlock other channels.".format(issuer.mention)
- await self.bot.say(msg)
- return
- unlocked = []
- for c in channels:
- 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)
- 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.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement