Example Scripts
Basic Start
import dlight
from dlight import events
import time
async def on_message(message): #when a message is sent
if message.author_isbot: #we dont want the bot to reply to itself or other bots
return
if message.content.startswith("!ping"):
await dlight.action.send("pong", message.channel,"footer")
if message.content.startswith("!nametag"):
await dlight.action.send(message.author_nametag, message.channel,"footer")
if message.content.startswith("!username"):
await dlight.action.send(message.author_username, message.channel,"footer")
async def on_connect(): #when the client connects to the API
print('Bot online')
async def on_client_error(error): #when the code in the client gives an error
print(error)
async def on_dlight_error(error): #when dlight returns and error
print(error)
events.on_message = on_message
events.on_connect = on_connect
events.on_client_error = on_client_error
events.on_dlight_error = on_dlight_error
dlight.run("token")
Last updated