async def shutdown(ctx): """ Save SQL Data and turn off the bot :param ctx: :return: """ logging.warning('{} with id {} in server : {} has initiated bot shutdown!.'.format(ctx.author.name, ctx.author.id, ctx.guild.id)) await ctx.send(emb('Shutting Down....I will see you on the other side.')) session.commit() session.close() sys.exit()
async def set_prefix(ctx, message): """ Set the prefix for bot commands. :param ctx: :param message: :return: """ row = session.query(Guild).filter( Guild.id == ctx.guild.id).first() row.prefix = message session.commit() try: bot.master[ctx.guild.id]["prefix"] = message except Exception as e: bot.master[ctx.guild.id] = {} bot.master[ctx.guild.id]["prefix"] = message await ctx.send('```Bot Command Prefix set to : {}```'.format(message))
async def vendor(self, ctx, action=None, item=None, quant=None): """ Sell your items for cheap in the pawnshop :param ctx: :param action: :param item: :param quant: :return: """ character = Character(ctx.author, self) if item is None: await ctx.send( "```Welcome to the Pawn Shop!\nIf u would like to sell something, " "I can accept it at a reasonable price, (-50%-60% base price)\nSimple recite the magic words:\n" "+vendor sell/buy itemforsale quantity\n I also sell the basic necessities and things that come" " into my grasp```") elif action is None: await ctx.send( "```Err what are you saying bud. Are you trying to sell me something or buy something ? ," " my customers usually just say :\n +vendor sell/buy itemforsale quantity```" ) elif quant is None: await ctx.send("```Please enter a quantity mate```") else: quant = self.bot.input_sanitation(quant) if action == "sell": inv_item = await character.take_from_inv(id_item=item, quantity=quant) total_value = inv_item[0] * inv_item[1] - inv_item[ 0] * inv_item[1] * random.randint(50, 60) / 100 try: character.moolah += int(total_value) session.commit() await ctx.send("```You sold {} {} for {} M".format( quant, item, total_value)) except SQLAlchemyError as e: logg.error(e) session.rollback() elif action == "buy": await ctx.send( "Slow down young one! I am still setting up the shop." ) # TODO Implement a random rotating shop
async def profession(self, ctx, number=None): """ Select your profession or view profession. """ prof_list = [ None, "Miner", "Lumberjack", "Gatherer", "Smith", "Outfitter", "Chef" ] player = Character(ctx.author, self) if player.has_chosen: await ctx.send( "You have already embarked on the jounery to become a master {} , there is not turing back!" .format(player.profession)) elif number is None: await ctx.send( " __* **Gatherer Professions:** *__\n**[1] Miner**\n**[2] Lumberjack**\n**[3] Gatherer**\n__* **Crafting Professions** *__\n**[4] Smith**\n**[5] Outfitter**\n**[6] Chef**\n Choose Your Profession(1-6) , eg +profession 2 for Lumberjack" ) else: try: selection = int(number) except Exception as e: await ctx.send( 'Error enter a number for your profession !\n you went to the wrong selection exam..' ) selected_prof = prof_list[selection] try: player = Query(types="player", obj=ctx.author).get() player.profession = selected_prof session.commit() await ctx.send( 'You passed the selection exam ! You have selected {}, there is no turning back now !\n' .format(selected_prof)) except Exception as e: await ctx.send( 'Error in selecting profession! You are paralyzed with indecision' ) session.rollback()
async def reboot(ctx): logging.warning( '{} with id {} in server : {} has initiated bot Reboot!.'.format(ctx.author.name, ctx.author.id, ctx.guild.id)) session.commit() session.close() os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)