1
0

angels.py 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import discord
  2. from discord.ext import commands
  3. async def setup(bot: commands.Bot):
  4. await bot.add_cog(AngelEvents(bot))
  5. class AngelEvents(commands.Cog):
  6. """A couple Angel specific commands."""
  7. def __init__(self, bot: commands.Bot):
  8. self.bot = bot
  9. @commands.Cog.listener()
  10. async def on_message(self, message: discord.Message):
  11. feed_channels = [1184948763614253187]
  12. if message.channel.id in feed_channels:
  13. news_channel = self.bot.get_channel(971796738484625468)
  14. if message.type == discord.MessageType.channel_follow_add:
  15. source_channel = self.bot.get_channel(message.reference.channel_id)
  16. if source_channel:
  17. source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.")
  18. await news_channel.send(f"{message.author.mention} [{message.system_content.partition()[2]}]({source_invite})")
  19. else:
  20. await news_channel.send(f"{message.author.mention} {message.system_content.partition(' ')[2]}")
  21. else:
  22. if message.author.bot:
  23. source_channel = self.bot.get_channel(message.reference.channel_id)
  24. if source_channel:
  25. source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.")
  26. msg = await news_channel.send(f"**[{message.author.name}](<{source_invite.url}>)**:\n\n{message.clean_content}")
  27. else:
  28. await news_channel.send("**" + message.author.name + "**:\n\n" + message.clean_content)