diff --git a/lib/help.py b/lib/help.py deleted file mode 100644 index 1d8cea4..0000000 --- a/lib/help.py +++ /dev/null @@ -1,7 +0,0 @@ -def get_help(): - help = """ - __**Help**__ \n - Prefix: $ - hello: get a hello back - """ - return(help) diff --git a/main.py b/main.py index 14ab595..688bbd5 100644 --- a/main.py +++ b/main.py @@ -15,44 +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.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}') - for guild in client.guilds: + for guild in bot.guilds: print(f'Connect to Server {guild.name} (id: {guild.id})') -@client.event -async def on_message(message): - 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)) - -@client.event -async def on_error(event, *args, **kwargs): - with open('err.log', 'a') as f: - if event == 'on_message': - f.write(f'Unhandled message: {args[0]}\n') - else: - raise +### 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) #keep_alive() -client.run(BOTDATA['token']) +bot.run(BOTDATA['token'])