diff options
author | 2019-08-14 21:35:44 -0400 | |
---|---|---|
committer | 2019-08-14 21:35:44 -0400 | |
commit | 61b44ccb430eaf785bc2c279f928e6c0a253c4d5 (patch) | |
tree | a1d9cfadc6ddd1af78733053b1789b6c839ec30b /bot | |
parent | add recommend_game.py and resource files (diff) |
added wiki links and author to json files, changes to Embed
Diffstat (limited to 'bot')
-rw-r--r-- | bot/resources/evergreen/game_recs/chrono_trigger.json | 6 | ||||
-rw-r--r-- | bot/resources/evergreen/game_recs/digimon_world.json | 4 | ||||
-rw-r--r-- | bot/resources/evergreen/game_recs/skyrim.json | 6 | ||||
-rw-r--r-- | bot/seasons/evergreen/recommend_game.py | 56 |
4 files changed, 67 insertions, 5 deletions
diff --git a/bot/resources/evergreen/game_recs/chrono_trigger.json b/bot/resources/evergreen/game_recs/chrono_trigger.json index 970f7899..cde74b70 100644 --- a/bot/resources/evergreen/game_recs/chrono_trigger.json +++ b/bot/resources/evergreen/game_recs/chrono_trigger.json @@ -1,10 +1,12 @@ { "title": "Chrono Trigger", - "recText": "My personal favorite game of all time. Square + Enix + Akira Toriyama = Pure Time-traveling gold.", + "recText": "One of the best games of all time. A brilliant story involving time-travel with loveable characters. It has a brilliant score by Yasonuri Mitsuda and artwork by Akira Toriyama. With over 20 endings and New Game+, there is a huge amount of replay value here.", "console": [ "snes", "gba", "pc" ], - "image": "https://vignette.wikia.nocookie.net/chrono/images/2/24/Chrono_Trigger_cover.jpg" + "wikiLink": "https://chrono.fandom.com/wiki/Chrono_Trigger", + "image": "https://vignette.wikia.nocookie.net/chrono/images/2/24/Chrono_Trigger_cover.jpg", + "author": "352635617709916161" }
\ No newline at end of file diff --git a/bot/resources/evergreen/game_recs/digimon_world.json b/bot/resources/evergreen/game_recs/digimon_world.json index e58dd2ed..86883e44 100644 --- a/bot/resources/evergreen/game_recs/digimon_world.json +++ b/bot/resources/evergreen/game_recs/digimon_world.json @@ -4,5 +4,7 @@ "console": [ "ps1" ], - "image": "https://www.mobygames.com/images/covers/l/437308-digimon-world-playstation-front-cover.jpg" + "image": "https://www.mobygames.com/images/covers/l/437308-digimon-world-playstation-front-cover.jpg", + "wikiLink": "https://digimon.fandom.com/wiki/Digimon_World", + "author": "352635617709916161" }
\ No newline at end of file diff --git a/bot/resources/evergreen/game_recs/skyrim.json b/bot/resources/evergreen/game_recs/skyrim.json index e26ff988..7a6ef117 100644 --- a/bot/resources/evergreen/game_recs/skyrim.json +++ b/bot/resources/evergreen/game_recs/skyrim.json @@ -1,6 +1,6 @@ { "title": "Elder Scrolls V: Skyrim", - "recText": "The last mainline Elder Scrolls game offered a fantastic role-playing experience with untethered freedom and a great story", + "recText": "The latest mainline Elder Scrolls game offered a fantastic role-playing experience with untethered freedom and a great story. Offering vast mod support, the game has endless customization and replay value.", "console": [ "xbox 360", "ps3", @@ -9,5 +9,7 @@ "xbox one", "ps4" ], - "image": "https://upload.wikimedia.org/wikipedia/en/1/15/The_Elder_Scrolls_V_Skyrim_cover.png" + "image": "https://upload.wikimedia.org/wikipedia/en/1/15/The_Elder_Scrolls_V_Skyrim_cover.png", + "wikiLink": "https://elderscrolls.fandom.com/wiki/Skyrim", + "author": "352635617709916161" }
\ No newline at end of file diff --git a/bot/seasons/evergreen/recommend_game.py b/bot/seasons/evergreen/recommend_game.py index e69de29b..e4ad5392 100644 --- a/bot/seasons/evergreen/recommend_game.py +++ b/bot/seasons/evergreen/recommend_game.py @@ -0,0 +1,56 @@ +import json +import logging +import os +from pathlib import Path +from random import shuffle + +import discord +from discord.ext import commands + +log = logging.getLogger(__name__) +DIR = "bot/resources/evergreen/game_recs" +game_recs = [] + + +class RecommendGame(commands.Cog): + """Commands related to recommending games.""" + + def __init__(self, bot): + self.bot = bot + self.populate_recs() + + @commands.command(name="recommend_game") + async def recommend_game(self, ctx): + """Sends an Embed of a random game recommendation.""" + if not game_recs: + self.populate_recs() + game = game_recs.pop() + else: + game = game_recs.pop() + + embed = discord.Embed( + title=game['title'], + url=game['wikiLink'], + color=discord.Colour.blue() + ) + + author = self.bot.get_user(int(game['author'])) + embed.set_author(name=author.name, icon_url=author.avatar_url) + embed.set_image(url=game['image']) + embed.add_field(name="Recommendation", value=game['recText']) + + await ctx.send(embed=embed) + + def populate_recs(self): + """Populates the game_recs list from resources.""" + for file_url in os.listdir(DIR): + with Path(DIR, file_url).open(encoding='utf-8') as file: + data = json.load(file) + game_recs.append(data) + shuffle(game_recs) + + +def setup(bot): + """Loads the RecommendGame cog.""" + bot.add_cog(RecommendGame(bot)) + log.info("Recommend_Game cog loaded") |