init
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
||||||
7
bot.json
Normal file
7
bot.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"token": "your-token",
|
||||||
|
"name": "Template Bot",
|
||||||
|
"description": "Template for a Discord Bot",
|
||||||
|
"author": "Template",
|
||||||
|
"prefix": "$"
|
||||||
|
}
|
||||||
0
lib/__init__.py
Normal file
0
lib/__init__.py
Normal file
7
lib/help.py
Normal file
7
lib/help.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
def get_help():
|
||||||
|
help = """
|
||||||
|
__**Help**__ \n
|
||||||
|
Prefix: $
|
||||||
|
hello: get a hello back
|
||||||
|
"""
|
||||||
|
return(help)
|
||||||
15
lib/keep_alive.py
Normal file
15
lib/keep_alive.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from flask import Flask
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
|
app = Flask('')
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
return "Hello. I am alive!"
|
||||||
|
|
||||||
|
def run():
|
||||||
|
app.run(host='0.0.0.0',port=8080)
|
||||||
|
|
||||||
|
def keep_alive():
|
||||||
|
t = Thread(target=run)
|
||||||
|
t.start()
|
||||||
46
main.py
Normal file
46
main.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
####################
|
||||||
|
# == 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.json", 'r') as f:
|
||||||
|
BOTDATA = json.load(f)
|
||||||
|
|
||||||
|
## Run
|
||||||
|
@client.event
|
||||||
|
async def on_ready():
|
||||||
|
print('Logged in as {0.user}'.format(client))
|
||||||
|
|
||||||
|
@client.event
|
||||||
|
async def on_message(message):
|
||||||
|
if message.author == client.user:
|
||||||
|
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!')
|
||||||
|
|
||||||
|
keep_alive()
|
||||||
|
client.run(BOTDATA['token'])
|
||||||
Reference in New Issue
Block a user