From 8553f45ab504a0bce462c0ba9d702aeb31372fc4 Mon Sep 17 00:00:00 2001 From: Anson Date: Thu, 11 Jul 2019 22:15:15 -0700 Subject: [PATCH] first workable version of discord bot --- discordBot.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/discordBot.py b/discordBot.py index 37dcb67..dd4f9ad 100644 --- a/discordBot.py +++ b/discordBot.py @@ -1,4 +1,5 @@ import discord +from functions import nextLaunch client = discord.Client() @@ -10,11 +11,23 @@ async def on_ready(): @client.event async def on_message(message): + + # Prevent bot from replying to itself if message.author == client.user: return - if message.content.startswith("$hello"): - await message.channel.send("Hello!") + if message.content.startswith("/launch"): + launch = nextLaunch() + embed = discord.Embed( + title=f"Mission: {launch['mission']}", + description=f"Rocket: {launch['rocket']}", + color=0x069AD2, + ) + embed.add_field(name="Launch Date", value=launch["date"], inline=False) + embed.add_field( + name="Countdown to Launch", value=launch["countdown"], inline=False + ) + await message.channel.say(embed=embed) client.run("your token here")