Guest User

Untitled

a guest
May 28th, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. @commands.has_any_role("Book Club Captain", "Owner", "Developer")
  2. async def create_new_book_thread(self, inter, book_title: str, book_author: str,
  3.                                     tag: str, *, book_description: str):
  4.    
  5.     await inter.response.defer(ephemeral=True)
  6.  
  7.     forum_channel = inter.guild.get_channel(1108149493104377948)
  8.     forum_tags = [tag for tag in forum_channel.available_tags]
  9.  
  10.     for t in forum_tags:
  11.         if t.name == tag:
  12.             tag_to_apply = t
  13.  
  14.     new_thread = await forum_channel.create_thread(
  15.         name = f"{book_title} - {book_author}",
  16.         applied_tags = [tag_to_apply,],
  17.         content = book_description
  18.     )
  19.  
  20.     jump_thread = inter.guild.get_thread(new_thread)
  21.  
  22.     return await inter.edit_original_message(f"{inter.author.mention} Your New Book Thread Has Been Created. {jump_thread.jump_url}")
  23.  
  24. @create_new_book_thread.autocomplete("tag")
  25. async def create_new_book_thread_autocomplete(self,inter,string):
  26.     forum_tags = [tag.name for tag in inter.guild.get_channel(1108149493104377948).available_tags]
  27.     return [i for i in forum_tags if string.lower() in i.lower()]
Advertisement
Add Comment
Please, Sign In to add comment