Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hikari
- import lightbulb
- import hikari.components
- playertimeasker = lightbulb.Plugin("PlayerTimePlugin")
- user_preferences = {}
- @playertimeasker.command
- @lightbulb.command("playertime", "Determine the time based on region")
- @lightbulb.implements(lightbulb.SlashCommand)
- async def playertime(ctx: lightbulb.SlashContext) -> None:
- select_menu = (
- ctx.bot.rest.build_message_action_row()
- .add_text_menu("region_select")
- .add_option("North America", "North America")
- .add_option("Europe", "Europe")
- .add_option("Middle East", "Middle East")
- .add_option("Asia", "Asia")
- .add_option("Africa", "Africa")
- .add_option("South America", "South America")
- .add_option("Australia", "Australia")
- .parent
- )
- await ctx.respond(
- "In which region/continent are you located?",
- component = select_menu
- )
- @playertimeasker.listener(hikari.InteractionCreateEvent)
- async def on_interaction_create(event: hikari.InteractionCreateEvent) -> None:
- if not isinstance(event.interaction, hikari.ComponentInteraction):
- return
- if event.interaction.custom_id == "region_select":
- region = event.interaction.values[0]
- user_id = event.interaction.user.id
- user_preferences[user_id] = region
- await event.interaction.create_initial_response(
- hikari.ResponseType.MESSAGE_CREATE,
- f"Your region is set to {region}."
- )
- if region == "North America": # help
- def load(bot: lightbulb.BotApp) -> None:
- bot.add_plugin(playertimeasker)
Advertisement
Add Comment
Please, Sign In to add comment