Skip to content

Commit

Permalink
Merge pull request #24 from exmaple/i7-click
Browse files Browse the repository at this point in the history
Replace ArgParse with Click
  • Loading branch information
maxUser authored May 31, 2020
2 parents 5fdc46b + d5f3880 commit d0e4825
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 11 additions & 13 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import discord
from discord.ext import commands
from argparse import ArgumentParser
import os
import click


def load_extensions(bot, extensions):
Expand All @@ -19,13 +19,9 @@ def load_extensions(bot, extensions):
print(f"{error}")


if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
"--token", "-t", action="store", help="Token from the developer portal",
)
args = parser.parse_args()

@click.command()
@click.option("--token", default=None, help="Token from the developer portal")
def main(token):
bot = commands.Bot(command_prefix="!")

@bot.event
Expand All @@ -37,9 +33,11 @@ async def on_ready():
extensions = ["cogs.stats_commands"]
load_extensions(bot, extensions)

if args.token:
run_token = args.token
else:
run_token = os.environ["TOKEN"]
if not token:
token = os.environ["TOKEN"]

bot.run(f"{token}")

bot.run(f"{run_token}")

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
black==19.10b0
bs4==0.0.1
click==7.1.2
discord.py==1.3.1
requests==2.23.0

0 comments on commit d0e4825

Please sign in to comment.