Got discord.py to work with scrython.
This commit is contained in:
parent
f14dc616af
commit
ab96f0fa23
|
@ -28,9 +28,9 @@ async def mtg(name):
|
||||||
mana_cost = card.mana_cost()
|
mana_cost = card.mana_cost()
|
||||||
|
|
||||||
string = """
|
string = """
|
||||||
{cardname} {mana_cost}
|
{cardname} {mana_cost}
|
||||||
{type_line} {set_code} {rarity}
|
{type_line} {set_code} {rarity}
|
||||||
{oracle_text}{power_toughness}
|
{oracle_text}{power_toughness}
|
||||||
""".format(
|
""".format(
|
||||||
cardname=card.name(),
|
cardname=card.name(),
|
||||||
mana_cost=mana_cost,
|
mana_cost=mana_cost,
|
||||||
|
@ -41,6 +41,6 @@ async def mtg(name):
|
||||||
power_toughness=PT
|
power_toughness=PT
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.bot.say(string)
|
await bot.say(string)
|
||||||
|
|
||||||
bot.run(BotUtils.AUTH_TOKEN)
|
bot.run(BotUtils.AUTH_TOKEN)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
class CardsObject(object):
|
class CardsObject(object):
|
||||||
"""
|
"""
|
||||||
|
@ -90,8 +91,13 @@ class CardsObject(object):
|
||||||
async with aiohttp.ClientSession(loop=loop) as client:
|
async with aiohttp.ClientSession(loop=loop) as client:
|
||||||
self.scryfallJson = await getRequest(client, self._url)
|
self.scryfallJson = await getRequest(client, self._url)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
def do_everything():
|
||||||
loop.run_until_complete(main(loop))
|
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':
|
if self.scryfallJson['object'] == 'error':
|
||||||
raise Exception(self.scryfallJson['details'])
|
raise Exception(self.scryfallJson['details'])
|
||||||
|
|
Loading…
Reference in New Issue