From cf412dc4bf1f6ae35f94e5f599373fbac8f42922 Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Wed, 28 Feb 2018 08:33:36 -0500 Subject: [PATCH] Created a mock discord bot for testing. --- .gitignore | 1 + discord_bot.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 discord_bot.py diff --git a/.gitignore b/.gitignore index 1997047..53204b9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__ scrython.egg-info dist tests +BotUtils.py diff --git a/discord_bot.py b/discord_bot.py new file mode 100644 index 0000000..6ff436d --- /dev/null +++ b/discord_bot.py @@ -0,0 +1,46 @@ +import discord, scrython, BotUtils, asyncio +from discord.ext import commands + +bot = commands.Bot(description='FetchBot', command_prefix="?") + +@bot.event +async def on_ready(): + print('Logged in as') + print(bot.user.name) + print(bot.user.id) + print('------') + +@bot.command() +async def mtg(name): + getCard = str(name) + + await asyncio.sleep(0.05) + card = scrython.cards.Named(loop=bot.loop, fuzzy=getCard) + + if card.type_line() == 'Creature': + PT = "({}/{})".format(card.power(), card.toughness()) + else: + PT = "" + + if card.cmc() == 0: + mana_cost = "" + else: + mana_cost = card.mana_cost() + + string = """ + {cardname} {mana_cost} + {type_line} {set_code} {rarity} + {oracle_text}{power_toughness} + """.format( + cardname=card.name(), + mana_cost=mana_cost, + type_line=card.type_line(), + set_code=card.set_code().upper(), + rarity=card.rarity(), + oracle_text=card.oracle_text(), + power_toughness=PT + ) + + await self.bot.say(string) + +bot.run(BotUtils.AUTH_TOKEN)