Improving request command handeling
This commit is contained in:
parent
fe567952b4
commit
8aa5563847
98
commands.py
98
commands.py
@ -137,8 +137,32 @@ class MediaCommands(commands.Cog):
|
|||||||
status_str = status_map.get(status, "Unknown")
|
status_str = status_map.get(status, "Unknown")
|
||||||
embed.add_field(name="Status", value=status_str, inline=True)
|
embed.add_field(name="Status", value=status_str, inline=True)
|
||||||
|
|
||||||
# Add request button info
|
# Add request button info or status
|
||||||
if not media_info or media_info.get('status') < 5:
|
if not media_info:
|
||||||
|
embed.add_field(
|
||||||
|
name="Request this Movie",
|
||||||
|
value=f"Use `{config.BOT_PREFIX}request movie {media_id}` to request this movie",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 5: # Available
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="✅ This movie is available in your library",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 3: # Processing
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="⏳ This movie is being processed",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 2: # Pending
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="⏳ This movie has been requested and is pending",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') < 5:
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Request this Movie",
|
name="Request this Movie",
|
||||||
value=f"Use `{config.BOT_PREFIX}request movie {media_id}` to request this movie",
|
value=f"Use `{config.BOT_PREFIX}request movie {media_id}` to request this movie",
|
||||||
@ -230,8 +254,44 @@ class MediaCommands(commands.Cog):
|
|||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add request button info
|
# Add request button info or status
|
||||||
if not media_info or media_info.get('status') < 5:
|
if not media_info:
|
||||||
|
embed.add_field(
|
||||||
|
name="Request this Show",
|
||||||
|
value=f"Use `{config.BOT_PREFIX}request tv {media_id}` to request all seasons or\n"
|
||||||
|
f"`{config.BOT_PREFIX}request tv {media_id} <season_nums>` for specific seasons",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 5: # Available
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="✅ This TV show is available in your library",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 4: # Partially Available
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="⚠️ This TV show is partially available. You may want to request specific seasons.",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Request Specific Seasons",
|
||||||
|
value=f"Use `{config.BOT_PREFIX}request tv {media_id} <season_nums>` to request specific seasons",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 3: # Processing
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="⏳ This TV show is being processed",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') == 2: # Pending
|
||||||
|
embed.add_field(
|
||||||
|
name="Status",
|
||||||
|
value="⏳ This TV show has been requested and is pending",
|
||||||
|
inline=False
|
||||||
|
)
|
||||||
|
elif media_info.get('status') < 5:
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Request this Show",
|
name="Request this Show",
|
||||||
value=f"Use `{config.BOT_PREFIX}request tv {media_id}` to request all seasons or\n"
|
value=f"Use `{config.BOT_PREFIX}request tv {media_id}` to request all seasons or\n"
|
||||||
@ -486,6 +546,22 @@ class RequestCommands(commands.Cog):
|
|||||||
await ctx.send(f"Could not retrieve details for {media_type} with ID {media_id}. Please check the ID and try again.")
|
await ctx.send(f"Could not retrieve details for {media_type} with ID {media_id}. Please check the ID and try again.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Check if media is already available
|
||||||
|
if media_details.get('mediaInfo'):
|
||||||
|
status = media_details.get('mediaInfo', {}).get('status')
|
||||||
|
if status == 5: # 5 = Available
|
||||||
|
await ctx.send(f"**{title}** is already available in your library! No need to request it.")
|
||||||
|
return
|
||||||
|
elif status == 4: # 4 = Partially Available (for TV shows)
|
||||||
|
if media_type.lower() == 'tv':
|
||||||
|
await ctx.send(f"**{title}** is partially available in your library. You might want to request specific seasons instead.")
|
||||||
|
elif status == 3: # 3 = Processing
|
||||||
|
await ctx.send(f"**{title}** is currently being processed. Please wait for it to become available.")
|
||||||
|
return
|
||||||
|
elif status == 2: # 2 = Pending
|
||||||
|
await ctx.send(f"**{title}** has already been requested and is pending approval or processing.")
|
||||||
|
return
|
||||||
|
|
||||||
# Create the request
|
# Create the request
|
||||||
request_data = {
|
request_data = {
|
||||||
'media_type': media_type.lower(),
|
'media_type': media_type.lower(),
|
||||||
@ -541,14 +617,18 @@ class RequestCommands(commands.Cog):
|
|||||||
|
|
||||||
error_message = str(e)
|
error_message = str(e)
|
||||||
if "500" in error_message:
|
if "500" in error_message:
|
||||||
await ctx.send(f"Error creating request: Server error (500). This could be because:\n"
|
if "Request already exists" in error_message:
|
||||||
f"1. You might not have permission to request this media\n"
|
await ctx.send(f"This media has already been requested and is either pending or being processed.")
|
||||||
f"2. The media ID doesn't exist or is invalid\n"
|
else:
|
||||||
f"3. The media may already be requested or available\n\n"
|
await ctx.send(f"Error creating request: Server error (500). This could be because:\n"
|
||||||
f"Try searching for the media first with `{config.BOT_PREFIX}search` to get a valid ID")
|
f"1. You might not have permission to request this media\n"
|
||||||
|
f"2. The media ID doesn't exist or is invalid\n"
|
||||||
|
f"3. The media may already be requested or available\n\n"
|
||||||
|
f"Try using `{config.BOT_PREFIX}info {media_id}` to check the current status")
|
||||||
elif "401" in error_message or "403" in error_message:
|
elif "401" in error_message or "403" in error_message:
|
||||||
await ctx.send(f"Error creating request: Authentication error. The bot account may not have permission to make requests.")
|
await ctx.send(f"Error creating request: Authentication error. The bot account may not have permission to make requests.")
|
||||||
else:
|
else:
|
||||||
|
await ctx.send(f"Error creating request: {str(e)}")
|
||||||
# Provide more specific error messages for common issues
|
# Provide more specific error messages for common issues
|
||||||
if "already exists" in str(e).lower():
|
if "already exists" in str(e).lower():
|
||||||
await ctx.send(f"This media has already been requested or is already available in your library.")
|
await ctx.send(f"This media has already been requested or is already available in your library.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user