diff options
author | 2021-02-16 10:48:13 -0800 | |
---|---|---|
committer | 2021-02-16 10:48:13 -0800 | |
commit | 06d600f0fd927e566d23879638d10c6d66a63a21 (patch) | |
tree | b7791f6c7f42e2aa3fd9a0c85111df8861b87546 /bot/exts/evergreen/pythonfacts.py | |
parent | Merge branch 'master' of https://github.com/MrKomodoDragon/sir-lancebot (diff) |
Move loading of file outside of command
Diffstat (limited to 'bot/exts/evergreen/pythonfacts.py')
-rw-r--r-- | bot/exts/evergreen/pythonfacts.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/exts/evergreen/pythonfacts.py b/bot/exts/evergreen/pythonfacts.py index b1c28d4b..c6592add 100644 --- a/bot/exts/evergreen/pythonfacts.py +++ b/bot/exts/evergreen/pythonfacts.py @@ -4,6 +4,10 @@ import discord from discord.ext import commands +with open('bot/resources/evergreen/python_facts.txt') as file: + FACTS = list(file) + + class PythonFacts(commands.Cog): """Gives a random fun fact about Python.""" @@ -13,8 +17,7 @@ class PythonFacts(commands.Cog): @commands.command(name='pythonfact', aliases=['pyfact']) async def get_python_fact(self, ctx: commands.Context) -> None: """Gives a Random fun fact about Python.""" - with open('bot/resources/evergreen/python_facts.txt') as file: - await ctx.send(embed=discord.Embed(title='Python Facts', description=f'**{random.choice(list(file))}**')) + await ctx.send(embed=discord.Embed(title='Python Facts', description=f'**{random.choice(FACTS)}**')) def setup(bot: commands.Bot) -> None: |