mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
Add context menu command for birthday role assignment. Users with allowed roles can now give birthday roles via right-click menu.
This commit is contained in:
@@ -112,20 +112,20 @@ class Birthday(commands.Cog):
|
||||
await self.config.guild(ctx.guild).birthday_channel.set(channel.id)
|
||||
await ctx.send(f"Birthday announcement channel set to {channel.mention}")
|
||||
|
||||
@commands.hybrid_command(name="addrole")
|
||||
@commands.hybrid_command(name="birthdayallowrole")
|
||||
@app_commands.guild_only()
|
||||
@app_commands.describe(role="The role to allow using the birthday command")
|
||||
async def add_allowed_role(self, ctx: commands.Context, role: discord.Role):
|
||||
async def birthday_allow_role(self, ctx: commands.Context, role: discord.Role):
|
||||
"""Add a role that can use the birthday command."""
|
||||
async with self.config.guild(ctx.guild).allowed_roles() as allowed_roles:
|
||||
if role.id not in allowed_roles:
|
||||
allowed_roles.append(role.id)
|
||||
await ctx.send(f"Added {role.name} to the list of roles that can use the birthday command.")
|
||||
|
||||
@commands.hybrid_command(name="removerole")
|
||||
@commands.hybrid_command(name="birthdayremoverole")
|
||||
@app_commands.guild_only()
|
||||
@app_commands.describe(role="The role to remove from using the birthday command")
|
||||
async def remove_allowed_role(self, ctx: commands.Context, role: discord.Role):
|
||||
async def birthday_remove_role(self, ctx: commands.Context, role: discord.Role):
|
||||
"""Remove a role from using the birthday command."""
|
||||
async with self.config.guild(ctx.guild).allowed_roles() as allowed_roles:
|
||||
if role.id in allowed_roles:
|
||||
|
||||
@@ -293,7 +293,9 @@ class VideoProcessor:
|
||||
for word in words:
|
||||
# Try each extractor
|
||||
for ie in ydl._ies:
|
||||
if ie.suitable(word):
|
||||
# Use suitable as a classmethod and check the result
|
||||
result = ie.suitable(word)
|
||||
if result and not isinstance(result, str):
|
||||
urls.append(word)
|
||||
break # Stop once we find a matching extractor
|
||||
except Exception as e:
|
||||
|
||||
@@ -93,7 +93,7 @@ class VideoDownloader:
|
||||
try:
|
||||
with yt_dlp.YoutubeDL() as ydl:
|
||||
for extractor in ydl._ies:
|
||||
if hasattr(extractor, "_VALID_URL") and extractor._VALID_URL:
|
||||
if hasattr(extractor, '_VALID_URL') and extractor._VALID_URL:
|
||||
if not self.enabled_sites or any(
|
||||
site.lower() in extractor.IE_NAME.lower()
|
||||
for site in self.enabled_sites
|
||||
@@ -313,8 +313,8 @@ class VideoDownloader:
|
||||
for site in self.enabled_sites
|
||||
):
|
||||
continue
|
||||
# Try to match URL
|
||||
if extractor.suitable(url):
|
||||
# Try to match URL using the class method
|
||||
if extractor.suitable(url) and not isinstance(extractor.suitable(url), str):
|
||||
return True
|
||||
return False
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user