Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core #8

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ ENV/
# mypy
.mypy_cache/
.idea
/config.json
24 changes: 24 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Awesomebot entry point
Mike Tung (seekheart)
"""

import discord
import asyncio
from settings import CREDS, PREFIX, logger



def init_bot():
"""Creates a discord client connection"""
return discord.Client()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using the discord.bot.ext frameworks? Also this feels like an unpythonic function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what that is

client = init_bot()

@client.event
async def on_ready():
"""Logs the bot in for operations"""
print('logged in as {}'.format(client.user.name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We said we'd support 3.6+, yeah? Should use f-strings where we can then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never used them, can you clone and make the changes? I would like to see.


if __name__ == '__main__':
client.run(CREDS['token'])
6 changes: 6 additions & 0 deletions example_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"clientId": 123,
"clientSecret": "abc",
"botPrefix": "ab",
"token": "TOKEN"
}
35 changes: 35 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Awesome Bot Settings
Mike Tung (seekheart)
"""

import json
import logging
import os


# setup logger format
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)


# setup configurations
ENV = os.environ.get('ENV', 'DEV')
CONFIG = os.environ.get('BOT_CONFIG', None)
CREDS = {}
with open(CONFIG, 'r') as c:
c = json.load(c)
CREDS['id'] = c['clientId']
CREDS['secret'] = c['clientSecret']
CREDS['token'] = c['token']
PREFIX = c['botPrefix']

if ENV == 'PROD':
logger.setLevel(logging.INFO)
else:
logger.setLevel(logging.DEBUG)