add thread to handle picable
This commit is contained in:
10
main.py
10
main.py
@@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import functools
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@@ -18,7 +19,13 @@ client = commands.Bot(command_prefix="/", intents=intents)
|
|||||||
|
|
||||||
|
|
||||||
async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str):
|
async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str):
|
||||||
await interaction.followup.send(PICable.PICable(owner, repo, github_token))
|
try:
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
|
result = await loop.run_in_executor(None, functools.partial(PICable.PICable, owner, repo, github_token))
|
||||||
|
await interaction.followup.send(result)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error processing PICable check: {e}")
|
||||||
|
await interaction.followup.send("An error occurred while processing your request. Please try again later.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +45,5 @@ async def on_ready():
|
|||||||
async def picable(interaction: discord.Interaction, owner: str, repository: str):
|
async def picable(interaction: discord.Interaction, owner: str, repository: str):
|
||||||
await interaction.response.defer(ephemeral=False, thinking=True)
|
await interaction.response.defer(ephemeral=False, thinking=True)
|
||||||
asyncio.create_task(reply_message_async(interaction, owner, repository))
|
asyncio.create_task(reply_message_async(interaction, owner, repository))
|
||||||
|
|
||||||
|
|
||||||
client.run(discord_token)
|
client.run(discord_token)
|
||||||
|
|||||||
Reference in New Issue
Block a user