Files
bot-discord/main.py

57 lines
1.2 KiB
Python

####################
# == Main Info ==
# main.py
# by 4nima
# v.0.0.0
#
####################
# == Descrtiption ==
# template for discord bot
#
####################
# == Dependencies ==
# pip3 install discord
# pip3 install flask (for keep_alive)
####################
## Imports
import discord
import json
from lib.keep_alive import keep_alive
from lib.help import *
## Vars
client = discord.Client()
with open("bot.conf", 'r') as f:
BOTDATA = json.load(f)
## Run
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
for guild in client.guilds:
print(f'Connect to Server {guild.name} (id: {guild.id})')
@client.event
async def on_message(message):
#if message.author == client.user:
# return
if message.author.bot:
return
if message.content.startswith(BOTDATA['prefix'] + 'help'):
help = get_help()
await message.channel.send(help)
if message.content.startswith(BOTDATA['prefix'] + 'hello'):
await message.channel.send("Hello, {}!".format(message.author))
if 'happy birthday' in message.content.lower():
await message.channel.send('Happy Birthday! 🎈🎉')
#keep_alive()
client.run(BOTDATA['token'])