mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Merge pull request #6389 from Deinara/discord_connect_fix
Discord connect fix
This commit is contained in:
commit
780cdd5f90
@ -42,11 +42,14 @@ class DiscordNotificationService(BaseNotificationService):
|
|||||||
import discord
|
import discord
|
||||||
discord_bot = discord.Client(loop=self.hass.loop)
|
discord_bot = discord.Client(loop=self.hass.loop)
|
||||||
|
|
||||||
yield from discord_bot.login(self.token)
|
@discord_bot.event
|
||||||
|
@asyncio.coroutine
|
||||||
|
def on_ready(): # pylint: disable=unused-variable
|
||||||
|
"""Send the messages when the bot is ready."""
|
||||||
|
for channelid in kwargs[ATTR_TARGET]:
|
||||||
|
channel = discord.Object(id=channelid)
|
||||||
|
yield from discord_bot.send_message(channel, message)
|
||||||
|
yield from discord_bot.logout()
|
||||||
|
yield from discord_bot.close()
|
||||||
|
|
||||||
for channelid in kwargs[ATTR_TARGET]:
|
yield from discord_bot.start(self.token)
|
||||||
channel = discord.Object(id=channelid)
|
|
||||||
yield from discord_bot.send_message(channel, message)
|
|
||||||
|
|
||||||
yield from discord_bot.logout()
|
|
||||||
yield from discord_bot.close()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user