mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
[V3 Audio] Add checking for valid file on upload (#1891)
This commit is contained in:
parent
e08c9dafa6
commit
1f1a85de18
@ -919,8 +919,11 @@ class Audio:
|
|||||||
file_suffix = file_url.rsplit(".", 1)[1]
|
file_suffix = file_url.rsplit(".", 1)[1]
|
||||||
if file_suffix != "txt":
|
if file_suffix != "txt":
|
||||||
return await self._embed_msg(ctx, "Only playlist files can be uploaded.")
|
return await self._embed_msg(ctx, "Only playlist files can be uploaded.")
|
||||||
|
try:
|
||||||
async with self.session.request("GET", file_url) as r:
|
async with self.session.request("GET", file_url) as r:
|
||||||
v2_playlist = await r.json(content_type="text/plain")
|
v2_playlist = await r.json(content_type="text/plain")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return await self._embed_msg(ctx, "Not a valid playlist file.")
|
||||||
try:
|
try:
|
||||||
v2_playlist_url = v2_playlist["link"]
|
v2_playlist_url = v2_playlist["link"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user