CryptoScoutv1 commited on
Commit
5e5b5e0
·
verified ·
1 Parent(s): ddcf3b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -12
app.py CHANGED
@@ -11,7 +11,8 @@ from discord.ext import commands
11
  from discord.utils import oauth_url
12
  import gradio_client as grc
13
  from gradio_client.utils import QueueError
14
- from discord_slash.model import SlashCommandOptionType as Option
 
15
 
16
  event = Event()
17
 
@@ -39,6 +40,20 @@ intents = discord.Intents.default()
39
  intents.message_content = True
40
  bot = commands.Bot(command_prefix="/", intents=intents)
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  ## BOT COMMANDS ##
44
 
@@ -58,17 +73,13 @@ async def on_ready():
58
 
59
 
60
  @bot.hybrid_command(name="cryptoportfolio", description="Select a predefined sentence")
61
- async def crypto_portfolio(ctx,
62
- selection: Option(str,
63
- "Select an option",
64
- choices=[
65
- "Find the top performing cryptocurrencies of the day.",
66
- "Find the top performing cryptocurrencies of the week.",
67
- "Find the top performing cryptocurrencies of the month."
68
- ])):
69
- try:
70
- # Acknowledge the command
71
- await ctx.send(f"Processing request: {selection}")
72
 
73
  # Simulated external processing
74
  loop = asyncio.get_running_loop()
 
11
  from discord.utils import oauth_url
12
  import gradio_client as grc
13
  from gradio_client.utils import QueueError
14
+ from discord.ui import Select, View
15
+
16
 
17
  event = Event()
18
 
 
40
  intents.message_content = True
41
  bot = commands.Bot(command_prefix="/", intents=intents)
42
 
43
+ class CryptoSelect(Select):
44
+ def __init__(self):
45
+ options = [
46
+ discord.SelectOption(label="Top performing cryptocurrencies of the day", value="day"),
47
+ discord.SelectOption(label="Top performing cryptocurrencies of the week", value="week"),
48
+ discord.SelectOption(label="Top performing cryptocurrencies of the month", value="month"),
49
+ ]
50
+ super().__init__(placeholder="Select an option", min_values=1, max_values=1, options=options)
51
+
52
+ async def callback(self, interaction: discord.Interaction):
53
+ selection = self.values[0] # The selected option's value
54
+ # Place your existing code for handling the selection here
55
+ # For example:
56
+ await interaction.response.send_message(f"You selected: {selection}")
57
 
58
  ## BOT COMMANDS ##
59
 
 
73
 
74
 
75
  @bot.hybrid_command(name="cryptoportfolio", description="Select a predefined sentence")
76
+ async def crypto_portfolio(ctx):
77
+ # Create a view and add our select menu to it
78
+ view = View()
79
+ view.add_item(CryptoSelect())
80
+
81
+ # Send a message with the view
82
+ await ctx.send("Please select an option:", view=view)
 
 
 
 
83
 
84
  # Simulated external processing
85
  loop = asyncio.get_running_loop()