Esempio n. 1
0
 async def stats(self, ctx, user: str):
     """Gets the basic stats of an user"""
     message = ctx.message
     api = get_api()
     tmp = await self.client.send_message(
         message.channel, embed=get_embed(title='Searching...'))
     try:
         m = api.matches({"update": True, "filter[playerNames]": user})
     except:
         await self.client.edit_message(
             tmp, embed=get_embed(title='No such player: {}.'.format(user)))
         return
     for i in m[0].rosters:
         for j in i.participants:
             if j.player.name == user:
                 if int(j.stats['karmaLevel']) == 1:
                     karma = 'Good Karma.'
                 else:
                     karma = 'Great Karma.'
                 await self.client.edit_message(
                     tmp,
                     embed=get_embed(
                         title="Player: {}".format(user),
                         txt='''\n\nWins: {wins}.\nLevel: {level}.
                                                                    Win Streak: {winStreak}.\nLose Streak: {lossStreak}.\nKarma: {karma}.'''
                         .format(karma=karma, **j.stats, **j.player.stats)))
Esempio n. 2
0
 async def take(self, ctx, amount: int, user: discord.User = None):
     """Bot owner only commnad, take money from a user"""
     if not user: user = ctx.message.author
     if int(amount) < 0: take_all = True
     else: take_all = False
     message = ctx.message
     try:
         self.modify(user, amount * -1, take_all=take_all)
     except OSError as e:
         print(e.args[0])
         return
     except TypeError as e:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="You don't have enough {}{}.".format(
                 self.cur_p, self.cur_i)))
         return
     if amount == 1:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} lost 1 {}{}.".format(
                 user.name, self.cur_s, self.cur_i)))
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} lost {} {}{}.".format(
                 user.name, amount, self.cur_p, self.cur_i)))
Esempio n. 3
0
    async def give(self, ctx, amount: int, user: discord.User = None):
        """not bot owner only command, give money to a user"""
        if not user: user = ctx.message.author
        message = ctx.message

        try:
            self.modify(message.author, amount * -1)
        except OSError as e:
            print(e.args[0])
            return
        except TypeError as e:
            await self.client.send_message(
                message.channel,
                embed=get_embed(title="You don't have enough {}{}.".format(
                    self.cur_p, self.cur_i)))
            return

        try:
            self.modify(user, int(amount))
        except OSError as e:
            print(e.args[0])
            return
        if amount == 1:
            await self.client.send_message(
                message.channel,
                embed=get_embed(title="{} give {} 1 {}{}.".format(
                    message.author, user.name, self.cur_s, self.cur_i)))
        else:
            await self.client.send_message(
                message.channel,
                embed=get_embed(title="{} give {} {} {}{}.".format(
                    message.author, user.name, amount, self.cur_p,
                    self.cur_i)))
Esempio n. 4
0
 async def random(self, ctx, user: str):
     """Gets a random match results of a user"""
     message = ctx.message
     api = get_api()
     try:
         m = api.matches({"update": True, "filter[playerNames]": user})
     except:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title='No such player: {}.'.format(user)))
         return
     match = m[0]
     for i in match.rosters:
         for j in i.participants:
             if j.player.name == user:
                 if j.stats['wentAfk']:
                     afk = 'yes'
                 else:
                     afk = 'no'
                 if j.stats['winner'] == 'True':
                     win = "victory"
                 else:
                     win = 'lost'
                 items = ", ".join(j.stats.pop('items'))
                 print(match.stats)
                 await self.client.send_message(
                     message.channel,
                     embed=get_embed(
                         title=
                         'Random Game(Casual/Ranked) Results for Player: {}'
                         .format(user),
                         txt=
                         '''\n\nHero: {hero}.\nSkin: {skinKey}.\nKDA: {kills}/{deaths}/{assists}.\nMinion Farm: {minionKills}.\nKrakens Captured: {krakenCaptures}.
                                 \nCrystal Mines Captured: {crystalMineCaptures}.\nGold Mines Captured: {goldMineCaptures}.\nTurrets Destroyed: {turretCaptures}.
                                 \nAfk: {afk}.\nResult: {endGameReason}.\nQueue: {queue}.\nMatch Duration: {duration:.2f} Minutes.\nGame Played on: {createdAt}.
                                 \nFinal Items Build: {items}.'''.format(
                             hero=pretty(j.actor),
                             afk=afk,
                             items=items,
                             duration=int(match.duration) / 60,
                             **match.stats,
                             **j.stats)))
     title = "Match Comp:"
     text = ""
     for team in range(2):
         text += '\nTeam %i:\n' % (team + 1)
         for player in range(3):
             name = match.rosters[team].participants[player].player.name
             hero = pretty(match.rosters[team].participants[player].actor)
             kills = match.rosters[team].participants[player].stats["kills"]
             deaths = match.rosters[team].participants[player].stats[
                 "deaths"]
             assists = match.rosters[team].participants[player].stats[
                 "assists"]
             text += "Player: {}, Hero: {}  {}/{}/{}\n".format(
                 name, hero, kills, deaths, assists)
     await self.client.send_message(message.channel,
                                    embed=get_embed(title=title, txt=text))
Esempio n. 5
0
 async def hit(self, ctx):
     message = ctx.message
     if not self.in_game:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='No Game is in session, please start a game'))
         return
     if message.author != self.started_by:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='You did not start this game, please wait.'))
         return
     new = self.current_game.play('hit')
     await self.client.send_message(
         message.channel,
         embed=get_embed(title='You got hit with:',
                         txt='\n{}\n'.format(new.replace('_', ' '))))
     result = self.current_game.check_over()
     cards = ", ".join(self.current_game.player_deck)
     cards = cards.replace('_', ' ')
     try:
         if 'busts' in result:
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(title='Your are busted! with %s total: ' %
                                 result.split(' ')[1],
                                 txt='\n{}\n'.format(cards)))
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You lost {}'.format(int(self.game_bet))))
             self.in_game = False
             self.current_game = None
             return
         elif result == 'blackjack':
             await self.client.send_message(message.channel,
                                            embed=get_embed(
                                                title='Blackjack!',
                                                txt='\n{}\n'.format(cards)))
             try:
                 self.modify(message.author, int(self.game_bet * 2.5))
             except OSError as e:
                 print(e.args[0])
                 return
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You won {}'.format(int(self.game_bet * 1.5))))
             self.in_game = False
             self.current_game = None
             return
     except:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title='Your cards are: ',
                             txt='\n{} with {} total\n'.format(
                                 cards, result)))
         self.player_max = result
Esempio n. 6
0
 async def userstats(self, ctx, user: str, region: str):
     """Gets a better and more complete stats of an user tracked from Feb 1"""
     message = ctx.message
     tmp = await self.client.send_message(
         message.channel, embed=get_embed(title='Searching...'))
     try:
         response = get_response(user, region)
     except urllib.error.HTTPError as weberror:
         if weberror.code == 500:
             await self.client.edit_message(
                 tmp,
                 embed=get_embed(title='No such player: {}.'.format(user)))
         else:
             await self.client.edit_message(
                 tmp,
                 embed=get_embed(
                     title=
                     'Cannot connect to vain.gg server. Use *random instead.'
                 ))
         return
     except ValueError:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title=
                 'Not a valid region. Valid regions are: na, sea, sa, ea, eu.'
             ))
         return
     response.pop('latestMatches')
     response.pop('roleData')
     favHero = ", ".join([
         he['championDto']['cleanName'] for he in response['championData']
     ])
     st = response['lifetimeStatistics']
     TR = st['totalRankedGamesPlayedInSeconds'] / 60
     TC = st['totalCasualGamesPlayedInSeconds'] / 60
     TP = st['totalTimePlayedInSeconds'] / 60
     txt = """Name: {name}.\nRegion: {region}.\nWins: {wins}.\nLosses: {losses}.\nWinStreak: {winStreak}.\nLossStreak: {lossStreak}.\nWinRate: {winRate}%.\nLifetimeGold: Too Much to Count.
             \nTotalCasualGamesWon: {totalCasualGamesWon}/{totalCasualGames}.\nTotalRankedGamesWon: {totalRankedGamesWon}/{totalRankedGames}.\nTotalGamesWon: {totalGamesWon}/{totalGames}.
             \nTotalRankedGamesPlayed: {totalRankedGamesPlayed:.2f} mins.\nTotalCasualGamesPlayed: {totalCasualGamesPlayed:.2f} mins.\nTotalTimePlayed: {totalTimePlayed:.2f} mins.
             \nFavorite Heros: {favHero}.\n""".format(
         favHero=favHero,
         totalRankedGamesPlayed=TR,
         totalCasualGamesPlayed=TC,
         totalTimePlayed=TP,
         **response,
         **response['lifetimeStatistics'])
     await self.client.send_message(
         message.channel,
         embed=get_embed(title='Statistics from Jan 27nd for: ', txt=txt))
Esempio n. 7
0
 async def money(self, ctx, user: discord.User = None):
     """Check a user's money"""
     message = ctx.message
     if not user: user = ctx.message.author
     amount = self.modify(user, get_amount=True)
     if not amount:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} has 0 {}{}.".format(
                 user.name, self.cur_s, self.cur_i)))
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} has {} {}{}.".format(
                 user.name, amount, self.cur_p, self.cur_i)))
Esempio n. 8
0
 async def bet(self, ctx, amount: int, side: int):
     """Guess the value of the 12 sided dice, guess it right, you win 10 times your bet"""
     message = ctx.message
     user = message.author
     if side not in range(1, 13):
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="Side not valid, valid sides are: 1-12"))
         return
     elif amount < 3:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="Cannot bet less than 10"))
         return
     try:
         self.modify(user, int(amount * -1))
     except OSError as e:
         print(e.args[0])
         return
     except TypeError as e:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="You don't have enough {}{}.".format(
                 self.cur_p, self.cur_i)))
         return
     win_num = random.randint(1, 12)
     if int(side) == int(win_num):
         win_amount = int(amount * 10)
         self.modify(user, win_amount)
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title="You won {} {}{} for guessing it right.".format(
                     win_amount, self.cur_p, self.cur_i)))
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title="Better luck next time, the dice rolled {}.".format(
                     win_num)))
Esempio n. 9
0
 async def blackjack(self, ctx, bet: int):
     """Blackjack beta, after started game, type %hit or %stand"""
     message = ctx.message
     self.game_bet = bet
     if self.in_game:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='A Game is already in session, please wait'))
         return
     try:
         self.modify(message.author, int(self.game_bet) * -1)
     except OSError as e:
         print(e.args[0])
         return
     except TypeError as e:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="You don't have enough {}{}.".format(
                 self.cur_p, self.cur_i)))
         return
     self.in_game = True
     self.started_by = message.author
     self.current_game = Blackjack()
     self.current_game.play('hit')
     self.current_game.play('hit')
     result = self.current_game.check_over()
     cards = ", ".join(self.current_game.player_deck)
     cards = cards.replace('_', ' ')
     if result == 'blackjack':
         await self.client.send_message(message.channel,
                                        embed=get_embed(
                                            title='Blackjack!',
                                            txt='\n{}\n'.format(cards)))
         try:
             self.modify(message.author, int(self.game_bet * 2.5))
         except OSError as e:
             print(e.args[0])
             return
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='You won {}'.format(int(self.game_bet * 1.5))))
         self.in_game = False
         self.current_game = None
         return
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title='Your cards are: ',
                             txt='\n{} with {} total\n'.format(
                                 cards, result)))
         self.player_max = result
     await self.client.send_message(
         message.channel,
         embed=get_embed(title='The dealer\'s cards is:',
                         txt='\n{} and a hole card\n'.format(
                             self.current_game.dealer_deck[0].replace(
                                 '_', ' '))))
Esempio n. 10
0
 async def draw(self, ctx, amount: int = 0):
     """Bot owner only, draw a random person and award the money"""
     message = ctx.message
     if not amount:
         amount = random.randint(1, 100)
     while 1:
         user = random.choice(list(message.server.members))
         if not user.bot: break
     try:
         self.modify(user, int(amount))
     except OSError as e:
         print(e.args[0])
         return
     if amount == 1:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} has won 1 {}{}.".format(
                 user.name, self.cur_s, self.cur_i)))
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} has won {} {}{}.".format(
                 user.name, amount, self.cur_p, self.cur_i)))
Esempio n. 11
0
 async def add(self, ctx, amount: int, user: discord.User = None):
     """Bot owner only command, give money to a user"""
     if not user: user = ctx.message.author
     message = ctx.message
     if 0 > amount > 300:
         await self.client.send_message(
             message.channel, embed=get_embed(title="Invalid amount."))
         return
     try:
         self.modify(user, int(amount))
     except OSError as e:
         print(e.args[0])
         return
     if amount == 1:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} added 1 {}{}.".format(
                 user.name, self.cur_s, self.cur_i)))
     else:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title="{} added {} {}{}.".format(
                 user.name, amount, self.cur_p, self.cur_i)))
Esempio n. 12
0
 async def die(self, ctx):
     await self.client.send_message(ctx.message.channel, embed=get_embed('Bye.'))
     client.close()
     sys.exit(0)
Esempio n. 13
0
 async def changeprefix(self, ctx, prefix : str):
     message = ctx.message
     self.client.command_prefix = list(prefix)
     self.config.change('Settings', 1, 'Prefix', str(prefix))
     await self.client.send_message(message.channel, embed=get_embed(title='{} has changed prefix to: {}'.format(message.author,prefix)))
Esempio n. 14
0
 async def stand(self, ctx):
     message = ctx.message
     if not self.in_game:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='No Game is in session, please start a game'))
         return
     if message.author != self.started_by:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title='You did not start this game, please wait.'))
         return
     await self.client.send_message(
         message.channel,
         embed=get_embed(
             title='The dealer\'s cards is:',
             txt='\n{} and {}\n'.format(
                 self.current_game.dealer_deck[0].replace('_', ' '),
                 self.current_game.dealer_deck[1].replace('_', ' '))))
     result = self.current_game.play('stand')
     for i in self.current_game.dealer_drew:
         await self.client.send_message(
             message.channel,
             embed=get_embed(title='The dealer got hit with %s' % i))
     else:
         await self.client.send_message(
             message.channel, embed=get_embed(title='The dealer standed'))
     cards = ", ".join(self.current_game.dealer_deck)
     cards = cards.replace('_', ' ')
     try:
         if 'busts' in result:
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='The dealer got busted! with %s total: ' %
                     result.split(' ')[1],
                     txt='\n{}\n'.format(cards)))
             try:
                 self.modify(message.author, int(self.game_bet * 2))
             except OSError as e:
                 print(e.args[0])
                 return
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You won {}'.format(int(self.game_bet))))
         elif result == 'blackjack':
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(title='The dealer got a blackjack!',
                                 txt='\n{}\n'.format(cards)))
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You lost {}'.format(int(self.game_bet))))
     except:
         if result > self.player_max:
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='The dealer got higher than you! with %s total: '
                     % result,
                     txt='\n{}\n'.format(cards)))
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You lost {}'.format(int(self.game_bet))))
         elif result == self.player_max:
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title=
                     'The dealer got the same points as you! with %s total: '
                     % result,
                     txt='\n{}\n'.format(cards)))
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(title='This game was a push!'))
             try:
                 self.modify(message.author, int(self.game_bet))
             except OSError as e:
                 print(e.args[0])
                 return
         else:
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title=
                     'you got more than the dealer! dealer\'s total points was %s: '
                     % result,
                     txt='\n{}\n'.format(cards)))
             await self.client.send_message(
                 message.channel,
                 embed=get_embed(
                     title='You won {}'.format(int(self.game_bet))))
             try:
                 self.modify(message.author, int(self.game_bet * 2))
             except OSError as e:
                 print(e.args[0])
                 return
     self.in_game = False
     self.current_game = None
Esempio n. 15
0
 async def lastmatch(self, ctx, user: str, region: str):
     """Get the last casual/ranked match results"""
     message = ctx.message
     tmp = await self.client.send_message(
         message.channel, embed=get_embed(title='Searching...'))
     try:
         response = get_response(user, region)
     except urllib.error.HTTPError as weberror:
         if weberror.code == 500:
             await self.client.edit_message(
                 tmp,
                 embed=get_embed(title='No such player: {}.'.format(user)))
         else:
             await self.client.edit_message(
                 tmp,
                 embed=get_embed(
                     title=
                     'Cannot connect to vain.gg server. Use *random instead.'
                 ))
         return
     except ValueError:
         await self.client.send_message(
             message.channel,
             embed=get_embed(
                 title=
                 'Not a valid region. Valid regions are: na, sea, sa, ea, eu.'
             ))
         return
     title = "Last match results for player {}:".format(user)
     match = response['latestMatches'][0]
     if match['casual']:
         match['matchType'] = 'casual'
     else:
         match['matchType'] = 'ranked'
     match['startTime'] = strftime("%a %d %b %Y %H:%M:%S GMT",
                                   gmtime(match['creationTime'] / 1000.0))
     match['duration'] = float("%.2f" % (match['matchDuration'] / 60))
     roster = match['rosters']
     txt = ''
     txt += "MatchType: {matchType}.\nStartTime: {startTime}.\nDuration: {duration}.\nRegion: {region}\n".format(
         **match)
     await self.client.send_message(message.channel,
                                    embed=get_embed(title=title, txt=txt))
     txt = ''
     for team in roster:
         txt += """\nSide: {side}.\nTurretsDestroyed: {turretKills}.\nTurretsRemaining: {turretsRemaining}.
         \nTeamGold: {gold}.\nAced: {acesEarned}.\nTotalHeroKills: {heroKills}.\nKrakenCaptures: {krakenCaptures}.\nPARTICIPANTS:\n""".format(
             **team)
         await self.client.send_message(message.channel,
                                        embed=get_embed(title=title,
                                                        txt=txt))
         txt = ''
         for player in team['participants']:
             player['hero'] = player['championDto']['cleanName']
             player['heroRole'] = player['championDto']['role']
             player['iconUrl'] = player['championDto']['iconUrl']
             player['farm'] = int(player['farm'])
             player['name'] = player['player']['name']
             player['KDA'] = "%s / %s / %s" % (
                 player['kills'], player['deaths'], player['assists'])
             txt += """Name: {name}.\nHero: {hero}.\nRole: {heroRole}.\nHeroPic: {iconUrl}.\nSkin: {skinKey}.\nfarm: {farm}.
             \nKDA: {KDA}\nGoldMineCaptures: {goldMineCaptures}.\nCrystalMineCaptures: {crystalMineCaptures}.
             \nWentAfk: {wentAfk}.\nWinner: {winner}.\nFinalBuild: \n""".format(
                 **player)
             for i, item in enumerate(player['matchItems']):
                 item['itemName'] = item['itemDto']['cleanName']
                 item['itemIcon'] = item['itemDto']['iconUrl']
                 item['i'] = i + 1
                 txt += "{i}.{itemName}.\n".format(**item)
             await self.client.send_message(message.channel,
                                            embed=get_embed(title=title,
                                                            txt=txt))
             txt = ''
Esempio n. 16
0
 async def clever(self, ctx, msg: str):
     message = ctx.message
     response = get_clever(self.cs, msg)
     self.cs = response['cs']
     await self.client.send_message(message.channel,
                                    embed=get_embed(response['output']))