@commands.Cog.listener() async def on_raw_reaction_add(self, payload): data = await self.bot.get_data(payload.guild_id) # Accessing data from main table starboard = self.bot.get_channel(data[27]) # Pulling the starboard ID from main tbale and making it a channel object stars = await self.bot.get_star(payload.message_id) # Accessing from the starboard table star_reactions = ["⭐", ":questionable_star:", ":star_struck:", ":star2:", ":StarPiece:", ":purple_star:"] # Listing the approved reactions to watch for reactions_count = 0 # Inilizing a reaction count for star in star_reactions: # Checking each option in the approved reactions if payload.emoji.name == star: # Checking if the reaction used is in the approved list stared_message = await self.bot.get_channel(payload.channel_id).fetch_message(payload.message_id) # Getting the the original msg as a message object if not stared_message.author.bot and payload.member.id != stared_message.author.id: # Checking the person adding the reaction isn't a bot and/or that they aren't the person who sent the orginal message. # Declaring the Embed to post in the starboard channel embed = discord.Embed(title = f"Starred message", description = f"{stared_message.content}" or "See attachment", colour = stared_message.author.colour, url = stared_message.jump_url, timestamp = datetime.datetime.utcnow()) embed.set_author(name = stared_message.author, icon_url = stared_message.author.avatar_url) if len(stared_message.attachments): # Checking if the orignal message contained a image embed.set_image(url = stared_message.attachments[0].url) # Add the orginal msgs image to the embed if stared_message.id != stars[0]: # Checking if the orignal message ID is NOT stored in the db reaction_count += stared_message.reactions.count # Adding the count of the star reactions to the count embed.set_footer(text = f"Stars: {str(reaction_count)}") post = await starboard.send(embed = embed) # Sending the embed to the starboard async with self.bot.pool.acquire() as conn: await conn.execute("UPDATE starboard SET stars=$1 WHERE id=$2", reaction_count, payload.message_id) await conn.execute("UPDATE starboard SET post=$1 WHERE id=$2", post.id, payload.message_id) else: star_count = stars[1] + 1 post = await self.bot.get_channel(starboard.id).fetch_message(stars[2]) # Getting the the post msg as a message object await post.edit(embed = embed.set_footer(text = f"Stars: {str(star_count)})) async with self.bot.pool.acquire() as conn: await conn.execute("UPDATE starboard SET stars=$1 WHERE id=$2", star_count, payload.message_id) else: await stared_message.remove_reaction(payload.emoji, payload.member)