Exemplo n.º 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))))
Exemplo n.º 2
0
async def on_guild_channel_create(channel):
    if str(channel.type) not in ['text', 'voice']: return
    data = Dashboard.getMuteRole(channel.guild.id)
    if data == None: return
    if str(channel.type) == 'text':
        return await channel.set_permissions(channel.guild.get_role(data),
                                             send_messages=False)
    await channel.set_permissions(channel.guild.get_role(data), connect=False)
Exemplo n.º 3
0
 async def unmute(self, ctx):
     toUnmute = myself.getUser(ctx, args, allownoargs=False)
     roleid = Dashboard.getMuteRole(ctx.guild.id)
     if roleid==None: return await ctx.send('{} | He is not muted!\nOr maybe you muted this on other bot... which is not compatible.'.format(self.client.get_emoji(BotEmote.error)))
     elif roleid not in [i.id for i in ctx.message.mentions[0].roles]:
         return await ctx.send('{} | That guy is not muted.'.format(self.client.get_emoji(BotEmotes.error)))
     try:
         await toUnmute.remove_roles(ctx.guild.get_role(roleid))
         await ctx.send('{} | {} unmuted.'.format(self.client.get_emoji(BotEmotes.success), toUnmute.name))
     except:
         await ctx.send('{} | I cannot unmute {}!'.format(self.client.get_emoji(BotEmotes.error), ctx.message.mentions[0].name))
Exemplo n.º 4
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)