2019-04-15 09:12:56 -07:00
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... \n Use `.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 ) :
2019-04-15 09:21:36 -07:00
if rpg_utils . playerexists ( ctx . author ) :
2019-04-15 09:12:56 -07:00
2019-04-15 09:21:36 -07:00
player = rpg_utils . getplayer ( ctx . author )
2019-04-15 09:12:56 -07:00
2019-04-15 09:21:36 -07:00
if player . _can_change_class :
2019-04-15 09:12:56 -07:00
2019-04-15 09:29:52 -07:00
if number . isdigit ( ) and int ( number ) < = len ( rpg_utils . classes ) and int ( number ) > = 1 :
2019-04-15 09:12:56 -07:00
2019-04-15 09:21:36 -07:00
player . _can_change_class = False
2019-04-15 09:12:56 -07:00
2019-04-15 09:23:56 -07:00
player . _class = rpg_utils . classes [ int ( number ) - 1 ]
2019-04-15 09:12:56 -07:00
2019-04-15 09:27:03 -07:00
await ctx . send ( " Successfully set your class to ** " + player . _class + " .** " )
2019-04-15 09:21:36 -07:00
else :
2019-04-15 09:29:21 -07:00
await ctx . send ( " Invalid arguments! Try providing a number from 1- " + str ( len ( rpg_utils . classes ) ) + " . " )
2019-04-15 09:12:56 -07:00
else :
2019-04-15 09:27:03 -07:00
await ctx . send ( " You can ' t change your class right now. \n Current class: " + player . _class )
2019-04-15 09:21:36 -07:00
2019-04-15 09:12:56 -07:00
else :
2019-04-15 09:21:36 -07:00
2019-04-15 09:27:03 -07:00
await ctx . send ( " You haven ' t begun your journey yet. Use `.rpg begin` to get started! " )
2019-04-15 09:12:56 -07:00
2019-04-15 09:15:26 -07:00
token = " "
2019-04-15 09:12:56 -07:00
2019-04-15 09:15:26 -07:00
with open ( " token.cfg " ) as f :
2019-04-15 09:17:17 -07:00
token = f . readlines ( ) [ 0 ]
2019-04-15 09:15:26 -07:00
bot . run ( token )
2019-04-15 09:12:56 -07:00