def _load_thread_task(files_list): """ Auxiliary task to load data asynchronously """ global data_lock, loaded_list, thread_stop_event my_process = PsProcess(getpid()) args = cycle(np.array_split(files_list, np.arange(20, len(files_list), 20))) del files_list load_pool = ThreadPool() init_memory = my_process.memory_percent() for arg in args: while my_process.memory_percent() - init_memory > 15: sleep(1) data = load_pool.starmap(ImgProc.load_image, zip(arg, repeat(ImgData.FLOAT))) data_lock.acquire() loaded_list.append(data) data_lock.release() if thread_stop_event.is_set(): break data_lock.acquire() loaded_list.append([]) data_lock.release() load_pool.close() load_pool.join() return
async def advinfo(self, ctx): proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) bot = await self.client.application_info() e = discord.Embed(title=f"{bot.name}", description=f"{bot.description}", colour=COLOURS['purple']) e.add_field(name="Bot Version", value=f'{BOT_VERSION}', inline=False) e.add_field(name="Uptime", value=f'{str(uptime).split(".")[0]}', inline=True) e.add_field(name="", value="") e.add_field(name="CPU time", value=f'{str(cpu_time).split(".")[0]}', inline=True) # name and value of below field are Zero Width Space not empty # Check this : https://emojipedia.org/zero-width-joiner/ e.add_field(name="Ping", value=f'{round(self.client.latency*1000)}ms', inline=True) e.add_field(name="", value="") e.add_field(name="Response Time", value=f'-', inline=False) e.add_field(name="Memory Usage", value=f'{mem_usage:,.0f}/{mem_total:,.0f} MB', inline=True) e.add_field(name="Memory Usage %", value=f'{mem_of_total:,.2f}%', inline=True) e.set_thumbnail(url=str(bot.icon_url)) e.set_footer( text=f'Python Version - {version_info.major}.{version_info.minor}.{version_info.micro} | Discord.py Version - {discord.version_info.major}.{discord.version_info.minor}.{discord.version_info.micro}') start = time() msg = await ctx.send(embed=e) end = time() e.set_field_at(index=6, name="Response Time", value=f'{round((end-start)*1000)}ms', inline=True) await msg.edit(embed=e)
async def botinfo(self, ctx): handles = self.db.get_count('handles') matches = self.db.get_count('finished') rounds = self.db.get_count('finished_rounds') guilds = len(self.client.guilds) uptime_ = int(time.time()) - self.uptime proc = Process() with proc.oneshot(): mem_total = virtual_memory().total / (1024 ** 3) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) embed = discord.Embed(description="A discord bot to compete with others on codeforces in a Lockout format", color=discord.Color.magenta()) embed.set_author(name="Bot Stats", icon_url=self.client.user.avatar_url) embed.set_thumbnail(url=self.client.user.avatar_url) embed.add_field(name="Handles Set", value=f"**{handles}**", inline=True) embed.add_field(name="Matches played", value=f"**{matches}**", inline=True) embed.add_field(name="Rounds played", value=f"**{rounds}**", inline=True) embed.add_field(name="Servers", value=f"**{guilds}**", inline=True) embed.add_field(name="Uptime", value=f"**{timeez(uptime_)}**", inline=True) embed.add_field(name="Memory usage", value=f"{int(mem_usage * 1024)} MB / {mem_total:,.0f} GB ({mem_of_total:.0f}%)", inline=True) embed.add_field(name="GitHub repository", value=f"[GitHub]({GITHUB_LINK})", inline=True) embed.add_field(name="Bot Invite link", value=f"[Invite]({BOT_INVITE})", inline=True) embed.add_field(name="Support Server", value=f"[Server]({SERVER_INVITE})", inline=True) await ctx.send(embed=embed)
async def show_bot_stats(self, ctx): '''Displays Statistical Information''' embed = Embed(title="Bot stats", colour=ctx.author.colour, thumbnail=self.bot.user.avatar_url, timestamp=datetime.utcnow()) proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) #cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) mo = self.bot.guilds sum1 = 0 for s in mo: sum1 += len(s.members) fields = [ ("Python version", python_version(), True), ("discord.py version", discord_version, True), ("Uptime", uptime, True), ("CPU time", f"{cpu_time}%", True), ("Memory usage", f"{mem_usage:,.3f} / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", True), ("Users", f"{sum1:,}", True), ("Servers", f"{len(self.bot.guilds)}", True), ("Region", f"`Europe`", True), ("Latency", "`{0}`".format(round(self.bot.latency, 4) * 1000), True) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) await ctx.send(embed=embed)
async def show_bot_stats(self, ctx): embed = Embed(title="Bot stats", colour=ctx.author.colour, thumbnail=self.bot.user.avatar_url, timestamp=datetime.utcnow()) proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) fields = [ ("Bot version", self.bot.VERSION, True), ("Python version", python_version(), True), ("discord.py version", discord_version, True), ("Uptime", uptime, True), ("CPU time", cpu_time, True), ("Memory usage", f"{mem_usage:,.3f} / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", True), ("Users", f"{self.bot.guild.member_count:,}", True) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) await ctx.send(embed=embed)
async def info(self, ctx): """Shows you information about the bot owner, bot uptime, latency, memory and cpu usage.""" embed = Embed(color=0x000000) embed.set_thumbnail(url=ctx.bot.user.avatar_url) app = await ctx.bot.application_info() owner = app.owner embed.set_author(name=str(owner), icon_url=owner.avatar_url) proc = Process() with proc.oneshot(): uptime = datetime.utcnow() - ctx.bot.launched_at mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) cpu_usage = proc.cpu_percent() / cpu_count() embed.add_field(name='Uptime', value=str(uptime), inline=False) embed.add_field(name='Latency', value=f'{round(ctx.bot.latency * 1000, 2)} ms', inline=False) embed.add_field( name='Memory usage', value= f'{int(mem_usage)} / {int(mem_total)} MiB ({round(mem_of_total)}%)', inline=False) embed.add_field(name='CPU usage', value=f'{round(cpu_usage)}%', inline=False) await ctx.send(embed=embed)
def get_stats(self): """Return statistics about our node""" stats = {} proc = Process() def get_open_files(): if WINDOWS: return proc.num_handles() return proc.num_fds() try: self._too_many except AttributeError: sleep(1) comm_inst = self._too_many.get(communicator.OnionrCommunicatorDaemon, args=(self._too_many, )) connected = [] [ connected.append(x) for x in comm_inst.onlinePeers if x not in connected ] stats['uptime'] = comm_inst.getUptime() stats['connectedNodes'] = '\n'.join(connected) stats['blockCount'] = len(blockmetadb.get_block_list()) stats['blockQueueCount'] = len(comm_inst.blockQueue) stats['threads'] = proc.num_threads() stats['ramPercent'] = proc.memory_percent() stats['fd'] = get_open_files() stats['diskUsage'] = human_size(size(identify_home())) return json.dumps(stats)
async def botstats(self, ctx): embed = discord.Embed(title="Statistics", colour=discord.Colour.red(), thumbnail=self.bot.user.avatar_url, timestamp=datetime.utcnow()) proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) embed.add_field(name="Python version", value=python_version(), inline=True), embed.add_field(name="discord.py version", value=discord_version, inline=True), embed.add_field(name="Uptime", value=uptime, inline=True), embed.add_field(name="CPU time", value=cpu_time, inline=True), embed.add_field( name="Memory usage", value= f"{mem_usage:,.3f} / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", inline=True), #embed.add_field(name = "Users", value = f"{ctx.guild.member_count:,}", inline =True) await ctx.send(embed=embed)
def track_process(p: psutil.Process): pid = p.pid with p.oneshot(): try: res = p.memory_info() tracker.add({ f'process.{p.pid}.{p.name()}.rss': res.rss, f'process.{p.pid}.{p.name()}.vms': res.vms }) except psutil.AccessDenied: pass try: res = p.memory_percent() tracker.add({ f'process.{p.pid}.{p.name()}.mem': res, }) except psutil.AccessDenied: pass try: res = p.cpu_percent() tracker.add({ f'process.{p.pid}.{p.name()}.cpu': res, }) except psutil.AccessDenied: pass try: res = p.num_threads() tracker.add({ f'process.{p.pid}.{p.name()}.threads': res, }) except psutil.AccessDenied: pass
def server_info(): """Return server statistics.""" started = time() proc = Process() process_size = proc.memory_info() stats = [] memory = virtual_memory() stats.append('Memory: {used} used of {total} ({percent}%)'.format( used=naturalsize(memory.used), total=naturalsize(memory.total), percent=memory.percent)) bt = boot_time() uptime = time() - bt stats.append('Server Uptime: {delta} since {booted}'.format( delta=util.format_timedelta(datetime.timedelta(seconds=uptime)), booted=ctime(bt))) if server.server.started is not None: stats.append('Process Uptime: {} since {}'.format( util.format_timedelta(datetime.datetime.utcnow() - server.server.started), server.server.started.ctime())) stats.append('OS Version: {} ({})'.format(platform(), architecture()[0])) stats.append('{type} : {version}'.format(type=python_implementation(), version=sys.version)) stats.append('Number Of Threads: %d' % proc.num_threads()) stats.append('Process Memory:') stats.append('Real: %s' % naturalsize(process_size.rss)) stats.append('Virtual: %s' % naturalsize(process_size.vms)) stats.append('Percent: %.2f' % proc.memory_percent()) stats.append('Lines of code in server: %d' % db.Base.code_lines()) stats.append('Objects in server: %d' % db.Base.number_of_objects()) stats.append('Statistics generated in %.2f seconds.' % (time() - started)) return stats
def get_stats(self): """Return statistics about our node""" stats = {} proc = Process() def get_open_files(): if WINDOWS: return proc.num_handles() return proc.num_fds() try: self._too_many except AttributeError: sleep(1) kv: "DeadSimpleKV" = self._too_many.get_by_string("DeadSimpleKV") connected = [] [ connected.append(x) for x in kv.get('onlinePeers') if x not in connected ] stats['uptime'] = get_epoch() - kv.get('startTime') stats['connectedNodes'] = '\n'.join(connected) stats['blockCount'] = len(blockmetadb.get_block_list()) stats['blockQueueCount'] = len(kv.get('blockQueue')) stats['threads'] = proc.num_threads() stats['ramPercent'] = proc.memory_percent() stats['fd'] = get_open_files() stats['diskUsage'] = human_size(size(identify_home())) return json.dumps(stats)
def worker(self, obj): if self.active_workers: for node, active_workers in self.active_workers.iteritems(): for worker in active_workers: if worker['id'] == obj.task_id: p = Process(worker['worker_pid']) return 'CPU:%.1f%% RAM:%.2f%%' % (p.cpu_percent(0.05), p.memory_percent()) return 'N/a'
def collect_status(pid, appname, site): ip_out = get_host_info()[0] ip_inner = get_host_info()[1] server_id = get_host_info()[2] physical_mem = psutil.virtual_memory().total / 1024 / 1024 #Unit of M cpu_count = psutil.cpu_count() its = int(time.time()) p_ins = Process(pid) pstatus = p_ins.status() create_time = time.strftime("%Y%m%d %H:%M:%S", time.localtime(p_ins.create_time())) memory_percent = p_ins.memory_percent() memory_used = memory_percent * physical_mem cpu_calc_list = [] for i in range(6): cpu_calc = p_ins.cpu_percent(interval=0.1) cpu_calc_list.append(cpu_calc) cpu_percent = float(sum(cpu_calc_list) / len(cpu_calc_list)) num_fds = p_ins.num_fds() connections = p_ins.connections() connections_num = len(connections) #appname=p_ins.cwd() if p_ins.name() == 'jsvc': app_path = p_ins.exe().split('/')[:-2] else: app_path = p_ins.cwd() #appname = app_path.split('/')[-1] appname = appname if p_ins.children(recursive=True): children_list = str(p_ins.children(recursive=True)) else: children_list = None message = { 'site': site, 'ip': ip_out, 'ip_inner': ip_inner, 'server_id': server_id, 'pstatus': pstatus, 'metric_name': 'app_monitor', 'its': its, 'pid': pid, 'physical_mem': physical_mem, 'memory_used': memory_used, 'memory_percent': memory_percent, 'cpu_count': cpu_count, 'cpu_percent': cpu_percent, 'num_fds': num_fds, 'connections_num': connections_num, 'create_time': create_time, 'appname': appname, 'app_path': app_path, 'children': children_list } return message
def F_Memory(pname): a = pids() for i in a: try: p = Process(i) if p.name() == 'java': cmd = ' '.join(p.cmdline()) if re.search(pname, cmd): print round(p.memory_percent(), 2) except Exception, e: continue
def memory_usage_psutil(): # return the memory usage in percentage like top process = Process(getpid()) mem = process.memory_info()[0] if mem > float(2**30): mem = color("{}GB".format(str(mem / float(2**30))[:6]), fontcolor='red', bold=True) elif mem > float(2**20): mem = color("{}MB".format(str(mem / float(2**20))[:6]), fontcolor='yellow', bold=True) elif mem > float(2**10): mem = color("{}KB".format(str(mem / float(2**10))[:6]), fontcolor='green', bold=True) else: mem = color("{}B".format(mem), fontcolor='green', bold=True) return " | {}% | {} |".format(str(process.memory_percent())[:6], mem)
async def cmd_stats(self, ctx): async with ctx.typing(): start = time() msg = await ctx.send("-") end = time() dwsp_latency = round(self.bot.latency*1000) response_latency = round((end-start)*1000) proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time()-proc.create_time()) cpu_time = timedelta(seconds=(cpu:=proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = round(mem_total * (mem_of_total / 100),2) mem_of_total = round(mem_of_total, 2) mem_total = round(mem_total/1024) embed=Embed( title=self.bot.user.name, color=ctx.guild.me.color if ctx.guild else ctx.author.color, timestamp=datetime.utcnow() ) embed.set_author(name=self.bot.user, icon_url=self.bot.user.avatar_url) embed.set_thumbnail(url=self.bot.user.avatar_url) fields=[ ("Default Prefix", self.bot.prefix, True), ("DWSP Latency", f"{dwsp_latency}ms", True), ("Response Latency", f"{response_latency}ms", True), ("Bot Version", self.bot.VERSION, True), ("Python Version", python_version(), True), ("Discord.py Version", discord_version, True), ("Uptime", uptime, True), ("CPU Time", cpu_time, True), ("Loaded Cogs", len(self.bot.extensions), True), ("Memory Usage", f"{mem_usage}MB/{mem_total}GB {mem_of_total}%", False), ("Servers", len(self.bot.guilds), True), ("Users", len(self.bot.users), True), ("Banned Users", len(self.bot.banlist), True)] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) await msg.delete() await ctx.send(embed=embed)
async def show_bot_info(self, ctx): t = datetime.utcnow() proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) e = Embed(title=f"Information about `ICE X`", colour=ctx.author.colour) fields = [ ("Bot version", self.bot.VERSION, True), ("Bot Owner", f"<@!537634097137188875>", True), ("Python version", python_version(), True), ("discord.py version", discord_version, True), ("Uptime", uptime, True), ("CPU time", cpu_time, True), ("Memory usage", f"{mem_usage:,.3f} / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", True), ("Invite Bot", '**[Invite](https://discord.com/api/oauth2/authorize?client_id=723380957343907911&permissions=8&scope=bot "Invite the bot to your server")**', False) ] for name, value, inline in fields: e.add_field(name=name, value=value, inline=inline) e.set_thumbnail(url=self.bot.user.avatar_url) e.set_author( name=f"{ctx.author.display_name}#{ctx.author.discriminator}", icon_url=ctx.author.avatar_url) e.set_footer( text= f"Requested by {ctx.author.display_name} | {t.strftime('%b %d, %Y | %I:%M %p UTC')}" ) await ctx.send(embed=e)
async def gbotinfo(self, ctx): embed = discord.Embed(title='About gBot', colour=discord.Colour.blurple()) proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) fields = [ ("Developed by:", "Galax028#9474", True), ("Hosted using:", "https://mydiscordbothosting.com", True), ("Version:", f"`{version}`", True), ("Total Commands:", f"{len(self.bot.commands)}", True), ("Invite the bot:", "[Click Here](https://rb.gy/wzzuvm)", True), ("Support Server:", "[Click Here](https://discord.gg/2hVmdnb)", True), ("⠀", "----------------------------------------------------------------------", False), ("Python Version:", f"`{python_version()}`", True), ("discord.py Version:", f"`{discord_version}`", True), ("⠀", "⠀", True), ("Uptime:", f"`{uptime}`", True), ("CPU Time:", f"`{cpu_time}`", True), ("RAM Usage:", f"`{mem_usage:,.3f}/250 MiB`", True), ("⠀", "----------------------------------------------------------------------", False), ("Special Thanks:", "PixelEdition#2116, Marxist Gamer#3000, Sir.Nick#4646", False), ("⠀", "⠀", False) ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_footer(text="Thank you for using gBot!") await ctx.send(embed=embed)
async def botstats(self, ctx): """ Displays the bots statistics """ embed = discord.Embed(colour=ctx.author.colour, title="Bot Stats", thumbnail=self.bot.user.avatar_url) proc = Process() with proc.oneshot(): now = int(time.time()) nt = now - proc.create_time() uptime = timedelta(seconds=nt) memory_total = virtual_memory().total / (1024**3) memory_of_total = proc.memory_percent() memory_usage = memory_total * (memory_of_total / 100) ft = "gif" if ctx.author.is_avatar_animated() else "png" embed.add_field(name="Python Version", value=python_version(), inline=True) embed.add_field(name="Discord.py Version", value=discord.__version__, inline=True) embed.add_field(name="Uptime", value=uptime, inline=False) embed.add_field( name="Memory Usage", value= f"{memory_usage:,.2} / {memory_total:,.0f} GB ({memory_of_total:,.0f}%)", inline=False) embed.set_footer(text=f"Requested by {ctx.author.name}") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format=ft)) await ctx.send(embed=embed)
async def show_bot_info(self, ctx, patreon_status): embed = Embed( title="Doob Info <:doob:754762131085459498>", colour=ctx.author.colour, timestamp=datetime.utcnow(), ) bot_version = self.bot.VERSION proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta( seconds=(cpu := proc.cpu_times()).system + cpu.user ) # pylint: disable=used-before-assignment mem_total = virtual_memory().total / (1025 ** 2) mem_of_total = proc.memory_percent() mem_usg = mem_total * (mem_of_total / 100) fields = [ ("Name", "Doob <:doob:754762131085459498>", False), ( "Description", "The multipurpose Discord Bot with global leveling and powerful logging tools for your server.", False, ), ("Developers", "<@308000668181069824>", False), ("Doob's Server Count", f"{str(len(self.bot.guilds))}", True), ("Doob's Member Count", f"{str(len(self.bot.users))}", True), ( "The ping for Doob is...", f" :ping_pong: {round(self.bot.latency * 1000)} ms", False, ), ("Python Version", python_version(), True), ("Uptime", uptime, True), ("CPU Time", cpu_time, True), ( "Memory Usage", f"{mem_usg:,.3f} MiB / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", True, ), ("Library", f"discord.py {discord_version}", True), ( "Bot Version", f"{self.bot.VERSION} - [Changelog](https://github.com/doobdev/doob/blob/master/CHANGELOG.md#v{bot_version.replace('.', '')})", True, ), ("Top.gg Link", "https://top.gg/bot/680606346952966177", False), ( "Invite Link", "[Invite Link Here](https://doob.link/invite)", True, ), ( "GitHub Repository", "[Click Here](https://github.com/doobdev/doob)", True, ), ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_thumbnail(url=ctx.guild.me.avatar_url) embed.set_footer( text=f"{ctx.author.name} requested Doob's information", icon_url=ctx.author.avatar_url, ) if patreon_status == True: embed.add_field( name="Patreon", value=f"Thanks for [Donating](https://patreon.com/doobdev) {ctx.author.display_name}! :white_check_mark:", inline=False, ) await ctx.reply(embed=embed) if patreon_status == False: embed.add_field( name="Patreon", value="[Click Here for Patreon](https://patreon.com/doobdev)", inline=False, ) await ctx.reply(embed=embed)
async def command_bot_info(self, ctx: commands.Context) -> None: proc = Process() with proc.oneshot(): uptime = chron.short_delta( timedelta(seconds=time() - proc.create_time())) cpu_time = chron.short_delta( timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user), milliseconds=True) mem_total = virtual_memory().total / (1024**2) mem_of_total = proc.memory_percent() mem_usage = mem_total * (mem_of_total / 100) await ctx.send(embed=discord.Embed.from_dict({ "title": "Carberretta Information", "color": DEFAULT_EMBED_COLOUR, "thumbnail": { "url": f"{self.bot.user.avatar_url}" }, "author": { "name": "Carberretta" }, "footer": { "text": f"Requested by {ctx.author.display_name}", "icon_url": f"{ctx.author.avatar_url}", }, "fields": [ { "name": "Bot Version", "value": self.bot.version, "inline": True }, { "name": "Python Version", "value": python_version(), "inline": True }, { "name": "discord.py Version", "value": discord.__version__, "inline": True }, { "name": "Uptime", "value": uptime, "inline": True }, { "name": "CPU Time", "value": cpu_time, "inline": True }, { "name": "Memory Usage", "value": f"{mem_usage:,.3f} / {mem_total:,.0f} MiB ({mem_of_total:,.0f}%)", "inline": True, }, { "name": "Code Lines", "value": f"{int(self.bot.loc.code):,}", "inline": True }, { "name": "Docs Lines", "value": f"{int(self.bot.loc.docs):,}", "inline": True }, { "name": "Blank Lines", "value": f"{int(self.bot.loc.empty):,}", "inline": True }, { "name": "Database Calls", "value": f"{self.bot.db._calls:,}", "inline": True }, ], }))
async def show_bot_info(self, ctx, patreon_status): embed = Embed(title="Krinio Info", colour=ctx.author.colour, timestamp=datetime.utcnow()) bot_version = self.bot.VERSION proc = Process() with proc.oneshot(): uptime = timedelta(seconds=time() - proc.create_time()) cpu_time = timedelta(seconds=(cpu := proc.cpu_times()).system + cpu.user) mem_total = virtual_memory().total / (1025**2) mem_of_total = proc.memory_percent() mem_usg = mem_total * (mem_of_total / 100) fields = [ ("Name", "Krinio", False), ("Developers", "<@308000668181069824>", False), ("Krinio's Server Count", f"{str(len(self.bot.guilds))}", True), ("Krinio's Member Count", f"{str(len(self.bot.users))}", True), ( "The ping for Krinio is...", f" :ping_pong: {round(self.bot.latency * 1000)} ms", False, ), ("Python Version", python_version(), True), ("Uptime", uptime, True), ("CPU Time", cpu_time, True), ( "Memory Usage", f"{mem_usg:,.3f} MiB / {mem_total:,.0f} MiB ({mem_of_total:.0f}%)", True, ), ("Library", f"discord.py {discord_version}", True), ( "Bot Version", f"{self.bot.VERSION} - [Changelog](https://github.com/doobdev/Krinio/blob/master/CHANGELOG.md#v{bot_version.replace('.', '')})", True, ), ("Top.gg Link", "https://top.gg/bot/744377689095536750", False), ( "Invite Link", "[Invite Link Here](https://discord.com/oauth2/authorize?client_id=744377689095536750&scope=bot&permissions=271674430)", True, ), ( "GitHub Repository", "[Click Here](https://github.com/doobdev/Krinio)", True, ), ] for name, value, inline in fields: embed.add_field(name=name, value=value, inline=inline) embed.set_thumbnail(url=ctx.guild.me.avatar_url) embed.set_footer( text=f"{ctx.author.name} requested Krinio's information", icon_url=ctx.author.avatar_url, ) if patreon_status == True: embed.add_field( name="Patreon", value= f"Thanks for [Donating](https://patreon.com/doobdev) {ctx.author.display_name}! :white_check_mark:", inline=False, ) await ctx.send(embed=embed) if patreon_status == False: embed.add_field( name="Patreon", value="[Click Here for Patreon](https://patreon.com/doobdev)", inline=False, ) await ctx.send(embed=embed)