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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -26
app.py CHANGED
@@ -11,8 +11,7 @@ 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.ui import Select, View
15
-
16
 
17
  event = Event()
18
 
@@ -40,21 +39,6 @@ intents = discord.Intents.default()
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
 
60
  @bot.event
@@ -72,16 +56,19 @@ async def on_ready():
72
 
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()
86
  client = await loop.run_in_executor(None, get_client, None)
87
  job = client.submit(selection, api_name="/predict")
 
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
  intents.message_content = True
40
  bot = commands.Bot(command_prefix="/", intents=intents)
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ## BOT COMMANDS ##
43
 
44
  @bot.event
 
56
 
57
 
58
 
59
+ async def crypto_portfolio(ctx,
60
+ selection: Option(str,
61
+ "Select an option",
62
+ choices=[
63
+ "Find the top performing cryptocurrencies of the day.",
64
+ "Find the top performing cryptocurrencies of the week.",
65
+ "Find the top performing cryptocurrencies of the month."
66
+ ])):
67
+ try:
68
+ # Acknowledge the command
69
+ await ctx.send(f"Processing request: {selection}")
70
 
71
+ # Make sure this block is properly indented
72
  loop = asyncio.get_running_loop()
73
  client = await loop.run_in_executor(None, get_client, None)
74
  job = client.submit(selection, api_name="/predict")