Update app.py
Browse files
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
|
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 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
83 |
|
84 |
-
#
|
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")
|