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))))
async def app(self, ctx, *args): src = myself.getUserAvatar(ctx, args, size=512) elem = myself.getUser(ctx, args) async with ctx.message.channel.typing(): await ctx.send(file=discord.File( self.canvas.app(src, elem.name), 'app.exe.png' ))
async def userinfo(self, ctx, *args): guy, ava = myself.getUser(ctx, args), myself.getUserAvatar(ctx, args) async with ctx.message.channel.typing(): bg_col = tuple(self.canvas.get_accent(ava)) data = self.canvas.usercard([{ 'name': i.name, 'color': i.color.to_rgb() } for i in guy.roles][::-1][0:5], guy, ava, bg_col) await ctx.send(file=discord.File(data, str(guy.discriminator)+'.png'))
async def palette(self, ctx, *args): url, person = myself.getUserAvatar(ctx, args), myself.getUser(ctx, args) async with ctx.message.channel.typing(): data = self.canvas.get_multiple_accents(url) file = discord.File(self.canvas.get_palette(data), 'palette.png') em = discord.Embed(title=f'{person.name}\'s avatar color palette', color=discord.Colour.from_rgb( data[0]['r'], data[0]['g'], data[0]['b'] )).set_thumbnail(url=url).set_image(url='attachment://palette.png') return await ctx.send(file=file, embed=em)
async def spotify(self, ctx, *args): source = myself.getUser(ctx, args) if str(source.activity).lower() != 'spotify': await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Nope, not listening to spotify.') else: async with ctx.message.channel.typing(): await ctx.send(file=discord.File( self.canvas.spotify(source, ctx.message), 'spotify.png'))
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))
async def bal(self, ctx, *args): wait = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + " | Please wait...") src, ava = myself.getUser(ctx, args), myself.getUserAvatar(ctx, args) if Economy.get(src.id) == None: raise myself.noProfile() else: img = self.canvas.profile( ava, src, Economy.getProfile( src.id, [i.id for i in ctx.guild.members if not i.bot])) await wait.delete() await ctx.send(file=discord.File(img, 'profile.png'))
async def joinposition(self, ctx, *args): current_time = t.now().timestamp() user = myself.getUser(ctx, args) wait = await ctx.send('{} | Iterating through {} members...'.format(self.client.get_emoji(BotEmotes.loading), len(ctx.guild.members))) sortedJoins = sorted([current_time-i.joined_at.timestamp() for i in ctx.guild.members])[::-1] num, users = [i for i in range(len(sortedJoins)) if (current_time-user.joined_at.timestamp())==sortedJoins[i]][0], [] for i in range(-10, 11): try: placement = (num + i) + 1 if placement < 1: continue locate = sortedJoins[num + i] username = [str(i) for i in ctx.guild.members if (current_time-i.joined_at.timestamp())==locate][0] if i == 0: username = f'**{username}**' users.append({ 'user': username, 'time': locate, 'order': str(placement) }) except IndexError: pass em = discord.Embed(title='Your join position', description='\n'.join([ '{}. {} ({} ago)'.format(i['order'], i['user'], myself.time_encode(round(i['time']))) for i in users ]), color=discord.Colour.from_rgb(201, 160, 112)) await wait.edit(content='', embed=em)
async def imgcaptcha(self, ctx, *args): async with ctx.message.channel.typing(): av, nm = myself.getUserAvatar(ctx, args), myself.getUser(ctx, args).name url = 'http://nekobot.xyz/api/imagegen?type=captcha&username='******'&url='+av+'&raw=1' data = self.canvas.urltoimage(url) await ctx.send(file=discord.File(data, 'your_captcha.png'))