Skip to content

Commit d02117c

Browse files
committed
Add API key messages to books and youtube
1 parent 4d0151f commit d02117c

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

plugins/books.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def load_key(bot):
1717
def books(text):
1818
"""books <query> -- Searches Google Books for <query>."""
1919
if not dev_key:
20-
return "No Google API key."
20+
return "This command requires a Google API key."
2121

2222
json = requests.get(book_search_api, params={"q": text, "key": dev_key}).json()
2323

plugins/youtube.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def youtube_url(match, bot):
7878
@hook.command("youtube", "you", "yt", "y")
7979
def youtube(text):
8080
"""youtube <query> -- Returns the first YouTube search result for <query>."""
81+
if not dev_key:
82+
return "This command requires a Google API key."
83+
8184
json = requests.get(search_api_url, params={"q": text, "key": dev_key}).json()
8285

8386
if 'error' in json:
@@ -94,6 +97,9 @@ def youtube(text):
9497
@hook.command("youtime", "ytime")
9598
def youtime(text):
9699
"""youtime <query> -- Gets the total run time of the first YouTube search result for <query>."""
100+
if not dev_key:
101+
return "This command requires a Google API key."
102+
97103
json = requests.get(search_api_url, params={"q": text, "key": dev_key}).json()
98104

99105
if 'error' in json:

0 commit comments

Comments
 (0)