import json
import discord
from handlers.message_handler import MessageHandler


with open("config.json", "r") as f:
	config = json.load(f)
client = discord.Client()
message_handler = MessageHandler(config, client)


@client.event
async def on_ready():
	print("Logged in as", client.user.name)


@client.event
async def on_message(message):
	await message_handler.handle(message)


client.run(config["token"])


import argparse
import json
import discord
from handlers.message_handler import MessageHandler


def main():
	p = argparse.ArgumentParser()
	p.add_argument("--config", required=True, help="Path to configuration file")
	args = p.parse_args()

	with open(args.config, "r") as f:
		config = json.load(f)

	client = discord.Client()
	message_handler = MessageHandler(config, client)

	@client.event
	async def on_ready():
		print("Logged in as", client.user.name)

	@client.event
	async def on_message(message):
		await message_handler.handle(message)

	client.run(config["token"])


if __name__ == "__main__":
	main()

Add --config argument as a path to the config file
Add --config argument as a path to the config file

+ 
+ import argparse
  import json
  import discord
  from handlers.message_handler import MessageHandler
  
  
+ def main():
+ 	p = argparse.ArgumentParser()
+ 	p.add_argument("--config", required=True, help="Path to configuration file")
+ 	args = p.parse_args()
+ 
- with open("config.json", "r") as f:
+ 	with open(args.config, "r") as f:
- 	config = json.load(f)
+ 		config = json.load(f)
+ 
- client = discord.Client()
+ 	client = discord.Client()
- message_handler = MessageHandler(config, client)
+ 	message_handler = MessageHandler(config, client)
+ 
+ 	@client.event
+ 	async def on_ready():
+ 		print("Logged in as", client.user.name)
+ 
+ 	@client.event
+ 	async def on_message(message):
+ 		await message_handler.handle(message)
+ 
+ 	client.run(config["token"])
  
  
+ if __name__ == "__main__":
+ 	main()
- @client.event
- async def on_ready():
- 	print("Logged in as", client.user.name)
  
- 
- @client.event
- async def on_message(message):
- 	await message_handler.handle(message)
- 
- 
- client.run(config["token"])
- 
Add --config argument as a path to the config file
## Code Before:
import json
import discord
from handlers.message_handler import MessageHandler


with open("config.json", "r") as f:
	config = json.load(f)
client = discord.Client()
message_handler = MessageHandler(config, client)


@client.event
async def on_ready():
	print("Logged in as", client.user.name)


@client.event
async def on_message(message):
	await message_handler.handle(message)


client.run(config["token"])

## Instruction:
Add --config argument as a path to the config file
## Code After:

import argparse
import json
import discord
from handlers.message_handler import MessageHandler


def main():
	p = argparse.ArgumentParser()
	p.add_argument("--config", required=True, help="Path to configuration file")
	args = p.parse_args()

	with open(args.config, "r") as f:
		config = json.load(f)

	client = discord.Client()
	message_handler = MessageHandler(config, client)

	@client.event
	async def on_ready():
		print("Logged in as", client.user.name)

	@client.event
	async def on_message(message):
		await message_handler.handle(message)

	client.run(config["token"])


if __name__ == "__main__":
	main()
