Skip to content

Commit

Permalink
codebase: bot.py entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
seven7ty committed Aug 19, 2022
1 parent 6250f72 commit 21747bb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
!cogs
!resources
!lib
!bot.py
!launcher.py
!bot.py
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
worker: python launcher.py
worker: python bot.py
18 changes: 18 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# coding: utf-8

"""
GitBot - the developer toolkit for Discord
~~~~~~~~~~~~~~~~~~~
A developer toolkit for the Discord era, with a focus on sleek design and powerful features.
:copyright: (c) 2020-present statch
:license: CC BY-NC-ND 4.0, see LICENSE for more details.
"""

import discord
from os import getenv
from dotenv import load_dotenv
from discord.ext import commands
from lib.structs.discord.context import GitBotContext
from lib.structs.discord.bot import GitBot

# all of the configuration is handled inside the class, there is no real need to pass anything here
bot = GitBot()


Expand Down Expand Up @@ -56,3 +69,8 @@ async def global_check(ctx: GitBotContext) -> bool:
async def before_invoke(ctx: GitBotContext):
if str(ctx.command) not in bot.mgr.env.no_typing_commands:
await ctx.channel.typing()


if __name__ == '__main__':
load_dotenv()
bot.run(getenv('BOT_TOKEN'))
6 changes: 3 additions & 3 deletions cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def bot():
pass


@bot.command('start', help='Start the bot using launcher.py')
@bot.command('start', help='Start the bot using bot.py')
@click.option('--no-new-window',
is_flag=True, help='Don\'t start the bot in a new terminal window, even if possible', default=False)
def start(no_new_window: bool = False):
if sys.platform == 'win32' and not no_new_window:
subprocess.call(f'start {PYTHON_COMMAND_LINE} launcher.py', shell=True)
subprocess.call(f'start {PYTHON_COMMAND_LINE} bot.py', shell=True)
else:
subprocess.call([PYTHON_COMMAND_LINE, 'launcher.py'])
subprocess.call([PYTHON_COMMAND_LINE, 'bot.py'])


@cli.group('dev', help='Commands related to the development of the bot')
Expand Down
7 changes: 0 additions & 7 deletions launcher.py

This file was deleted.

0 comments on commit 21747bb

Please sign in to comment.