minor things

This commit is contained in:
Xory 2025-08-21 19:22:16 +03:00
parent 9fea33e619
commit 70612cb353
3 changed files with 48 additions and 2 deletions

29
main.py
View file

@ -66,7 +66,7 @@ async def generation(interaction: discord.Interaction) -> None:
@bot.tree.command(name="ask", description="ai thing yes 👍")
@app_commands.allowed_installs(guilds=False, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def ask(interaction: discord.Interaction, prompt: str, attachment: Optional[discord.Attachment], ephemeral: bool) -> None:
async def ask(interaction: discord.Interaction, prompt: str, attachment: Optional[discord.Attachment], ephemeral: Optional[bool]) -> None:
if not ephemeral:
await interaction.response.defer()
else:
@ -134,6 +134,33 @@ async def ask(interaction: discord.Interaction, prompt: str, attachment: Optiona
await interaction.edit_original_response(content=generation)
@bot.tree.command(name="genimage", description="ai image gen woooo")
@app_commands.allowed_installs(guilds=False, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def gen_image(interaction: discord.Interaction, prompt: str) -> None:
await interaction.response.defer()
response: types.GenerateImagesResponse | None
for _ in range(5):
try:
response = await client.models.generate_images(
model="imagen-4.0-generate-001",
prompt=prompt,
config=types.GenerateImagesConfig(
number_of_images=1,
)
)
except:
print_exc()
await asyncio.sleep(10)
continue
if not response:
await interaction.edit_original_response(content="`[E] API error. Please try again later.`")
await interaction.edit_original_response(content="Done", attachments=response.generated_images)
@bot.tree.command(name="sync", description="bot.tree.sync()")
@app_commands.allowed_installs(guilds=False, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)