diff --git a/.vscode/settings.json b/.vscode/settings.json index 8f81310..adf7e3a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,3 @@ { - "python.pythonPath": "venv/bin/python", - "python.linting.pylintEnabled": false, - "python.linting.pep8Enabled": true, - "python.linting.enabled": true -} + "python.pythonPath": "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3" +} \ No newline at end of file diff --git a/bot.py b/bot.py index 24a2601..6e97bc8 100644 --- a/bot.py +++ b/bot.py @@ -4,7 +4,7 @@ import discord from discord.ext import commands -from modules import xkcd +from modules import xkcd, coin TOKEN = os.getenv('DISCORD_BOT_API_TOKEN') bot = commands.Bot(command_prefix='$', description='Just A Rather Very Intelligent System, now on Discord!') @@ -56,4 +56,20 @@ async def search_image(ctx, search_arg): print(e) await ctx.send("Sorry, something went wrong.") + +@bot.command( + name="coin", + description="Flip a coin game", + brief="flip a coin and send head to tails", +) +async def flip_coin(ctx): + try: + embed = coin.coinToss() + await ctx.send(embed=embed) + + except Exception as e: + print(e) + await ctx.send("Sorry, something went wrong.") + + bot.run(TOKEN) diff --git a/modules/coin.py b/modules/coin.py new file mode 100644 index 0000000..fe03478 --- /dev/null +++ b/modules/coin.py @@ -0,0 +1,33 @@ +import random +import discord + +head_image_url = "https://urlzs.com/Wi46z" +tail_image_url = "https://urlzs.com/UXXyP" + + +def cointoss(number): + flips = [random.randint(0, 1) for r in range(1)] + results = [] + for object in flips: + if object == 0: + results.append("Heads") + elif object == 1: + results.append("Tails") + + return results + + +def coinToss(): + result = cointoss(1)[0] + + if result == "Heads": + + rembed = discord.Embed( + title=result, type="rich", image=head_image_url + ).set_image(url=head_image_url) + else: + rembed = discord.Embed( + title=result, type="rich", image=tail_image_url + ).set_image(url=tail_image_url) + + return rembed diff --git a/modules/image.py b/modules/image.py index b02b646..e1ec6a9 100644 --- a/modules/image.py +++ b/modules/image.py @@ -2,6 +2,7 @@ import aiohttp import os + # Searches for a image related to the search arg async def process(search_arg): diff --git a/requirements.txt b/requirements.txt index 1e2b7e3..3e708e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ discord.py==1.1.1 idna==2.8 more-itertools==7.0.0 multidict==4.5.2 -pep8==1.7.1 +pycodestyle==2.5.0 pluggy==0.11.0 py==1.8.0 pytest==4.5.0 diff --git a/tests/test_pep8.py b/tests/test_pep8.py index 42d650b..c7a52ef 100644 --- a/tests/test_pep8.py +++ b/tests/test_pep8.py @@ -1,13 +1,13 @@ import os import unittest -import pep8 +import pycodestyle class TestCodeFormat(unittest.TestCase): def test_pep8_conformance(self): """Test that we conform to PEP8. checks all project files""" errors = 0 - style = pep8.StyleGuide(quiet=False) + style = pycodestyle.StyleGuide(quiet=False) style.options.max_line_length = 120 for root, dirs, files in os.walk('.'): python_files = [os.path.join(root, f) for f in files if f.endswith(".py")]