mirror of
https://gitlab.com/MisterBiggs/multi-bot-tutorial.git
synced 2025-06-16 07:06:51 +00:00
first workable version of discord bot
This commit is contained in:
parent
f2fcc040fe
commit
8553f45ab5
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user