import asyncio import functools from sys import argv import discord from discord.ext import commands import PICable if len(argv) != 3: print("Usage:\n\t" + argv[0] + " ") exit(1) discord_token = argv[1] github_token = argv[2] intents = discord.Intents.default() intents.message_content = True client = commands.Bot(command_prefix="/", intents=intents) async def reply_message_async(interaction: discord.Interaction, owner: str, repo: str): 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 @client.event async def on_ready(): print(f"We have logged in as {client.user}") await client.change_presence(activity=discord.Game("with PIC ideas")) try: synced = await client.tree.sync() print(f"Synced {len(synced)} command(s)") except Exception as e: print(f"Failed to sync commands: {e}") @client.tree.command(name="picable", description="Check if a Github repository is eligible for PIC") @discord.app_commands.describe(owner="The owner of the repository", repository="The name of the repository") async def picable(interaction: discord.Interaction, owner: str, repository: str): await interaction.response.defer(ephemeral=False, thinking=True) asyncio.create_task(reply_message_async(interaction, owner, repository)) client.run(discord_token)