Skip to content
This repository was archived by the owner on Aug 28, 2021. It is now read-only.

Commit dd5d748

Browse files
committed
Optimization and better syntax
1 parent 13395dc commit dd5d748

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

bot.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import discord
2-
import json
2+
import json, os
33
from discord.ext import commands
44

5+
if not os.path.exists("config.json"):
6+
with open("config.json.example") as f:
7+
with open("config.json", "w") as w:
8+
w.write(f.read())
9+
510
with open('config.json') as f:
611
configData = json.load(f)
12+
f.close()
713

814
client = commands.Bot(command_prefix = configData['prefix'])
915

1016
@client.event
1117
async def on_ready():
12-
activity = discord.Game(name="PyCharm vs. Jupyter vs. Visual Studio Code", type=1)
18+
activity = discord.Game(name=configData["status"], type=1)
1319
await client.change_presence(status=discord.Status.online, activity=activity)
1420
print('Bot is ready')
1521

1622
@client.command()
17-
async def branch(ctx, arg):
23+
async def branch(ctx, arg = "develop"):
1824
await ctx.send(f'You can access the {arg} branch by running ``git checkout {arg}``')
1925

2026
@client.command()
21-
async def repo(ctx, arg):
27+
async def repo(ctx, arg = "main"):
2228
if (arg == 'main' or arg == 'mcpy'):
2329
await ctx.send('The github repo for McPy is located at https://github.com/mcpyproject/McPy')
2430
if (arg == 'bot'):
@@ -29,7 +35,7 @@ async def tryitandsee(ctx):
2935
await ctx.send("It's now time to https://tryitands.ee")
3036

3137
@client.command()
32-
async def install(ctx, arg):
38+
async def install(ctx, arg = "python"):
3339
if (arg == 'python3' or arg == 'python3.8' or arg == 'python'):
3440
await ctx.send('Python 3.8 can be installed by following the instructions at https://www.python.org/downloads/release/python-387/')
3541
if (arg == 'submodules' or arg == 'submodule'):

config.json.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"token": " --TOKEN HERE-- ",
3-
"prefix": "."
3+
"prefix": ".",
4+
"status": "The game of life"
45
}

0 commit comments

Comments
 (0)