Beispiel #1
0
 async def mute(self, ctx, *args):
     toMute = myself.getUser(ctx, args, allownoargs=False)
     if not ctx.author.guild_permissions.manage_messages: return await ctx.send('{} | No `manage messages` permission!'.format(self.client.get_emoji(BotEmotes.error)))
     role = Dashboard.getMuteRole(ctx.guild.id)
     if role==None:
         await ctx.send('{} | Please wait... Setting up...\nThis may take a while if your server has a lot of channels.'.format(str(self.client.get_emoji(BotEmotes.loading))))
         role = await ctx.guild.create_role(name='Muted', color=discord.Colour.from_rgb(0, 0, 1))
         ratelimit_counter = 0
         # BEWARE API ABUSE! ADDED SOME STUFF TO REDUCE RATELIMITS
         for i in ctx.guild.channels:
             if ratelimit_counter > 10: # take a break for a while
                 await asyncio.sleep(2)
                 ratelimit_counter = 0 ; continue
             if str(i.type)=='text':
                 await i.set_permissions(role, send_messages=False)
                 ratelimit_counter += 1
             elif str(i.type)=='voice':
                 await i.set_permissions(role, connect=False)
                 ratelimit_counter += 1
         Dashboard.editMuteRole(ctx.guild.id, role.id)
         role = role.id
     role = ctx.guild.get_role(role)
     try:
         await toMute.add_roles(role)
         await ctx.send('{} | Muted. Ductaped {}\'s mouth.'.format(str(self.client.get_emoji(BotEmotes.success)), toMute.name))
     except Exception as e:
         print(e)
         await ctx.send('{} | I cannot mute him... maybe i has less permissions than him.\nHis mouth is too powerful.'.format(str(self.client.get_emoji(BotEmotes.error))))
Beispiel #2
0
async def on_guild_role_delete(role):
    muterole = Dashboard.getMuteRole(role.guild.id)
    if muterole == None: return
    if muterole != role.id: return
    Dashboard.editMuteRole(role.guild.id, None)