mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
fix(tweety): only works with text no more images
also now works with other bot messages
This commit is contained in:
@@ -256,16 +256,6 @@ def tweety_command():
|
||||
|
||||
try:
|
||||
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(
|
||||
title="Tweet Generator (Processing)",
|
||||
@@ -291,31 +281,15 @@ def tweety_command():
|
||||
for channel in original_message.channel_mentions:
|
||||
message_text = message_text.replace(f'<#{channel.id}>', f'#{channel.name}')
|
||||
|
||||
image_url = None
|
||||
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:
|
||||
if not message_text.strip():
|
||||
await processing_msg.delete()
|
||||
embed = discord.Embed(
|
||||
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,
|
||||
)
|
||||
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
|
||||
|
||||
ny_tz = pytz.timezone('America/New_York')
|
||||
@@ -331,9 +305,6 @@ def tweety_command():
|
||||
"dark": False
|
||||
}
|
||||
|
||||
if image_url:
|
||||
tweet_data["image"] = image_url
|
||||
|
||||
API_BASE_URL = "https://tweety-api.vercel.app"
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
||||
Reference in New Issue
Block a user