ArchRPG/rpg_main.py

52 lines
1.5 KiB
Python

import rpg_utils
from discord.ext import commands
bot = commands.Bot(command_prefix = '.rpg ')
@bot.command()
async def begin(ctx):
if rpg_utils.playerexists(ctx.author):
await ctx.send("You've already begun your journey!")
else:
rpg_utils.addplayer(ctx.author)
await ctx.send("And so it begins...\nUse `.rpg class <1-" + str(len(rpg_utils.classes)) + ">` to select a player class from the following list:\n`" + ", ".join(rpg_utils.classes) + "`")
@bot.command(name = 'class')
async def _class(ctx, number):
if rpg_utils.playerexists(ctx.author):
player = rpg_utils.getplayer(ctx.author)
if player._can_change_class:
if number.isdigit() and int(number) <= len(rpg_utils.classes) and int(number) >= 1:
player._can_change_class = False
player._class = rpg_utils.classes[int(number)-1]
await ctx.send("Successfully set your class to **" + player._class + ".**")
else:
await ctx.send("Invalid arguments! Try providing a number from 1-"+str(len(rpg_utils.classes))+".")
else:
await ctx.send("You can't change your class right now.\nCurrent class: " + player._class)
else:
await ctx.send("You haven't begun your journey yet. Use `.rpg begin` to get started!")
token = ""
with open("token.cfg") as f:
token = f.readlines()[0]
bot.run(token)