Guest User

Untitled

a guest
May 12th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import hikari
  2. import lightbulb
  3. import hikari.components
  4.  
  5. playertimeasker = lightbulb.Plugin("PlayerTimePlugin")
  6.  
  7. user_preferences = {}
  8.  
  9. @playertimeasker.command
  10. @lightbulb.command("playertime", "Determine the time based on region")
  11. @lightbulb.implements(lightbulb.SlashCommand)
  12. async def playertime(ctx: lightbulb.SlashContext) -> None:
  13. select_menu = (
  14. ctx.bot.rest.build_message_action_row()
  15. .add_text_menu("region_select")
  16. .add_option("North America", "North America")
  17. .add_option("Europe", "Europe")
  18. .add_option("Middle East", "Middle East")
  19. .add_option("Asia", "Asia")
  20. .add_option("Africa", "Africa")
  21. .add_option("South America", "South America")
  22. .add_option("Australia", "Australia")
  23. .parent
  24. )
  25.  
  26. await ctx.respond(
  27. "In which region/continent are you located?",
  28. component = select_menu
  29. )
  30.  
  31. @playertimeasker.listener(hikari.InteractionCreateEvent)
  32. async def on_interaction_create(event: hikari.InteractionCreateEvent) -> None:
  33. if not isinstance(event.interaction, hikari.ComponentInteraction):
  34. return
  35.  
  36. if event.interaction.custom_id == "region_select":
  37. region = event.interaction.values[0]
  38.  
  39. user_id = event.interaction.user.id
  40. user_preferences[user_id] = region
  41.  
  42. await event.interaction.create_initial_response(
  43. hikari.ResponseType.MESSAGE_CREATE,
  44. f"Your region is set to {region}."
  45. )
  46.  
  47. if region == "North America": # help
  48.  
  49.  
  50.  
  51.  
  52. def load(bot: lightbulb.BotApp) -> None:
  53. bot.add_plugin(playertimeasker)
Advertisement
Add Comment
Please, Sign In to add comment