Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions homeassistant/components/notify/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ def async_send_message(self, message, **kwargs):
import discord
discord_bot = discord.Client(loop=self.hass.loop)

yield from discord_bot.login(self.token)

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()
@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()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is close not needed anymore?

yield from discord_bot.close()

yield from discord_bot.start(self.token)