refactor(tweet): new york time

add pytz requirements
This commit is contained in:
neoarz
2025-10-07 22:10:52 -04:00
parent 56818bf912
commit 47043fb38b
2 changed files with 12 additions and 9 deletions

View File

@@ -1,3 +1,8 @@
# The API used in the tweety command is made by me and can be found here:
# https://github.com/neoarz/tweety-api
# I made this out of spite since i couldnt find any free APIs for this
# Its serverless and hosted on Vercel :)
import os import os
import tempfile import tempfile
import discord import discord
@@ -5,10 +10,11 @@ from discord.ext import commands
import aiohttp import aiohttp
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional
import pytz
class TweetyHelpView(discord.ui.View): class TweetyHelpView(discord.ui.View):
"""Paginated help view for tweety command""" """This is the help view for the slash command cuz only the pinging and prefix versions can use this command"""
def __init__(self, user_id: int, bot): def __init__(self, user_id: int, bot):
super().__init__(timeout=180) super().__init__(timeout=180)
@@ -36,7 +42,6 @@ class TweetyHelpView(discord.ui.View):
self.update_buttons() self.update_buttons()
def create_embed(self): def create_embed(self):
"""Create embed for current page"""
page = self.pages[self.current_page] page = self.pages[self.current_page]
embed = discord.Embed( embed = discord.Embed(
title=page["title"], title=page["title"],
@@ -54,7 +59,6 @@ class TweetyHelpView(discord.ui.View):
return embed return embed
def update_buttons(self): def update_buttons(self):
"""Update button states based on current page"""
self.clear_items() self.clear_items()
prev_button = discord.ui.Button( prev_button = discord.ui.Button(
@@ -76,7 +80,6 @@ class TweetyHelpView(discord.ui.View):
self.add_item(next_button) self.add_item(next_button)
async def previous_page(self, interaction: discord.Interaction): async def previous_page(self, interaction: discord.Interaction):
"""Go to previous page"""
if interaction.user.id != self.user_id: if interaction.user.id != self.user_id:
await interaction.response.send_message("You can't control someone else's help menu!", ephemeral=True) await interaction.response.send_message("You can't control someone else's help menu!", ephemeral=True)
return return
@@ -89,7 +92,6 @@ class TweetyHelpView(discord.ui.View):
await interaction.response.defer() await interaction.response.defer()
async def next_page(self, interaction: discord.Interaction): async def next_page(self, interaction: discord.Interaction):
"""Go to next page"""
if interaction.user.id != self.user_id: if interaction.user.id != self.user_id:
await interaction.response.send_message("You can't control someone else's help menu!", ephemeral=True) await interaction.response.send_message("You can't control someone else's help menu!", ephemeral=True)
return return
@@ -102,7 +104,6 @@ class TweetyHelpView(discord.ui.View):
await interaction.response.defer() await interaction.response.defer()
async def on_timeout(self): async def on_timeout(self):
"""Disable buttons when view times out"""
for item in self.children: for item in self.children:
item.disabled = True item.disabled = True
@@ -123,7 +124,6 @@ class TweetyView(discord.ui.View):
self.update_button_styles() self.update_button_styles()
def update_button_styles(self): def update_button_styles(self):
"""Update button styles to reflect current state"""
self.clear_items() self.clear_items()
dark_button = discord.ui.Button( dark_button = discord.ui.Button(
@@ -310,7 +310,9 @@ def tweety_command():
await context.send(embed=embed) await context.send(embed=embed)
return return
timestamp = original_message.created_at.strftime("%I:%M %p · %b %d, %Y").replace(" 0", " ") ny_tz = pytz.timezone('America/New_York')
msg_time_ny = original_message.created_at.astimezone(ny_tz)
timestamp = msg_time_ny.strftime("%I:%M %p · %b %d, %Y").replace(" 0", " ")
tweet_data = { tweet_data = {
"name": display_name[:50], "name": display_name[:50],
"handle": username[:20], "handle": username[:20],

View File

@@ -4,4 +4,5 @@ discord.py==2.6.3
python-dotenv python-dotenv
yt-dlp yt-dlp
Pillow Pillow
pillow-heif pillow-heif
pytz