mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-28 14:36:56 -05:00
Compare commits
2 Commits
a472d1669b
...
pixeebot/d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f63a24659 | ||
|
|
2e7ed15038 |
@@ -229,6 +229,48 @@ class Birthday(commands.Cog):
|
|||||||
logger.error("Unexpected error in remove_birthday command", exc_info=True)
|
logger.error("Unexpected error in remove_birthday command", exc_info=True)
|
||||||
await ctx.send(f"An error occurred while removing the birthday role: {str(e)}", ephemeral=True)
|
await ctx.send(f"An error occurred while removing the birthday role: {str(e)}", ephemeral=True)
|
||||||
|
|
||||||
|
@commands.hybrid_command(name="status")
|
||||||
|
@app_commands.guild_only()
|
||||||
|
async def status(self, ctx: commands.Context):
|
||||||
|
"""Show the status of the Birthday cog in the current server."""
|
||||||
|
try:
|
||||||
|
# Check if the user has permission to use this command
|
||||||
|
allowed_roles = await self.config.guild(ctx.guild).allowed_roles()
|
||||||
|
if not any(role.id in allowed_roles for role in ctx.author.roles):
|
||||||
|
logger.warning(f"User {ctx.author.id} attempted to use status command without permission")
|
||||||
|
return await ctx.send("You don't have permission to use this command.", ephemeral=True)
|
||||||
|
|
||||||
|
# Fetch configuration details
|
||||||
|
birthday_role_id = await self.config.guild(ctx.guild).birthday_role()
|
||||||
|
birthday_role = ctx.guild.get_role(birthday_role_id) if birthday_role_id else None
|
||||||
|
allowed_roles_ids = await self.config.guild(ctx.guild).allowed_roles()
|
||||||
|
allowed_roles = [ctx.guild.get_role(role_id) for role_id in allowed_roles_ids]
|
||||||
|
timezone = await self.config.guild(ctx.guild).timezone()
|
||||||
|
birthday_channel_id = await self.config.guild(ctx.guild).birthday_channel()
|
||||||
|
birthday_channel = ctx.guild.get_channel(birthday_channel_id) if birthday_channel_id else None
|
||||||
|
scheduled_tasks = await self.config.guild(ctx.guild).scheduled_tasks()
|
||||||
|
|
||||||
|
# Construct status message
|
||||||
|
status_message = f"**Birthday Cog Status for {ctx.guild.name}**\n"
|
||||||
|
status_message += f"**Birthday Role:** {birthday_role.name if birthday_role else 'Not Set'}\n"
|
||||||
|
status_message += f"**Allowed Roles:** {', '.join(role.name for role in allowed_roles if role) if allowed_roles else 'None'}\n"
|
||||||
|
status_message += f"**Timezone:** {timezone}\n"
|
||||||
|
status_message += f"**Birthday Channel:** {birthday_channel.mention if birthday_channel else 'Not Set'}\n"
|
||||||
|
status_message += f"**Scheduled Tasks:** {len(scheduled_tasks)}\n"
|
||||||
|
|
||||||
|
if scheduled_tasks:
|
||||||
|
status_message += "\n**Upcoming Tasks:**\n"
|
||||||
|
for member_id, task_info in scheduled_tasks.items():
|
||||||
|
member = ctx.guild.get_member(int(member_id))
|
||||||
|
role = ctx.guild.get_role(task_info["role_id"])
|
||||||
|
remove_at = datetime.fromisoformat(task_info["remove_at"]).replace(tzinfo=ZoneInfo(timezone))
|
||||||
|
status_message += f"- {member.display_name} ({role.name}) at {remove_at}\n"
|
||||||
|
|
||||||
|
await ctx.send(status_message, ephemeral=True)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Unexpected error in status command: {str(e)}", exc_info=True)
|
||||||
|
await ctx.send(f"An error occurred while fetching the status: {str(e)}", ephemeral=True)
|
||||||
|
|
||||||
async def daily_cleanup(self):
|
async def daily_cleanup(self):
|
||||||
"""Daily task to ensure all birthday roles are properly removed."""
|
"""Daily task to ensure all birthday roles are properly removed."""
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
import requests
|
|
||||||
import tarfile
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -19,6 +18,7 @@ import lzma
|
|||||||
# try:
|
# try:
|
||||||
# Try relative imports first
|
# Try relative imports first
|
||||||
from exceptions import DownloadError
|
from exceptions import DownloadError
|
||||||
|
from security import safe_requests
|
||||||
|
|
||||||
# except ImportError:
|
# except ImportError:
|
||||||
# Fall back to absolute imports if relative imports fail
|
# Fall back to absolute imports if relative imports fail
|
||||||
@@ -175,7 +175,7 @@ class FFmpegDownloader:
|
|||||||
|
|
||||||
logger.info(f"Downloading FFmpeg from {url}")
|
logger.info(f"Downloading FFmpeg from {url}")
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, stream=True, timeout=30)
|
response = safe_requests.get(url, stream=True, timeout=30)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
total_size = int(response.headers.get("content-length", 0))
|
total_size = int(response.headers.get("content-length", 0))
|
||||||
|
|||||||
Reference in New Issue
Block a user