async def help(self, ctx): try: disc = f"\n**NOTE**: You can find the arguments a command supports by typing the command with `args` at the end.\n**Example**: `{ctx.prefix}player ARGS`\n" intro = "Surviv Stat Bot Commands!\nThe Game is playable at https://surviv.io/." info_command_desc = f"βΉοΈ `{ctx.prefix}info` - Returns some information on the game surviv.io.\n" melee_command_desc = f"πͺ `{ctx.prefix}melee` - Returns stats for a melee weapon in surviv.io.\n" link_command_desc = f"π `{ctx.prefix}link` - Returns a party link for surviv.io that expires in 7 seconds.\n" ping_command_desc = f"π `{ctx.prefix}ping` - Gets the current latency of the bot.\n" gun_command_desc = f"\U0001F52B `{ctx.prefix}gun` - Returns stats for a gun in surviv.io.\n" player_command_desc = f"βΉ `{ctx.prefix}player` - Returns stats for a player in surviv.io.\n" twitch_command_desc = f"πΉοΈ `{ctx.prefix}twitch` - Returns the top streamers currently streaming surviv.io.\n" update_command_desc = f"π `{ctx.prefix}update` - Returns the current update in surviv.io.\n" website_command_desc = f"π`{ctx.prefix}website` - Link to the website.\n" supportserver_command_desc = f"π`{ctx.prefix}support` - Link to the support server.\n" surviv_regions_command_desc = f"π `{ctx.prefix}regions` - All of the surviv.io regions.\n" ad_command_desc = f"Your Server Could be here! Join the support server for more info.\n" embed = discord.Embed( title= "<:survivio:787315420074868768> Surviv.io Commands <:survivio:787315420074868768>", description= f"{disc}\n{intro}\n\n{info_command_desc}{melee_command_desc}{ping_command_desc}{gun_command_desc}{player_command_desc}{twitch_command_desc}{update_command_desc}{ surviv_regions_command_desc}{supportserver_command_desc}", color=self.color) embed.set_footer( text=f"{self.name} Dashboard requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.') except Exception as e: WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}' )
async def update(self, ctx): try: conn = await aiosqlite.connect('data/rotating/surviv.db') c = await conn.cursor() await c.execute('select * from new') res = await c.fetchall() content = res[0][2] current_title = res[0][0] current_date = res[0][1] embed = discord.Embed( title=f'Γ°ΕΈβ β’ {current_title} ~ ({current_date}) Γ°ΕΈβ β’ ', description=f'{content}', color=self.color) embed.set_footer( text=f"{self.name} requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.') await conn.close() except Exception as e: try: await conn.close() except: pass WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}' ) error_embed = discord.Embed( description= f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`", color=self.color) await ctx.send(embed=error_embed)
async def player(self, ctx, player_name): try: player_lowered = player_name.lower() player_payload = { "slug": f"{player_lowered}", "interval": "all", "mapIdFilter": "-1" } async with self._session.post(self.url, headers=self.headers, json=player_payload) as r: player_data = await r.json() if not player_data: # no such player embed = discord.Embed( description= f"**{player_name}** is not a valid player of surviv.io.", color=self.color) embed.set_footer( text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) else: kills = player_data["kills"] wins = player_data["wins"] games = player_data["games"] kg = player_data["kpg"] mostkills = max([i["mostKills"] for i in player_data["modes"]]) maxDamage = max( [i["mostDamage"] for i in player_data["modes"]]) embed = discord.Embed( title=f" **{player_data['username']}'s Stats**", description= f"**Wins**: {wins} \n **Kills**: {kills} \n **Games**: {games} \n **Kill Per Game Avg**: {kg} \n **Max Kills**: {mostkills} \n **Most Damage**: {maxDamage}", color=self.color, ) embed.set_footer( text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.') except Exception as e: WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}' ) error_embed = discord.Embed( description= f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`", color=self.color) await ctx.send(embed=error_embed)
async def gun(self, ctx, *args): gun = ' '.join(args).strip() if gun == '': gun = "''" try: conn = await aiosqlite.connect('data/rotating/surviv.db') c = await conn.cursor() await c.execute('select * from guns') res = await c.fetchall() for t in res: if gun.lower() == t[0].lower(): break if t[0].lower() != gun.lower(): guns = [i for i in list(zip(*res))[0]] embed = discord.Embed( description= f"\"**{gun}**\" is not a valid gun in **surviv.io**\n\n**Valid Guns**: {', '.join(guns)}", color=self.color, ) embed.set_footer( text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) else: embed = discord.Embed( title=f"{t[0]} Stats", description= f"**Bullet Damage**: {t[1]} \n **Shot Spread**: {t[2]} \n **Reload Time**: {t[3]} \n **Firing Delay**: {t[4]}", color=self.color, ) embed.set_footer( text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.') await conn.close() except Exception as e: try: await conn.close() except: pass WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}' )
async def help(self, ctx): try: disc = f"\n**NOTE**: You can find the arguments a command supports by typing the command with `args` at the end.\n**Example**: `{ctx.prefix}player`\n" intro = "The Riptide Bot supports commands for the game **surviv.io**.\nThe Game is playable at https://surviv.io/." info_command_desc = f"βΉ `{ctx.prefix}info` - Returns some information on the game surviv.io.\n" melee_command_desc = f"πͺ `{ctx.prefix}melee` - Returns stats for a melee weapon in surviv.io.\n" link_command_desc = f"π `{ctx.prefix}link` - Returns a party link for surviv.io that expires in 7 seconds.\n" gun_command_desc = f"\U0001F52B `{ctx.prefix}gun` - Returns stats for a gun in surviv.io.\n" player_command_desc = f"βΉ `{ctx.prefix}player` - Returns stats for a player in surviv.io.\n" twitch_command_desc = f"πΉοΈ `{ctx.prefix}twitch` - Returns the top streamers currently streaming surviv.io.\n" update_command_desc = f"π `{ctx.prefix}update` - Returns the current update in surviv.io.\n" embed = discord.Embed(title="<:surviv:743213975889641575> Surviv.io Commands <:surviv:743213975889641575>", description = f"{disc}\n{intro}\n\n{info_command_desc}{melee_command_desc}{link_command_desc}{gun_command_desc}{player_command_desc}{twitch_command_desc}{update_command_desc}", color=self.color) embed.set_footer(text=f"{self.name} Dashboard requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log(f'{ctx.message.author} ran {self.name} Command successfully.') except Exception as e: WarningLogger.log(f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}')
async def twitch(self, ctx): try: async with self._session.get(self.url, headers=self.headers) as r: raw_json = await r.json() # parse json embed = discord.Embed( title="Current Surviv Streamers", description= "[Surviv.io on Twitch!](https://www.twitch.tv/directory/game/surviv.io)", color=self.color) for t in raw_json['twitch']: embed.add_field( name=f"Streamer: {t['name']}", value= f"Watch: [{t['title']}]({t['url']})\nViewers: `{t['viewers']}`", inline=True) if not len(raw_json['twitch']): embed = discord.Embed( description= "No Surviv Twitch Streamers are **currently streaming**.", color=self.color) embed.set_footer( text= f"{self.name} Dashboard requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.' ) except Exception as e: WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}' ) error_embed = discord.Embed( description= f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`", color=self.color) await ctx.send(embed=error_embed)
async def melee(self, ctx, *args): wep = ' '.join(args).strip() if wep == '': wep = "''" try: conn = await aiosqlite.connect('data/rotating/surviv.db') c = await conn.cursor() await c.execute('select * from melee') res = await c.fetchall() for t in res: if wep.lower() == t[0]: break if t[0] != wep.lower(): weps = [string.capwords(i) for i in list(zip(*res))[0]] embed = discord.Embed( description=f'"**{wep}**" is not a valid melee weapon in **surviv.io**\n\n**Valid Weapons**: {", ".join(weps)}', color=self.color, ) embed.set_footer(text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) else: embed = discord.Embed( title=f"{string.capwords(t[0])} Stats", description=f"**Damage**: {t[2]} \n **Attack Radius**: {t[3]} \n **Equip Speed**: {t[1]} \n **Cooldown Time**: {t[4]} \n **Auto Attack**: {t[5]} \n", color=self.color, ) embed.set_footer(text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) StreamLogger.log(f'{ctx.message.author} ran {self.name} Command successfully.') await conn.close() except Exception as e: WarningLogger.log(f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}') try: await conn.close() except: pass
async def link(self, ctx): try: embed = discord.Embed(description="(1/5) **Starting Process** ...", color=self.color) status = await ctx.send(embed=embed) arsenic_session = await start_session( services.Geckodriver(), browsers.Firefox(), ) embed = discord.Embed(description="(2/5) **Spawned Instance** ...", color=self.color) await status.edit(embed=embed) await arsenic_session.get(self.url) make_team_btn = await arsenic_session.get_element( '#btn-create-team') embed = discord.Embed(description="(3/5) **Locating target** ...", color=self.color) await status.edit(embed=embed) await make_team_btn.click() embed = discord.Embed( description="(4/5) **Retrieving Party Link** ...", color=self.color) await status.edit(embed=embed) await asyncio.sleep( 2 ) # add a small sleep delay for the party link to load up (a bit risky) party_url = await arsenic_session.get_url() embed = discord.Embed( description= f"**Party Link**: {party_url}\nLink Generator will leave in 7 seconds.", color=self.color) await status.edit(embed=embed) await asyncio.sleep(4) # waits 7 seconds before leaving await status.edit(embed=discord.Embed( description= f"**Party Link**: {party_url}\nLink Generator is leaving soon ...", color=self.color)) await asyncio.sleep(6) # add more than 3 for extra time embed = discord.Embed( description=f"**Link Generator left.**\nOld Link: {party_url}", color=self.color) embed.set_footer( text=f"{self.name} requested by {ctx.message.author}", icon_url=ctx.author.avatar_url) await status.edit(embed=embed) StreamLogger.log( f'{ctx.message.author} ran {self.name} Command successfully.') await stop_session(arsenic_session) except Exception as e: try: await stop_session(arsenic_session) except: pass WarningLogger.log( f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {e}' ) error_embed = discord.Embed( description= f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`", color=self.color) await ctx.send(embed=error_embed)