mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
fix(tweety): only works with text no more images
also now works with other bot messages
This commit is contained in:
@@ -257,16 +257,6 @@ def tweety_command():
|
|||||||
try:
|
try:
|
||||||
original_message = await context.channel.fetch_message(context.message.reference.message_id)
|
original_message = await context.channel.fetch_message(context.message.reference.message_id)
|
||||||
|
|
||||||
if original_message.author.bot:
|
|
||||||
embed = discord.Embed(
|
|
||||||
title="Error",
|
|
||||||
description="Cannot convert bot messages to tweets!",
|
|
||||||
color=0xE02B2B,
|
|
||||||
)
|
|
||||||
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
|
||||||
await context.send(embed=embed)
|
|
||||||
return
|
|
||||||
|
|
||||||
processing_embed = discord.Embed(
|
processing_embed = discord.Embed(
|
||||||
title="Tweet Generator (Processing)",
|
title="Tweet Generator (Processing)",
|
||||||
description="<a:mariospin:1423677027013103709> Generating tweet... This may take a moment.",
|
description="<a:mariospin:1423677027013103709> Generating tweet... This may take a moment.",
|
||||||
@@ -291,31 +281,15 @@ def tweety_command():
|
|||||||
for channel in original_message.channel_mentions:
|
for channel in original_message.channel_mentions:
|
||||||
message_text = message_text.replace(f'<#{channel.id}>', f'#{channel.name}')
|
message_text = message_text.replace(f'<#{channel.id}>', f'#{channel.name}')
|
||||||
|
|
||||||
image_url = None
|
if not message_text.strip():
|
||||||
if original_message.attachments:
|
|
||||||
for attachment in original_message.attachments:
|
|
||||||
if any(attachment.filename.lower().endswith(ext) for ext in ['.png', '.jpg', '.jpeg', '.gif', '.webp']):
|
|
||||||
raw_url = attachment.url
|
|
||||||
if 'cdn.discordapp.com' in raw_url:
|
|
||||||
media_url = raw_url.replace('cdn.discordapp.com', 'media.discordapp.net')
|
|
||||||
if '?' not in media_url:
|
|
||||||
media_url += f"?width={attachment.width}&height={attachment.height}"
|
|
||||||
elif 'width=' not in media_url and attachment.width:
|
|
||||||
media_url += f"&width={attachment.width}&height={attachment.height}"
|
|
||||||
image_url = media_url
|
|
||||||
else:
|
|
||||||
image_url = raw_url
|
|
||||||
break
|
|
||||||
|
|
||||||
if not message_text.strip() and not image_url:
|
|
||||||
await processing_msg.delete()
|
await processing_msg.delete()
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Error",
|
title="Error",
|
||||||
description="Message must have either text content or an image/GIF to convert!",
|
description="No text found! This command only works with text messages.",
|
||||||
color=0xE02B2B,
|
color=0xE02B2B,
|
||||||
)
|
)
|
||||||
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||||
await context.send(embed=embed)
|
await context.send(embed=embed, ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
ny_tz = pytz.timezone('America/New_York')
|
ny_tz = pytz.timezone('America/New_York')
|
||||||
@@ -331,9 +305,6 @@ def tweety_command():
|
|||||||
"dark": False
|
"dark": False
|
||||||
}
|
}
|
||||||
|
|
||||||
if image_url:
|
|
||||||
tweet_data["image"] = image_url
|
|
||||||
|
|
||||||
API_BASE_URL = "https://tweety-api.vercel.app"
|
API_BASE_URL = "https://tweety-api.vercel.app"
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
|
|||||||
Reference in New Issue
Block a user