Compare commits
10 Commits
9c902769f6
...
8864543129
| Author | SHA1 | Date | |
|---|---|---|---|
| 8864543129 | |||
| e9730cbf2f | |||
| 3434c0171e | |||
| 46c168391b | |||
| 77767a9fb4 | |||
| 24e35a2b91 | |||
| 43b6aa067c | |||
| c5e69d7b15 | |||
| 95603a3907 | |||
| 8343e0cde2 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
bot.conf
|
||||||
|
*.log
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"token": "your-token",
|
"token": "OTExNTkwODQxMTgzNzY0NTMx.YZjnIQ.wsu4-3qnBJF2gI-9ZIV74SinBnw",
|
||||||
"name": "Template Bot",
|
"name": "Template Bot",
|
||||||
"description": "Template for a Discord Bot",
|
"description": "Template for a Discord Bot",
|
||||||
"author": "Template",
|
"author": "Template",
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
def get_help():
|
|
||||||
help = """
|
|
||||||
__**Help**__ \n
|
|
||||||
Prefix: $
|
|
||||||
hello: get a hello back
|
|
||||||
"""
|
|
||||||
return(help)
|
|
||||||
37
main.py
37
main.py
@@ -15,32 +15,33 @@
|
|||||||
####################
|
####################
|
||||||
|
|
||||||
## Imports
|
## Imports
|
||||||
import discord
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from discord.ext import commands
|
||||||
from lib.keep_alive import keep_alive
|
from lib.keep_alive import keep_alive
|
||||||
from lib.help import *
|
|
||||||
|
|
||||||
## Vars
|
## Vars
|
||||||
client = discord.Client()
|
with open("bot.conf", 'r') as f:
|
||||||
with open("bot.json", 'r') as f:
|
|
||||||
BOTDATA = json.load(f)
|
BOTDATA = json.load(f)
|
||||||
|
bot = commands.Bot(command_prefix=BOTDATA['prefix'])
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
@client.event
|
### Events
|
||||||
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print('Logged in as {0.user}'.format(client))
|
print(f'Logged in as {bot.user}')
|
||||||
|
|
||||||
@client.event
|
for guild in bot.guilds:
|
||||||
async def on_message(message):
|
print(f'Connect to Server {guild.name} (id: {guild.id})')
|
||||||
if message.author == client.user:
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.content.startswith(BOTDATA['prefix'] + 'help'):
|
### Commands
|
||||||
help = get_help()
|
@bot.command(name='hello', help='Say hello!')
|
||||||
await message.channel.send(help)
|
async def say_hello(ctx):
|
||||||
|
await ctx.send(f'Hello, <@{ctx.author.id}>!')
|
||||||
|
print(ctx.guild)
|
||||||
|
print(ctx.message.content)
|
||||||
|
print(ctx.message)
|
||||||
|
print(ctx.author)
|
||||||
|
|
||||||
if message.content.startswith(BOTDATA['prefix'] + 'hello'):
|
#keep_alive()
|
||||||
await message.channel.send('Hello!')
|
bot.run(BOTDATA['token'])
|
||||||
|
|
||||||
keep_alive()
|
|
||||||
client.run(BOTDATA['token'])
|
|
||||||
|
|||||||
Reference in New Issue
Block a user