From a0eab474c6a05381434ba987fdd79fd53ba87de7 Mon Sep 17 00:00:00 2001 From: ledinhchinh0212 Date: Fri, 10 Jan 2025 13:16:15 +0700 Subject: [PATCH 1/3] Add self-interaction responses --- cogs/query/send_GIF.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/cogs/query/send_GIF.py b/cogs/query/send_GIF.py index f785cd3..c2efe8a 100644 --- a/cogs/query/send_GIF.py +++ b/cogs/query/send_GIF.py @@ -3,12 +3,16 @@ import discord from discord.ext import commands from discord import app_commands - +from enum import Enum import config GIPHY_API_KEY = config.GIPHY_API_KEY GIPHY_URL = "https://api.giphy.com/v1/gifs/search" +class Action(Enum): + KISS = 'kiss', + HUG = 'hug' + class SendGIF(commands.Cog): def __init__(self, bot): self.bot = bot @@ -62,11 +66,31 @@ async def fetch_gif(self, style: str, interaction: discord.Interaction, user: di @app_commands.command(name="hug", description="Lệnh ôm ai đó và gửi GIF") async def hug_command(self, interaction: discord.Interaction, user: discord.Member): - await self.fetch_gif("hug", interaction, user) + if user == interaction.user: + responses = [ + f"Hugging yourself... 🤗 Somebody, come give you a hug!", + f"Giving yourself a big, warm hug! Don't be sad~ 💖", + f"Hugging yourself... Do you need a hug from someone special? <(\")", + f"Wrapping yourself up in a cozy blanket for a self-hug~ ☁️💞", + f"Snuggling a pillow tightly! Everything's gonna be okay~ 💕" + ] + await interaction.response.send_message(random.choice(responses)) + else: + await self.fetch_gif(Action.HUG.value, interaction, user) @app_commands.command(name="kiss", description="Lệnh kiss ai đó và gửi GIF") async def kiss(self, interaction: discord.Interaction, user: discord.Member): - await self.fetch_gif("kiss", interaction, user) + if user == interaction.user: + responses = [ + f"Kisses themselves... 😘 Loving yourself is amazing!", + f"Gives themselves a cheek kiss~ UwU 💕", + f"Blows a kiss to themselves! 💋✨", + f"Smooches themselves! Someone should come and claim this kiss~ 💞", + f"Rewards themselves with a cute kiss! You're awesome! <(\")" + ] + await interaction.response.send_message(random.choice(responses)) + else: + await self.fetch_gif(Action.KISS.value, interaction, user) async def setup(bot): await bot.add_cog(SendGIF(bot)) \ No newline at end of file From 298df5dce0ef5d4283078c3f8e15f3ed451a366d Mon Sep 17 00:00:00 2001 From: ledinhchinh0212 Date: Fri, 10 Jan 2025 13:21:14 +0700 Subject: [PATCH 2/3] Update weather embed color based on temperature and add weather icon thumbnail --- cogs/query/weather.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cogs/query/weather.py b/cogs/query/weather.py index 339b02d..8ff715c 100644 --- a/cogs/query/weather.py +++ b/cogs/query/weather.py @@ -37,13 +37,15 @@ async def weather_command(self, interaction: discord.Interaction, city_name: str embed = discord.Embed( title=f"Thông tin thời tiết tại {city}, {country}", description=f"{weather_description.capitalize()}", - color=discord.Color.blue() + color=discord.Color.red() if temperature >= 30 else discord.Color.orange() if temperature > 20 else discord.Color.blue() ) + embed.set_thumbnail(url=f"http://openweathermap.org/img/wn/{weather['icon']}@2x.png") embed.add_field(name="Nhiệt độ", value=f"{temperature}°C", inline=False) embed.add_field(name="Độ ẩm", value=f"{humidity}%", inline=False) embed.add_field(name="Áp suất", value=f"{pressure} hPa", inline=False) embed.add_field(name="Tốc độ gió", value=f"{wind_speed} m/s", inline=False) + await interaction.response.send_message(embed=embed) async def setup(bot): From 36d53b0b86e697786d8ed3c89c9e5e0aad6bf6dd Mon Sep 17 00:00:00 2001 From: ledinhchinh0212 Date: Fri, 10 Jan 2025 13:26:15 +0700 Subject: [PATCH 3/3] Update server stats embed color to white and format recent members' join date with relative timestamps --- cogs/stats/server_stats.py | 2 +- cogs/user/recent_members.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cogs/stats/server_stats.py b/cogs/stats/server_stats.py index 16d8eb9..999e8eb 100644 --- a/cogs/stats/server_stats.py +++ b/cogs/stats/server_stats.py @@ -25,7 +25,7 @@ async def server_stats(self, interaction: discord.Interaction): embed = discord.Embed( title=f"Thống Kê Server: {guild.name}", - color=0x67ff4f + color=0xFFFFFF ) embed.add_field(name="Tổng số thành viên", value=total_members, inline=False) embed.add_field(name="Số thành viên (người)", value=total_users, inline=True) diff --git a/cogs/user/recent_members.py b/cogs/user/recent_members.py index a87b0a8..cf57834 100644 --- a/cogs/user/recent_members.py +++ b/cogs/user/recent_members.py @@ -24,8 +24,9 @@ async def recent_members(self, interaction: discord.Interaction): member_info = [] for member in recent_members: - join_date = member.joined_at.strftime('%d-%m-%Y %H:%M:%S') - member_info.append(f"**{member.name}** - Tham gia vào: {join_date}") + join_date = f"" + join_long = f"" + member_info.append(f"**{member.name}** - {join_date} ({join_long})") embed = discord.Embed( title="Các thành viên tham gia gần đây",