add logging
This commit is contained in:
14
main.py
14
main.py
@@ -16,27 +16,39 @@
|
|||||||
|
|
||||||
## Imports
|
## Imports
|
||||||
import json
|
import json
|
||||||
|
import logging as log
|
||||||
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from lib.keep_alive import keep_alive
|
from lib.keep_alive import keep_alive
|
||||||
|
|
||||||
## Vars
|
## Vars
|
||||||
|
### Load and set Bot Config
|
||||||
with open("bot.conf", 'r') as f:
|
with open("bot.conf", 'r') as f:
|
||||||
BOTDATA = json.load(f)
|
BOTDATA = json.load(f)
|
||||||
bot = commands.Bot(command_prefix=BOTDATA['prefix'])
|
bot = commands.Bot(command_prefix=BOTDATA['prefix'])
|
||||||
|
|
||||||
|
### Set logging options
|
||||||
|
log.basicConfig(
|
||||||
|
filename="bot.log",
|
||||||
|
level=log.DEBUG,
|
||||||
|
format='%(asctime)s - %(process)d-%(levelname)s: %(message)s',
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
)
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
### Events
|
### Events
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
log.info(f'Logged in as {bot.user}')
|
||||||
print(f'Logged in as {bot.user}')
|
print(f'Logged in as {bot.user}')
|
||||||
|
|
||||||
for guild in bot.guilds:
|
for guild in bot.guilds:
|
||||||
print(f'Connect to Server {guild.name} (id: {guild.id})')
|
log.info(f'Connect to Server {guild.name} (id: {guild.id})')
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
@bot.command(name='hello', help='Say hello!')
|
@bot.command(name='hello', help='Say hello!')
|
||||||
async def say_hello(ctx):
|
async def say_hello(ctx):
|
||||||
|
print(f'{ctx}')
|
||||||
await ctx.send(f'Hello, <@{ctx.author.id}>!')
|
await ctx.send(f'Hello, <@{ctx.author.id}>!')
|
||||||
print(ctx.guild)
|
print(ctx.guild)
|
||||||
print(ctx.message.content)
|
print(ctx.message.content)
|
||||||
|
|||||||
Reference in New Issue
Block a user