async def starboard(self, ctx, *args): wait = await ctx.send('{} | Please wait...'.format( str(self.client.get_emoji(BotEmotes.error)) )) if not ctx.author.guild_permissions.manage_channels: return await wait.edit(content='{} | You need the `Manage channels` permission.'.format( str(self.client.get_emoji(BotEmotes.error)) )) starboard_channel = Dashboard.getStarboardChannel(ctx.guild) if len(list(args))==0: if starboard_channel['channelid']==None: channel = await ctx.guild.create_text_channel(name='starboard', topic='Server starboard channel. Every funny/cool posts will be here.') Dashboard.addStarboardChannel(channel, 1) return await wait.edit(content=f'{str(self.client.get_emoji(BotEmotes.success))} | OK. Created a channel <#{str(channel.id)}>. Every starboard will be set there.\nTo remove starboard, type `{Config.prefix}starboard remove`.\nBy default, starboard requirements are set to 1 reaction. To increase, type `{Config.prefix}starboard limit <number>`.') return await wait.edit(content='', embed=discord.Embed( title=f'Starboard for {ctx.guild.name}', description='Channel: <#{}>\nStars required to reach: {}'.format( starboard_channel['channelid'], starboard_channel['starlimit'] ), color=discord.Colour.from_rgb(201, 160, 112) )) if starboard_channel['channelid']==None: return elif list(args)[0].lower().startswith('rem'): Dashboard.removeStarboardChannel(ctx.guild) return await wait.edit(content='{} | OK. Starboard for this server is deleted.'.format(str(self.client.get_emoji(BotEmotes.success)))) elif list(args)[0].lower()=='limit': try: num = int(list(args)[1]) if not num in range(1, 20): return await wait.edit(content='{} | Invalid number.'.format(str(self.client.get_emoji(BotEmotes.error)))) Dashboard.setStarboardLimit(num, ctx.guild) await wait.edit(content='{} | Set the limit to {} reactions.'.format(str(self.client.get_emoji(BotEmotes.success)), str(num))) except: await wait.edit(content='{} | Invalid number.'.format(str(self.client.get_emoji(BotEmotes.error))))
async def on_raw_reaction_add(payload): # IF IS NOT STAR EMOJI, IGNORE if str(payload.emoji) != 'тнР': return data = Dashboard.getStarboardChannel(None, guildid=payload.guild_id) if data == None: return try: messages = await client.get_channel(data['channelid'] ).history().flatten() starboards = [ int(str(message.content).split(': ')[1]) for message in messages if message.author.id == Config.id ] if payload.message_id in starboards: return except: return message = await client.get_channel(payload.channel_id ).fetch_message(payload.message_id) if len(message.reactions) == data['starlimit']: await client.get_channel(data['channelid']).send( content=f'ID: {message.id}', embed=Dashboard.sendStarboard(discord, message))