Guest User

Untitled

a guest
May 28th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import disnake
  2.  
  3. from disnake.ext import commands
  4.  
  5. class BookCreationEvents(commands.Cog):
  6.     def __init__(self,bot):
  7.         self.bot = bot
  8.  
  9.     @commands.Cog.listener()
  10.     async def on_thread_create(self,thread):
  11.         # if the new thread does not belong to the open_books forum, pass
  12.         if thread.category.name != "Book Club":
  13.             pass
  14.        
  15.         announce_channel = thread.guild.get_channel(1112533230483148882)
  16.  
  17.         embed = disnake.Embed(
  18.             color = disnake.Colour.random(),
  19.             title = "A New Book Has Been Created!",
  20.             description = f"Click Here To View This Thread {thread.jump_url}"
  21.         ).add_field(
  22.             name = "Book Name",
  23.             value = thread.name,
  24.             inline = False
  25.         ).add_field(
  26.             name = "Book Details",
  27.             value = thread.starter_message,
  28.             inline = False
  29.         ).add_field(
  30.             name = "Book Genre",
  31.             value = [tag.name for tag in thread.applied_tags]
  32.         )
  33.  
  34.         return await announce_channel.send_message("@here A New Book Thread Has Been Started.", embed=embed)
  35.    
  36. def setup(bot):
  37.     bot.add_cog(BookCreationEvents(bot))
Add Comment
Please, Sign In to add comment