diff options
| -rw-r--r-- | bot/resources/evergreen/game_recs/chrono_trigger.json | 7 | ||||
| -rw-r--r-- | bot/resources/evergreen/game_recs/digimon_world.json | 7 | ||||
| -rw-r--r-- | bot/resources/evergreen/game_recs/doom_2.json | 7 | ||||
| -rw-r--r-- | bot/resources/evergreen/game_recs/skyrim.json | 7 | ||||
| -rw-r--r-- | bot/seasons/evergreen/recommend_game.py | 51 | 
5 files changed, 79 insertions, 0 deletions
| diff --git a/bot/resources/evergreen/game_recs/chrono_trigger.json b/bot/resources/evergreen/game_recs/chrono_trigger.json new file mode 100644 index 00000000..219c1e78 --- /dev/null +++ b/bot/resources/evergreen/game_recs/chrono_trigger.json @@ -0,0 +1,7 @@ +{ +  "title": "Chrono Trigger", +  "description": "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.", +  "link": "https://rawg.io/games/chrono-trigger-1995", +  "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 new file mode 100644 index 00000000..a2820f8e --- /dev/null +++ b/bot/resources/evergreen/game_recs/digimon_world.json @@ -0,0 +1,7 @@ +{ +  "title": "Digimon World", +  "description": "A great mix of town-building and pet-raising set in the Digimon universe. With plenty of Digimon to raise and recruit to the village, this charming game will keep you occupied for a long time.", +  "image": "https://www.mobygames.com/images/covers/l/437308-digimon-world-playstation-front-cover.jpg", +  "link": "https://rawg.io/games/digimon-world", +  "author": "352635617709916161" +}
\ No newline at end of file diff --git a/bot/resources/evergreen/game_recs/doom_2.json b/bot/resources/evergreen/game_recs/doom_2.json new file mode 100644 index 00000000..e228e2b1 --- /dev/null +++ b/bot/resources/evergreen/game_recs/doom_2.json @@ -0,0 +1,7 @@ +{ +  "title": "Doom II", +  "description": "Doom 2 was one of the first FPS games that I truly enjoyed. It offered awesome weapons, terrifying demons to kill, and a great atmosphere to do it in.", +  "image": "https://upload.wikimedia.org/wikipedia/en/thumb/2/29/Doom_II_-_Hell_on_Earth_Coverart.png/220px-Doom_II_-_Hell_on_Earth_Coverart.png", +  "link": "https://rawg.io/games/doom-ii", +  "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 new file mode 100644 index 00000000..09f93563 --- /dev/null +++ b/bot/resources/evergreen/game_recs/skyrim.json @@ -0,0 +1,7 @@ +{ +  "title": "Elder Scrolls V: Skyrim", +  "description": "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.", +  "image": "https://upload.wikimedia.org/wikipedia/en/1/15/The_Elder_Scrolls_V_Skyrim_cover.png", +  "link": "https://rawg.io/games/the-elder-scrolls-v-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 new file mode 100644 index 00000000..835a4e53 --- /dev/null +++ b/bot/seasons/evergreen/recommend_game.py @@ -0,0 +1,51 @@ +import json +import logging +from pathlib import Path +from random import shuffle + +import discord +from discord.ext import commands + +log = logging.getLogger(__name__) +game_recs = [] + +# Populate the list `game_recs` with resource files +for rec_path in Path("bot/resources/evergreen/game_recs").glob("*.json"): +    with rec_path.open(encoding='utf-8') as file: +        data = json.load(file) +    game_recs.append(data) +shuffle(game_recs) + + +class RecommendGame(commands.Cog): +    """Commands related to recommending games.""" + +    def __init__(self, bot: commands.Bot) -> None: +        self.bot = bot +        self.index = 0 + +    @commands.command(name="recommendgame", aliases=['gamerec']) +    async def recommend_game(self, ctx: commands.Context) -> None: +        """Sends an Embed of a random game recommendation.""" +        if self.index >= len(game_recs): +            self.index = 0 +            shuffle(game_recs) +        game = game_recs[self.index] +        self.index += 1 + +        author = self.bot.get_user(int(game['author'])) + +        # Creating and formatting Embed +        embed = discord.Embed(color=discord.Colour.blue()) +        if author is not None: +            embed.set_author(name=author.name, icon_url=author.avatar_url) +        embed.set_image(url=game['image']) +        embed.add_field(name='Recommendation: ' + game['title'] + '\n' + game['link'], value=game['description']) + +        await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: +    """Loads the RecommendGame cog.""" +    bot.add_cog(RecommendGame(bot)) +    log.info("RecommendGame cog loaded") | 
