import discord from discord.ext import commands async def setup(bot: commands.Bot): await bot.add_cog(AngelEvents(bot)) class AngelEvents(commands.Cog): """A couple of simple commands.""" def __init__(self, bot: commands.Bot): self.bot = bot @commands.Cog.listener() async def on_message(self, message: discord.Message): feed_channels = [1184948763614253187, 1185045883985858610] if message.channel.id in feed_channels: news_channel = self.bot.get_channel(1002655345795158077) if message.type == discord.MessageType.channel_follow_add: source_channel = self.bot.get_channel(message.reference.channel_id) if source_channel: source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.") await news_channel.send(message.author.mention + " [" + message.system_content.partition()[2] + "](" + source_invite + ")") else: await news_channel.send(message.author.mention + " " + message.system_content.partition(" ")[2]) else: if message.author.bot: source_channel = self.bot.get_channel(message.reference.channel_id) if source_channel: source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.") msg = await news_channel.send("**[" + message.author.name + "](<" + source_invite.url + ">)**:\n\n" + message.clean_content) else: await news_channel.send("**" + message.author.name + "**:\n\n" + message.clean_content)