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__/
|
||||
bot.conf
|
||||
*.log
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"token": "your-token",
|
||||
"token": "OTExNTkwODQxMTgzNzY0NTMx.YZjnIQ.wsu4-3qnBJF2gI-9ZIV74SinBnw",
|
||||
"name": "Template Bot",
|
||||
"description": "Template for a Discord Bot",
|
||||
"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
|
||||
import discord
|
||||
import json
|
||||
|
||||
from discord.ext import commands
|
||||
from lib.keep_alive import keep_alive
|
||||
from lib.help import *
|
||||
|
||||
## Vars
|
||||
client = discord.Client()
|
||||
with open("bot.json", 'r') as f:
|
||||
with open("bot.conf", 'r') as f:
|
||||
BOTDATA = json.load(f)
|
||||
bot = commands.Bot(command_prefix=BOTDATA['prefix'])
|
||||
|
||||
## Run
|
||||
@client.event
|
||||
### Events
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print('Logged in as {0.user}'.format(client))
|
||||
print(f'Logged in as {bot.user}')
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
if message.author == client.user:
|
||||
return
|
||||
for guild in bot.guilds:
|
||||
print(f'Connect to Server {guild.name} (id: {guild.id})')
|
||||
|
||||
if message.content.startswith(BOTDATA['prefix'] + 'help'):
|
||||
help = get_help()
|
||||
await message.channel.send(help)
|
||||
### Commands
|
||||
@bot.command(name='hello', help='Say hello!')
|
||||
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'):
|
||||
await message.channel.send('Hello!')
|
||||
|
||||
keep_alive()
|
||||
client.run(BOTDATA['token'])
|
||||
#keep_alive()
|
||||
bot.run(BOTDATA['token'])
|
||||
|
||||
Reference in New Issue
Block a user