Got discord.py to work with scrython.

This commit is contained in:
2018-02-28 21:04:45 -05:00
parent f14dc616af
commit ab96f0fa23
2 changed files with 12 additions and 6 deletions

View File

@ -28,9 +28,9 @@ async def mtg(name):
mana_cost = card.mana_cost()
string = """
{cardname} {mana_cost}
{type_line} {set_code} {rarity}
{oracle_text}{power_toughness}
{cardname} {mana_cost}
{type_line} {set_code} {rarity}
{oracle_text}{power_toughness}
""".format(
cardname=card.name(),
mana_cost=mana_cost,
@ -41,6 +41,6 @@ async def mtg(name):
power_toughness=PT
)
await self.bot.say(string)
await bot.say(string)
bot.run(BotUtils.AUTH_TOKEN)

View File

@ -1,6 +1,7 @@
import aiohttp
import asyncio
import urllib.parse
from threading import Thread
class CardsObject(object):
"""
@ -90,9 +91,14 @@ class CardsObject(object):
async with aiohttp.ClientSession(loop=loop) as client:
self.scryfallJson = await getRequest(client, self._url)
loop = asyncio.get_event_loop()
def do_everything():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop))
t = Thread(target=do_everything)
t.run()
if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details'])