Skip to content

Commit 2668a40

Browse files
committedJan 20, 2023
Small changes
1 parent 0225540 commit 2668a40

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed
 

‎lib/cogs/Youtube.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, bot):
1717

1818
youtube = SlashCommandGroup('youtube')
1919

20-
def check_channel(self, handle: str, message: str, guild_id: str):
20+
async def check_channel(self, handle: str, message: str, guild_id: str):
2121
async with aiohttp.ClientSession() as session:
2222
res = await session.get(f"https://youtube.com/@{handle}/videos")
2323
html = await res.text()
@@ -27,7 +27,6 @@ def check_channel(self, handle: str, message: str, guild_id: str):
2727
except AttributeError:
2828
latest_video_url = ""
2929

30-
3130
@youtube.command(name='notify', description='Get a ping when this user uploads')
3231
@option('handle',
3332
str,
@@ -49,7 +48,8 @@ async def youtube_notify(self, ctx: CustomContext, handle: str, message: str | N
4948
elif res.status not in range(200, 300):
5049
return await ctx.respond(embed=Embed(title=':x: | Something went wrong', colour=0xff0000))
5150

52-
user = self.bot.db.record("""SELECT * FROM youtube WHERE handle = ? AND guild_id = ?""", handle, ctx.guild_id)
51+
user = self.bot.db.record("""SELECT * FROM youtube WHERE handle = ? AND guild_id = ?""", handle,
52+
ctx.guild_id)
5353
if user:
5454
return await ctx.respond(embed=Embed(title=':x: | Already watching for new videos', colour=0xff0000))
5555

@@ -60,16 +60,11 @@ async def youtube_notify(self, ctx: CustomContext, handle: str, message: str | N
6060
latest_video_url = "https://www.youtube.com/watch?v=" + re.search('(?<="videoId":").*?(?=")', html).group()
6161
except AttributeError:
6262
latest_video_url = ""
63-
self.bot.db.execute("""INSERT INTO youtube VALUES (?,?,?,?)""", handle, ctx.guild_id, message if message else f"@{handle} has uploaded a video", latest_video_url)
63+
self.bot.db.execute("""INSERT INTO youtube VALUES (?,?,?,?)""", handle, ctx.guild_id,
64+
message if message else f"@{handle} has uploaded a video", latest_video_url)
6465
await ctx.respond(embed=Embed(title=f'✅ | Waiting for @{handle} to post more videos'))
65-
self.bot.tasks.add_job(id=f"{handle}|{ctx.guild_id}", args=(handle, message, ctx.guild_id,), trigger='interval', minutes=1)
66-
67-
68-
69-
70-
71-
72-
66+
self.bot.tasks.add_job(id=f"{handle}|{ctx.guild_id}", args=(handle, message, ctx.guild_id,), trigger='interval',
67+
minutes=1)
7368

7469

7570
def setup(bot):

0 commit comments

Comments
 (0)