Skip to content

Commit

Permalink
import some code for embed/popup
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendaryAKx3 committed Nov 24, 2023
1 parent 4737e71 commit de56ba4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cogs/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,41 @@ async def ping(self, inter: Interaction) -> None:

def setup(bot: Bot) -> None:
bot.add_cog(Ticket(bot))

# TODO Fix Imported code for embed and popup form
import nextcord
from nextcord.ext import commands
from nextcord.ui import button, SelectMenu, SelectOption

bot = commands.Bot(command_prefix='!')

@bot.command()
async def embed_with_form(ctx):
# Create an embed message
embed = nextcord.Embed(
title='Embed with Form',
description='Click the button to open the form.',
color=0x3498db # You can customize the color as needed.
)

# Create a select menu with options
select_menu = SelectMenu(custom_id='form_menu', placeholder='Select an option')
select_menu.add_option(SelectOption(label='Option 1', value='option1'))
select_menu.add_option(SelectOption(label='Option 2', value='option2'))

# Create a view and add the select menu to it
view = nextcord.ui.View()
view.add_item(select_menu)

# Send the embed message with the select menu
message = await ctx.send(embed=embed, view=view)

@bot.event
async def on_select_option(interaction):
# Check if the select menu was interacted with in the correct context
if interaction.custom_id == 'form_menu':
selected_value = interaction.data['values'][0] # Get the selected value
await interaction.respond(content=f'You selected: {selected_value}')

# Start the bot
bot.run('YOUR_BOT_TOKEN')

0 comments on commit de56ba4

Please sign in to comment.