Skip to content

Commit 21747bb

Browse files
author
Paul Przybyszewski
committed
codebase: bot.py entrypoint
1 parent 6250f72 commit 21747bb

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

.dockerignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
!cogs
44
!resources
55
!lib
6-
!bot.py
7-
!launcher.py
6+
!bot.py

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
worker: python launcher.py
1+
worker: python bot.py

bot.py

+18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
# coding: utf-8
2+
3+
"""
4+
GitBot - the developer toolkit for Discord
5+
~~~~~~~~~~~~~~~~~~~
6+
A developer toolkit for the Discord era, with a focus on sleek design and powerful features.
7+
:copyright: (c) 2020-present statch
8+
:license: CC BY-NC-ND 4.0, see LICENSE for more details.
9+
"""
10+
111
import discord
12+
from os import getenv
13+
from dotenv import load_dotenv
214
from discord.ext import commands
315
from lib.structs.discord.context import GitBotContext
416
from lib.structs.discord.bot import GitBot
517

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

821

@@ -56,3 +69,8 @@ async def global_check(ctx: GitBotContext) -> bool:
5669
async def before_invoke(ctx: GitBotContext):
5770
if str(ctx.command) not in bot.mgr.env.no_typing_commands:
5871
await ctx.channel.typing()
72+
73+
74+
if __name__ == '__main__':
75+
load_dotenv()
76+
bot.run(getenv('BOT_TOKEN'))

cli/main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ def bot():
1616
pass
1717

1818

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

2828

2929
@cli.group('dev', help='Commands related to the development of the bot')

launcher.py

-7
This file was deleted.

0 commit comments

Comments
 (0)