2018-03-01 02:20:41 +00:00
|
|
|
# Before running you need to provide a token to run.
|
|
|
|
# For safety it's reccommended that you save the token as a variable
|
|
|
|
# in another file; in this case BotUtils.py
|
|
|
|
|
2018-02-28 13:33:36 +00:00
|
|
|
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()
|
2018-03-01 02:10:53 +00:00
|
|
|
async def mtg(*, name):
|
2018-02-28 13:33:36 +00:00
|
|
|
getCard = str(name)
|
|
|
|
|
|
|
|
await asyncio.sleep(0.05)
|
2018-02-28 23:23:33 +00:00
|
|
|
card = scrython.cards.Named(fuzzy=getCard)
|
2018-02-28 13:33:36 +00:00
|
|
|
|
|
|
|
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 = """
|
2018-03-01 02:04:45 +00:00
|
|
|
{cardname} {mana_cost}
|
|
|
|
{type_line} {set_code} {rarity}
|
|
|
|
{oracle_text}{power_toughness}
|
2018-02-28 13:33:36 +00:00
|
|
|
""".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
|
|
|
|
)
|
|
|
|
|
2018-03-01 02:04:45 +00:00
|
|
|
await bot.say(string)
|
2018-02-28 13:33:36 +00:00
|
|
|
|
|
|
|
bot.run(BotUtils.AUTH_TOKEN)
|