def get_active_player_count(self) -> Tuple[Optional[str], int]: try: current = next( (player.current for player in lavalink.active_players() if player.current is not None), None, ) get_single_title = self.get_track_description_unformatted( current, self.local_folder_current_path) playing_servers = len(lavalink.active_players()) except IndexError: get_single_title = None playing_servers = 0 return get_single_title, playing_servers
async def usagecount(self, ctx: commands.Context): """ Show the usage count of the bot. Commands processed, messages received, and music on servers. """ uptime = str(self.get_bot_uptime()) commands_count = "`{}`".format(self.get("processed_commands")) errors_count = "`{}`".format(self.get("command_error")) messages_read = "`{}`".format(self.get("messages_read")) messages_sent = "`{}`".format(self.get("msg_sent")) try: total_num = "`{}/{}`".format( humanize_number(len(lavalink.active_players())), humanize_number(len(lavalink.all_players())), ) except AttributeError: # Remove at 3.2 total_num = "`{}/{}`".format( humanize_number( len([p for p in lavalink.players if p.current is not None])), humanize_number(len([p for p in lavalink.players])), ) tracks_played = "`{}`".format(self.get("tracks_played")) guild_join = "`{}`".format(self.get("guild_join")) guild_leave = "`{}`".format(self.get("guild_remove")) avatar = self.bot.user.avatar_url_as(static_format="png") msg = (bold(_("Commands processed: ")) + _("{} commands.\n").format(commands_count) + bold(_("Commands errors: ")) + _("{} errors.\n").format(errors_count) + bold(_("Messages received: ")) + _("{} messages.\n").format(messages_read) + bold(_("Messages sent: ")) + _("{} messages.\n").format(messages_sent) + bold(_("Playing music on: ")) + _("{} servers.\n").format(total_num) + bold(_("Tracks played: ")) + _("{} tracks.\n\n").format(tracks_played) + bold(_("Servers joined: ")) + _("{} servers.\n").format(guild_join) + bold(_("Servers left: ")) + _("{} servers.").format(guild_leave)) try: em = discord.Embed(color=await ctx.embed_colour()) em.add_field( name=_("Usage count of {} since last restart:").format( ctx.bot.user.name), value=msg, ) em.set_thumbnail(url=avatar) em.set_footer(text=_("Since {}").format(uptime)) await ctx.send(embed=em) except discord.Forbidden: await ctx.send( _("Usage count of {} since last restart:\n").format( ctx.bot.user.name) + msg + _("\n\nSince {}").format(uptime))
async def command_audiostats(self, ctx: commands.Context): """Audio stats.""" server_num = len(lavalink.active_players()) total_num = len(lavalink.all_connected_players()) msg = "" async for p in AsyncIter(lavalink.all_connected_players()): connect_dur = ( self.get_time_string( int( ( datetime.datetime.now(datetime.timezone.utc) - p.connected_at ).total_seconds() ) ) or "0s" ) try: if not p.current: raise AttributeError current_title = await self.get_track_description( p.current, self.local_folder_current_path ) msg += f"{p.guild.name} [`{connect_dur}`]: {current_title}\n" except AttributeError: msg += "{} [`{}`]: **{}**\n".format( p.guild.name, connect_dur, _("Nothing playing.") ) if total_num == 0: return await self.send_embed_msg(ctx, title=_("Not connected anywhere.")) servers_embed = [] pages = 1 for page in pagify(msg, delims=["\n"], page_length=1500): em = discord.Embed( colour=await ctx.embed_colour(), title=_("Playing in {num}/{total} servers:").format( num=humanize_number(server_num), total=humanize_number(total_num) ), description=page, ) em.set_footer( text=_("Page {}/{}").format( humanize_number(pages), humanize_number((math.ceil(len(msg) / 1500))) ) ) pages += 1 servers_embed.append(em) await menu(ctx, servers_embed, DEFAULT_CONTROLS)
async def usagecount(self, ctx: commands.Context): """ Show the usage count of the bot. Commands processed, messages received, and music on servers. """ msg = _( "**Commands processed:** `{commands_count}` commands. (`{cpm_commands:.2f}`/min)\n" "**Commands errors:** `{errors_count}` errors.\n" "**Messages received:** `{messages_read}` messages. (`{cpm_msgs:.2f}`/min)\n" "**Messages sent:** `{messages_sent}` messages. (`{cpm_msgs_sent:.2f}`/min)\n" "**Playing music on:** `{ll_players}` servers.\n" "**Tracks played:** `{tracks_played}` tracks. (`{cpm_tracks:.2f}`/min)\n\n" "**Servers joined:** `{guild_join}` servers. (`{cpm_guild_join:.2f}`/hour)\n" "**Servers left:** `{guild_leave}` servers. (`{cpm_guild_leave:.2f}`/hour)" ).format( commands_count=self.get("processed_commands"), cpm_commands=self.usage_counts_cpm("processed_commands"), errors_count=self.get("command_error"), messages_read=self.get("messages_read"), cpm_msgs=self.usage_counts_cpm("messages_read"), messages_sent=self.get("msg_sent"), cpm_msgs_sent=self.usage_counts_cpm("msg_sent"), ll_players="`{}/{}`".format( humanize_number(len(lavalink.active_players())), humanize_number(len(lavalink.all_players())), ), tracks_played=self.get("tracks_played"), cpm_tracks=self.usage_counts_cpm("tracks_played"), guild_join=self.get("guild_join"), cpm_guild_join=self.usage_counts_cpm("guild_join", 3600), guild_leave=self.get("guild_remove"), cpm_guild_leave=self.usage_counts_cpm("guild_remove", 3600), ) if await ctx.embed_requested(): em = discord.Embed( color=await ctx.embed_colour(), title=_("Usage count of {} since last restart:").format( self.bot.user.name), description=msg, ) em.set_thumbnail(url=self.bot.user.avatar_url_as( static_format="png")) em.set_footer(text=_("Since {}").format(self.get_bot_uptime())) await ctx.send(embed=em) else: await ctx.send( _("Usage count of {} since last restart:\n").format( ctx.bot.user.name) + msg + _("\n\nSince {}").format(self.get_bot_uptime()))
async def usagecount(self, ctx): """ Show the usage count of the bot. Commands processed, messages received, and music on servers. """ uptime = str(self.bot.get_cog("Core").get_bot_uptime()) commands_count = "`{:,}`".format( self.bot.counter["processed_commands"]) errors_count = "`{}`".format(self.bot.counter["command_error"]) messages_read = "`{:,}`".format(self.bot.counter["messages_read"]) messages_sent = "`{:,}`".format(self.bot.counter["msg_sent"]) try: total_num = "`{:,}/{:,}`".format(len(lavalink.active_players()), len(lavalink.all_players())) except AttributeError: total_num = "`{:,}/{:,}`".format( len([p for p in lavalink.players if p.current is not None]), len([p for p in lavalink.players]), ) guild_join = "`{:,}`".format(self.bot.counter["guild_join"]) guild_leave = "`{:,}`".format(self.bot.counter["guild_remove"]) avatar = self.bot.user.avatar_url_as(static_format="png") em = discord.Embed(color=(await ctx.embed_colour())) em.add_field( name=_("Usage count of {} since last restart:").format( ctx.bot.user.name), value=(bold(_("Commands processed: ")) + _("{} commands.\n").format(commands_count) + bold(_("Commands errors: ")) + _("{} errors.\n").format(errors_count) + bold(_("Messages received: ")) + _("{} messages.\n").format(messages_read) + bold(_("Messages sent: ")) + _("{} messages.\n").format(messages_sent) + bold(_("Playing music on: ")) + _("{} servers.\n\n").format(total_num) + bold(_("Servers joined: ")) + _("{} servers.\n").format(guild_join) + bold(_("Servers left: ")) + _("{} servers.").format(guild_leave)), ) em.set_thumbnail(url=avatar) em.set_footer(text=_("Since {}").format(uptime)) await ctx.send(embed=em)
async def advusagecount(self, ctx: commands.Context): """ Permanent stats since first time that the cog has been loaded. """ avatar = self.bot.user.avatar_url_as(static_format="png") query = SELECT_PERMA_SINGLE condition = {"event": "creation_time", "guild_id": -1000} result = list(self.cursor.execute(query, condition)) delta = datetime.utcnow() - datetime.utcfromtimestamp(result[0][0]) uptime = humanize_timedelta(timedelta=delta) ll_players = "{}/{}".format( humanize_number(len(lavalink.active_players())), humanize_number(len(lavalink.all_players())), ) em = discord.Embed( title=_("Usage count of {}:").format(ctx.bot.user.name), color=await ctx.embed_colour(), ) em.add_field( name=_("Message Stats"), value=box( _("Messages Read : {messages_read}\n" "Messages Sent : {msg_sent}\n" "Messages Deleted : {messages_deleted}\n" "Messages Edited : {messages_edited}\n" "DMs Received : {dms_received}\n").format_map({ "messages_read": self.fetch("messages_read"), "msg_sent": self.fetch("msg_sent"), "messages_deleted": self.fetch("messages_deleted"), "messages_edited": self.fetch("messages_edited"), "dms_received": self.fetch("dms_received"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("Commands Stats"), value=box( _("Commands Processed : {processed_commands}\n" "Errors Occured : {command_error}\n" "Sessions Resumed : {sessions_resumed}\n").format_map({ "processed_commands": self.fetch("processed_commands"), "command_error": self.fetch("command_error"), "sessions_resumed": self.fetch("sessions_resumed"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("Guild Stats"), value=box( _("Guilds Joined : {guild_join}\n" "Guilds Left : {guild_remove}\n").format_map({ "guild_join": self.fetch("guild_join"), "guild_remove": self.fetch("guild_remove"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("User Stats"), value=box( _("New Users : {new_members}\n" "Left Users : {members_left}\n" "Banned Users : {members_banned}\n" "Unbanned Users : {members_unbanned}\n").format_map({ "new_members": self.fetch("new_members"), "members_left": self.fetch("members_left"), "members_banned": self.fetch("members_banned"), "members_unbanned": self.fetch("members_unbanned"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("Role Stats"), value=box( _("Roles Added : {roles_added}\n" "Roles Removed : {roles_removed}\n" "Roles Updated : {roles_updated}\n").format_map({ "roles_added": self.fetch("roles_added"), "roles_removed": self.fetch("roles_removed"), "roles_updated": self.fetch("roles_updated"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("Emoji Stats"), value=box( _("Reacts Added : {reactions_added}\n" "Reacts Removed : {reactions_removed}\n" "Emoji Added : {emojis_added}\n" "Emoji Removed : {emojis_removed}\n" "Emoji Updated : {emojis_updated}\n").format_map({ "reactions_added": self.fetch("reactions_added"), "reactions_removed": self.fetch("reactions_removed"), "emojis_added": self.fetch("emojis_added"), "emojis_removed": self.fetch("emojis_removed"), "emojis_updated": self.fetch("emojis_updated"), }), lang="prolog", ), inline=False, ) em.add_field( name=_("Audio Stats"), value=box( _("Users Who Joined VC : {users_joined_bot_music_room}\n" "Tracks Played : {tracks_played}\n" "Number Of Players : {ll_players}").format( users_joined_bot_music_room=self.fetch( "users_joined_bot_music_room"), tracks_played=self.fetch("tracks_played"), ll_players=ll_players, ), lang="prolog", ), inline=False, ) if Query: em.add_field( name=_("Track Stats"), value=box( _("Streams : {streams_played}\n" "YouTube Streams : {yt_streams_played}\n" "Mixer Streams : {mixer_streams_played}\n" "Twitch Streams : {ttv_streams_played}\n" "Other Streams : {streams_played}\n" "YouTube Tracks : {youtube_tracks}\n" "Soundcloud Tracks : {soundcloud_tracks}\n" "Bandcamp Tracks : {bandcamp_tracks}\n" "Vimeo Tracks : {vimeo_tracks}\n" "Mixer Tracks : {mixer_tracks}\n" "Twitch Tracks : {twitch_tracks}\n" "Other Tracks : {other_tracks}\n").format( streams_played=self.fetch("streams_played"), yt_streams_played=self.fetch("yt_streams_played"), mixer_streams_played=self.fetch( "mixer_streams_played"), ttv_streams_played=self.fetch("ttv_streams_played"), other_streams_played=self.fetch( "other_streams_played"), youtube_tracks=self.fetch("youtube_tracks"), soundcloud_tracks=self.fetch("soundcloud_tracks"), bandcamp_tracks=self.fetch("bandcamp_tracks"), vimeo_tracks=self.fetch("vimeo_tracks"), mixer_tracks=self.fetch("mixer_tracks"), twitch_tracks=self.fetch("twitch_tracks"), other_tracks=self.fetch("other_tracks"), ), lang="prolog", ), inline=False, ) em.set_thumbnail(url=avatar) em.set_footer(text=_("Since {}").format(uptime)) await ctx.send(embed=em)
async def advusagecount(self, ctx): avatar = self.bot.user.avatar_url_as(static_format="png") uptime = str(self.get_bot_uptime()) errors_count = "{:,}".format(self.counter["command_error"]) messages_read = "{:,}".format(self.counter["messages_read"]) messages_sent = "{:,}".format(self.counter["msg_sent"]) dms_received = "{:,}".format(self.counter["dms_received"]) guild_join = "{:,}".format(self.counter["guild_join"]) guild_leave = "{:,}".format(self.counter["guild_remove"]) resumed_sessions = "{:,}".format(self.counter["sessions_resumed"]) commands_count = "{:,}".format(self.counter["processed_commands"]) new_mem = "{:,}".format(self.counter["new_members"]) left_mem = "{:,}".format(self.counter["members_left"]) msg_deleted = "{:,}".format(self.counter["messages_deleted"]) msg_edited = "{:,}".format(self.counter["messages_edited"]) react_added = "{:,}".format(self.counter["reactions_added"]) react_removed = "{:,}".format(self.counter["reactions_removed"]) roles_add = "{:,}".format(self.counter["roles_added"]) roles_rem = "{:,}".format(self.counter["roles_removed"]) roles_up = "{:,}".format(self.counter["roles_updated"]) mem_ban = "{:,}".format(self.counter["members_banned"]) mem_unban = "{:,}".format(self.counter["members_unbanned"]) emoji_add = "{:,}".format(self.counter["emojis_added"]) emoji_rem = "{:,}".format(self.counter["emojis_removed"]) emoji_up = "{:,}".format(self.counter["emojis_updated"]) vc_joins = "{:,}".format(self.counter["users_joined_bot_music_room"]) tracks_played = "{:,}".format(self.counter["tracks_played"]) #streams_played = "{:,}".format(self.counter["streams_played"]) #yt_streams = "{:,}".format(self.counter["yt_streams_played"]) #mixer_streams = "{:,}".format(self.counter["mixer_streams_played"]) #ttv_streams = "{:,}".format(self.counter["ttv_streams_played"]) #other_streams = "{:,}".format(self.counter["other_streams_played"]) #youtube_tracks = "{:,}".format(self.counter["youtube_tracks"]) #soundcloud_tracks = "{:,}".format(self.counter["soundcloud_tracks"]) #bandcamp_tracks = "{:,}".format(self.counter["bandcamp_tracks"]) #vimeo_tracks = "{:,}".format(self.counter["vimeo_tracks"]) #mixer_tracks = "{:,}".format(self.counter["mixer_tracks"]) #twitch_tracks = "{:,}".format(self.counter["twitch_tracks"]) #other_tracks = "{:,}".format(self.counter["other_tracks"]) try: total_num = "{:,}/{:,}".format(len(lavalink.active_players()), len(lavalink.all_players())) except AttributeError: total_num = "{:,}/{:,}".format( len([p for p in lavalink.players if p.current is not None]), len([p for p in lavalink.players]), ) em = discord.Embed( title=_("Usage count of {} since last restart:").format( ctx.bot.user.name), color=await ctx.embed_colour()) em.add_field(name=_("Message Stats"), value=box(_(""" Messages Read: {} Messages Sent: {} Messages Deleted: {} Messages Edited {} DMs Recieved: {}""").format(messages_read, messages_sent, msg_deleted, msg_edited, dms_received), lang="prolog"), inline=False) em.add_field(name=_("Commands Stats"), value=box(_(""" Commands Processed: {} Errors Occured: {} Sessions Resumed: {}""").format(commands_count, errors_count, resumed_sessions), lang="prolog"), inline=False) em.add_field(name=_("Guild Stats"), value=box(_(""" Guilds Joined: {} Guilds Left: {}""").format(guild_join, guild_leave), lang="prolog"), inline=False) em.add_field(name=_("User Stats"), value=box(_(""" New Users: {} Left Users: {} Banned Users: {} Unbanned Users: {}""").format(new_mem, left_mem, mem_ban, mem_unban), lang="prolog"), inline=False) em.add_field(name=_("Role Stats"), value=box(_(""" Roles Added: {} Roles Removed: {} Roles Updated: {}""").format(roles_add, roles_rem, roles_up), lang="prolog"), inline=False) em.add_field(name=_("Emoji Stats"), value=box(_(""" Reacts Added: {} Reacts Removed: {} Emoji Added: {} Emoji Removed: {} Emoji Updated: {}""").format(react_added, react_removed, emoji_add, emoji_rem, emoji_up), lang="prolog"), inline=False) em.add_field(name=_("Audio Stats"), value=box(_(""" Users Who Joined VC: {} Tracks Played: {} Number Of Players: {}""").format(vc_joins, tracks_played, total_num), lang="prolog"), inline=False) em.set_thumbnail(url=avatar) em.set_footer(text=_("Since {}").format(uptime)) await ctx.send(embed=em)
async def botinfo(self, ctx: commands.Context): """Show bot information. `details`: Shows more information when set to `True`. Default to False. """ async with ctx.typing(): vc_regions = { "eu-west": _("EU West ") + "\U0001F1EA\U0001F1FA", "eu-central": _("EU Central ") + "\U0001F1EA\U0001F1FA", "europe": _("Europe ") + "\U0001F1EA\U0001F1FA", "london": _("London ") + "\U0001F1EC\U0001F1E7", "frankfurt": _("Frankfurt ") + "\U0001F1E9\U0001F1EA", "amsterdam": _("Amsterdam ") + "\U0001F1F3\U0001F1F1", "us-west": _("US West ") + "\U0001F1FA\U0001F1F8", "us-east": _("US East ") + "\U0001F1FA\U0001F1F8", "us-south": _("US South ") + "\U0001F1FA\U0001F1F8", "us-central": _("US Central ") + "\U0001F1FA\U0001F1F8", "singapore": _("Singapore ") + "\U0001F1F8\U0001F1EC", "sydney": _("Sydney ") + "\U0001F1E6\U0001F1FA", "brazil": _("Brazil ") + "\U0001F1E7\U0001F1F7", "hongkong": _("Hong Kong ") + "\U0001F1ED\U0001F1F0", "russia": _("Russia ") + "\U0001F1F7\U0001F1FA", "japan": _("Japan ") + "\U0001F1EF\U0001F1F5", "southafrica": _("South Africa ") + "\U0001F1FF\U0001F1E6", "india": _("India ") + "\U0001F1EE\U0001F1F3", "dubai": _("Dubai ") + "\U0001F1E6\U0001F1EA", "south-korea": _("South Korea ") + "\U0001f1f0\U0001f1f7", "EU West": _("EU West ") + "\U0001F1EA\U0001F1FA", "EU Central": _("EU Central ") + "\U0001F1EA\U0001F1FA", "Europe": _("Europe ") + "\U0001F1EA\U0001F1FA", "London": _("London ") + "\U0001F1EC\U0001F1E7", "Frankfurt": _("Frankfurt ") + "\U0001F1E9\U0001F1EA", "Amsterdam": _("Amsterdam ") + "\U0001F1F3\U0001F1F1", "US West": _("US West ") + "\U0001F1FA\U0001F1F8", "US East": _("US East ") + "\U0001F1FA\U0001F1F8", "US South": _("US South ") + "\U0001F1FA\U0001F1F8", "US Central": _("US Central ") + "\U0001F1FA\U0001F1F8", "Singapore": _("Singapore ") + "\U0001F1F8\U0001F1EC", "Sydney": _("Sydney ") + "\U0001F1E6\U0001F1FA", "Brazil": _("Brazil ") + "\U0001F1E7\U0001F1F7", "Hong Kong": _("Hong Kong ") + "\U0001F1ED\U0001F1F0", "Russia": _("Russia ") + "\U0001F1F7\U0001F1FA", "Japan": _("Japan ") + "\U0001F1EF\U0001F1F5", "South Africa": _("South Africa ") + "\U0001F1FF\U0001F1E6", "India": _("India ") + "\U0001F1EE\U0001F1F3", "Dubai": _("Dubai ") + "\U0001F1E6\U0001F1EA", "South Korea": _("South Korea ") + "\U0001f1f0\U0001f1f7", } verif = { "none": _("None"), "low": _("Low"), "medium": _("Medium"), "high": _("High"), "extreme": _("Extreme"), } features = { "VIP_REGIONS": _("VIP Voice Servers"), "VANITY_URL": _("Vanity URL"), "INVITE_SPLASH": _("Splash Invite"), "VERIFIED": _("Verified"), "PARTNERED": _("Partnered"), "MORE_EMOJI": _("More Emojis"), "DISCOVERABLE": _("Server Discovery"), "FEATURABLE": _("Featurable"), "COMMERCE": _("Commerce"), "PUBLIC": _("Public"), "NEWS": _("News Channels"), "BANNER": _("Banner Image"), "ANIMATED_ICON": _("Animated Icon"), "PUBLIC_DISABLED": _("Public disabled"), "MEMBER_LIST_DISABLED": _("Member list disabled"), "ENABLED_DISCOVERABLE_BEFORE": _("Was in Server Discovery"), "WELCOME_SCREEN_ENABLED": _("Welcome Screen"), } audio_cog = self.bot.get_cog("Audio") bot_has_stats = getattr(self.bot, "stats", None) if not bot_has_stats: counter = Counter() counter["guild_count"] = len(self.bot.guilds) counter["active_music_players"] = len( lavalink.active_players()) counter["total_music_players"] = len(lavalink.all_players()) counter["inactive_music_players"] = ( counter["total_music_players"] - counter["active_music_players"]) counter["discord_latency"] = int(round(self.bot.latency * 1000)) counter["shards"] = self.bot.shard_count temp_data = defaultdict(set) region_count = Counter() verif_count = Counter() features_count = Counter() async for s in AsyncIter(self.bot.guilds, steps=1000, delay=0): if s.unavailable: temp_data["unavailable"].add(s.id) continue async for f in AsyncIter(s.features, steps=1000, delay=0): features_count[f] += 1 verif_count[f"{s.verification_level}"] += 1 region_count[f"{s.region}"] += 1 counter["channel_categories_count"] += len(s.categories) counter["guild_channel_count"] += len(s.channels) counter["guild_text_channel_count"] += len(s.text_channels) counter["guild_voice_channel_count"] += len( s.voice_channels) counter["role_count"] += len(s.roles) counter["emoji_count"] += len(s.emojis) if s.large: temp_data["large_guilds"].add(s.id) if not s.chunked: temp_data["not_chunked_guilds"].add(s.id) if s.premium_tier != 0: temp_data["boosted_servers"].add(s.id) if s.premium_tier == 1: temp_data["tier_1_count"].add(s.id) elif s.premium_tier == 2: temp_data["tier_2_count"].add(s.id) elif s.premium_tier == 3: temp_data["tier_3_count"].add(s.id) async for c in AsyncIter(s.text_channels, steps=1000, delay=0): if c.is_nsfw(): temp_data["nsfw_text_channel_count"].add(c.id) if c.is_news(): temp_data["news_text_channel_count"].add(c.id) if c.type is discord.ChannelType.store: temp_data["store_text_channel_count"].add(c.id) async for vc in AsyncIter(s.voice_channels, steps=1000, delay=0): counter["user_voice_channel_count"] += len(vc.members) if s.me in vc.members: counter["user_voice_channel_with_me_count"] += len( vc.members) - 1 counter["bots_voice_channel_with_me_count"] += sum( 1 for m in vc.members if m.bot) - 1 async for vcm in AsyncIter(vc.members, steps=1000, delay=0): if vcm.is_on_mobile(): temp_data[ "user_voice_channel_mobile_count"].add( vcm.id) async for e in AsyncIter(s.emojis, steps=1000, delay=0): if e.animated: counter["animated_emojis"] += 1 else: counter["static_emojis"] += 1 async for m in AsyncIter(s.members, steps=1000, delay=0): if m.bot: temp_data["bots"].add(m.id) else: temp_data["humans"].add(m.id) temp_data["unique_user"].add(m.id) if m.is_on_mobile(): temp_data["mobile_users"].add(m.id) streaming = False async for a in AsyncIter(m.activities, steps=1000, delay=0): if a.type is discord.ActivityType.streaming: temp_data["streaming_users"].add(m.id) if m.bot: temp_data["streaming_bots"].add(m.id) else: temp_data["streaming_human"].add(m.id) streaming = True elif a.type is discord.ActivityType.playing: temp_data["gaming_users"].add(m.id) if m.bot: temp_data["gaming_bots"].add(m.id) else: temp_data["gaming_human"].add(m.id) if a.type is discord.ActivityType.listening: temp_data["listening_users"].add(m.id) if m.bot: temp_data["listening_bots"].add(m.id) else: temp_data["listening_human"].add(m.id) if a.type is discord.ActivityType.watching: temp_data["watching_users"].add(m.id) if m.bot: temp_data["watching_bots"].add(m.id) else: temp_data["watching_human"].add(m.id) if a.type is discord.ActivityType.custom: temp_data["custom_users"].add(m.id) if m.bot: temp_data["custom_bots"].add(m.id) else: temp_data["custom_human"].add(m.id) if not streaming: if m.status is discord.Status.online: temp_data["online_users"].add(m.id) if m.bot: temp_data["online_bots"].add(m.id) else: temp_data["online_human"].add(m.id) elif m.status is discord.Status.idle: temp_data["idle_users"].add(m.id) if m.bot: temp_data["idle_bots"].add(m.id) else: temp_data["idle_human"].add(m.id) elif m.status is discord.Status.do_not_disturb: temp_data["do_not_disturb_users"].add(m.id) if m.bot: temp_data["do_not_disturb_bots"].add(m.id) else: temp_data["do_not_disturb_human"].add(m.id) elif m.status is discord.Status.offline: temp_data["offline_users"].add(m.id) if m.bot: temp_data["offline_bots"].add(m.id) else: temp_data["offline_human"].add(m.id) if m.mobile_status is discord.Status.online: temp_data["mobile_online_users"].add(m.id) elif m.mobile_status is discord.Status.idle: temp_data["mobile_idle_users"].add(m.id) elif m.mobile_status is discord.Status.do_not_disturb: temp_data["mobile_do_not_disturb_users"].add(m.id) elif m.mobile_status is discord.Status.offline: temp_data["mobile_offline_users"].add(m.id) if m.desktop_status is discord.Status.online: temp_data["desktop_online_users"].add(m.id) elif m.desktop_status is discord.Status.idle: temp_data["desktop_idle_users"].add(m.id) elif m.desktop_status is discord.Status.do_not_disturb: temp_data["desktop_do_not_disturb_users"].add(m.id) elif m.desktop_status is discord.Status.offline: temp_data["desktop_offline_users"].add(m.id) if m.web_status is discord.Status.online: temp_data["web_online_users"].add(m.id) elif m.web_status is discord.Status.idle: temp_data["web_idle_users"].add(m.id) elif m.web_status is discord.Status.do_not_disturb: temp_data["web_do_not_disturb_users"].add(m.id) elif m.web_status is discord.Status.offline: temp_data["web_offline_users"].add(m.id) for key, value in temp_data.items(): counter[key] = len(value) online_stats = { "\N{LARGE GREEN CIRCLE}": counter["online_users"], "\N{LARGE ORANGE CIRCLE}": counter["idle_users"], "\N{LARGE RED CIRCLE}": counter["do_not_disturb_users"], "\N{MEDIUM WHITE CIRCLE}": counter["offline_users"], "\N{LARGE PURPLE CIRCLE}": counter["streaming_users"], "\N{MOBILE PHONE}": counter["mobile_users"], "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": counter["streaming_users"], "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": counter["gaming_users"], "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": counter["listening_users"], "\N{TELEVISION}\N{VARIATION SELECTOR-16}": counter["watching_users"], _("Custom"): counter["custom_users"], } online_stats_web = { "\N{LARGE GREEN CIRCLE}": counter["web_online_users"], "\N{LARGE ORANGE CIRCLE}": counter["web_idle_users"], "\N{LARGE RED CIRCLE}": counter["web_do_not_disturb_users"], "\N{MEDIUM WHITE CIRCLE}": counter["web_offline_users"], } online_stats_mobile = { "\N{LARGE GREEN CIRCLE}": counter["mobile_online_users"], "\N{LARGE ORANGE CIRCLE}": counter["mobile_idle_users"], "\N{LARGE RED CIRCLE}": counter["mobile_do_not_disturb_users"], "\N{MEDIUM WHITE CIRCLE}": counter["mobile_offline_users"], } online_stats_desktop = { "\N{LARGE GREEN CIRCLE}": counter["desktop_online_users"], "\N{LARGE ORANGE CIRCLE}": counter["desktop_idle_users"], "\N{LARGE RED CIRCLE}": counter["desktop_do_not_disturb_users"], "\N{MEDIUM WHITE CIRCLE}": counter["desktop_offline_users"], } online_stats_bots = { "\N{LARGE GREEN CIRCLE}": counter["online_bots"], "\N{LARGE ORANGE CIRCLE}": counter["idle_bots"], "\N{LARGE RED CIRCLE}": counter["do_not_disturb_bots"], "\N{MEDIUM WHITE CIRCLE}": counter["offline_bots"], "\N{LARGE PURPLE CIRCLE}": counter["streaming_bots"], "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": counter["streaming_bots"], "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": counter["gaming_bots"], "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": counter["listening_bots"], "\N{TELEVISION}\N{VARIATION SELECTOR-16}": counter["watching_bots"], _("Custom"): counter["custom_bots"], } online_stats_humans = { "\N{LARGE GREEN CIRCLE}": counter["online_human"], "\N{LARGE ORANGE CIRCLE}": counter["idle_human"], "\N{LARGE RED CIRCLE}": counter["do_not_disturb_human"], "\N{MEDIUM WHITE CIRCLE}": counter["offline_human"], "\N{LARGE PURPLE CIRCLE}": counter["streaming_human"], "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": counter["streaming_human"], "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": counter["gaming_human"], "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": counter["listening_human"], "\N{TELEVISION}\N{VARIATION SELECTOR-16}": counter["watching_human"], _("Custom"): counter["custom_human"], } else: online_stats = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Users Online", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Idle Users", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Users in Do Not Disturb", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Users Offline", 0), "\N{LARGE PURPLE CIRCLE}": getattr(self.bot.stats.bot, "Users Streaming", 0), "\N{MOBILE PHONE}": getattr(self.bot.stats.bot, "Users Online on Mobile", 0), "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Users Streaming", 0), "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Users Gaming", 0), "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Users Listening", 0), "\N{TELEVISION}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Users Watching", 0), _("Custom"): getattr(self.bot.stats.bot, "Users with Custom Status", 0), } online_stats_web = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Users Online on Browser", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Users Idle on Browser", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Users in Do Not Disturb on Browser", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Users Offline on Browser", 0), } online_stats_mobile = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Users Online on Mobile", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Users Idle on Mobile", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Users in Do Not Disturb on Mobile", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Users Offline on Mobile", 0), } online_stats_desktop = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Users Online on Desktop", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Users Idle on Desktop", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Users in Do Not Disturb on Desktop", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Users Offline on Desktop", 0), } online_stats_bots = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Bots Online", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Idle Bots", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Bots in Do Not Disturb", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Bots Offline", 0), "\N{LARGE PURPLE CIRCLE}": getattr(self.bot.stats.bot, "Bots Streaming", 0), "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Bots Streaming", 0), "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Bots Gaming", 0), "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Bots Listening", 0), "\N{TELEVISION}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Bots Watching", 0), _("Custom"): getattr(self.bot.stats.bot, "Bots with Custom Status", 0), } online_stats_humans = { "\N{LARGE GREEN CIRCLE}": getattr(self.bot.stats.bot, "Humans Online", 0), "\N{LARGE ORANGE CIRCLE}": getattr(self.bot.stats.bot, "Idle Humans", 0), "\N{LARGE RED CIRCLE}": getattr(self.bot.stats.bot, "Humans in Do Not Disturb", 0), "\N{MEDIUM WHITE CIRCLE}": getattr(self.bot.stats.bot, "Humans Offline", 0), "\N{LARGE PURPLE CIRCLE}": getattr(self.bot.stats.bot, "Humans Streaming", 0), "\N{CLAPPER BOARD}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Humans Streaming", 0), "\N{VIDEO GAME}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Humans Gaming", 0), "\N{HEADPHONE}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Humans Listening", 0), "\N{TELEVISION}\N{VARIATION SELECTOR-16}": getattr(self.bot.stats.bot, "Humans Watching", 0), _("Custom"): getattr(self.bot.stats.bot, "Humans with Custom Status", 0), } since = self.bot.uptime.strftime("%Y-%m-%d %H:%M:%S") delta = datetime.datetime.utcnow() - self.bot.uptime uptime_str = humanize_timedelta( timedelta=delta) or _("Less than one second") description = _( "Uptime: **{time_quantity}** (since {timestamp} UTC)").format( time_quantity=uptime_str, timestamp=since) data = discord.Embed( description=description, colour=await ctx.embed_colour(), ) data.set_author(name=str(ctx.me), icon_url=ctx.me.avatar_url) if not bot_has_stats: member_msg = _( "Users online: {online}/{total_users}\nHumans: {humans}\nBots: {bots}\n" ).format( online=bold(humanize_number(counter["online_users"])), total_users=bold(humanize_number(counter["unique_user"])), humans=bold(humanize_number(counter["humans"])), bots=bold(humanize_number(counter["bots"])), ) else: member_msg = _( "Users online: {online}/{total_users}\nHumans: {humans}\nBots: {bots}\n" ).format( online=bold( humanize_number( getattr(self.bot.stats.bot, "Users Online", 0))), total_users=bold( humanize_number( getattr(self.bot.stats.bot, "Unique Users", 0))), humans=bold( humanize_number( getattr(self.bot.stats.bot, "Humans Online", 0))), bots=bold( humanize_number( getattr(self.bot.stats.bot, "Bots Online", 0))), ) count = 1 for emoji, value in online_stats.items(): member_msg += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 if not bot_has_stats: data.add_field( name=_("General:"), value=_( "Servers: {total}\n" "Discord latency: {lat}ms\n" "Shard count: {shards}\n" "Large servers: {large}\n" "Unchunked servers: {chuncked}\n" "Unavailable servers: {unavaliable}\n").format( lat=bold(humanize_number(counter["discord_latency"])), shards=bold(humanize_number(counter["shards"])), total=bold(humanize_number(counter["guild_count"])), large=bold(humanize_number(counter["large_guilds"])), chuncked=bold( humanize_number(counter["not_chunked_guilds"])), unavaliable=bold( humanize_number(counter["unavaliable_guilds"])), ), ) else: data.add_field( name=_("General:"), value=_("Servers: {total}\n" "Discord latency: {lat}ms\n" "Shard count: {shards}\n" "Large servers: {large}\n" "Unchunked servers: {chuncked}\n" "Unavailable servers: {unavaliable}\n").format( lat=bold( humanize_number( getattr(self.bot.stats.bot, "Discord Latency", 0))), shards=bold( humanize_number( getattr(self.bot.stats.bot, "Shards", 0))), total=bold( humanize_number( getattr(self.bot.stats.guilds, "Total", 0))), large=bold( humanize_number( getattr(self.bot.stats.guilds, "Large", 0))), chuncked=bold( humanize_number( getattr(self.bot.stats.guilds, "Unchunked", 0))), unavaliable=bold( humanize_number( getattr(self.bot.stats.guilds, "Unavailable", 0))), ), ) verif_data = "" if not bot_has_stats: for r, value in sorted(verif_count.items(), reverse=False): if value: verif_data += f"{bold(humanize_number(value))} - {verif.get(r)}\n" else: for k, value in sorted( self.bot.stats.guild_verification.__dict__.items(), reverse=False): if value: verif_data += f"{bold(humanize_number(value))} - {k}\n" if verif_data: data.add_field(name=_("Server Verification:"), value=verif_data) if not bot_has_stats: data.add_field( name=_("Nitro boosts:"), value= _("Total: {total}\n" "\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Level: {text}\n" "\N{DIGIT TWO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Levels: {voice}\n" "\N{DIGIT THREE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Levels: {users}" ).format( total=bold(humanize_number(counter["boosted_servers"])), text=bold(humanize_number(counter["tier_1_count"])), voice=bold(humanize_number(counter["tier_2_count"])), users=bold(humanize_number(counter["tier_3_count"])), ), ) else: data.add_field( name=_("Nitro boosts:"), value= _("Total: {total}\n" "\N{DIGIT ONE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Level: {text}\n" "\N{DIGIT TWO}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Levels: {voice}\n" "\N{DIGIT THREE}\N{VARIATION SELECTOR-16}\N{COMBINING ENCLOSING KEYCAP} Levels: {users}" ).format( total=bold( humanize_number( getattr(self.bot.stats.guilds, "Nitro Boosted", 0))), text=bold( humanize_number( getattr(self.bot.stats.guilds, "Tier 1 Nitro", 0))), voice=bold( humanize_number( getattr(self.bot.stats.guilds, "Tier 2 Nitro", 0))), users=bold( humanize_number( getattr(self.bot.stats.guilds, "Tier 3 Nitro", 0))), ), ) if not bot_has_stats: data.add_field( name=_("Channels:"), value= _("\N{SPEECH BALLOON} \N{SPEAKER WITH THREE SOUND WAVES} Total Channels: {total}\n" "\N{BOOKMARK TABS} Categories: {categories}\n" "\N{SPEECH BALLOON} Text Channels: {text}\n" "\N{MONEY BAG} Store Channels: {store}\n" "\N{NO ONE UNDER EIGHTEEN SYMBOL} NSFW Channels: {nsfw}\n" "\N{NEWSPAPER} News Channels: {news}\n" "\N{SPEAKER WITH THREE SOUND WAVES} Voice Channels: {voice}\n" "\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Users in VC: {users}\n" "\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16}\N{MOBILE PHONE} Users in VC on Mobile: {users_mobile}\n" "\N{BUST IN SILHOUETTE}\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Users in VC with me: {with_me}\n" "\N{ROBOT FACE}\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Bots in VC with me: {bot_with_me}\n" ).format( store=bold( humanize_number( counter["store_text_channel_count"])), nsfw=bold( humanize_number(counter["nsfw_text_channel_count"])), news=bold( humanize_number(counter["news_text_channel_count"])), users_mobile=bold( humanize_number( counter["user_voice_channel_mobile_count"])), total=bold( humanize_number(counter["guild_channel_count"])), text=bold( humanize_number( counter["guild_text_channel_count"])), voice=bold( humanize_number( counter["guild_voice_channel_count"])), users=bold( humanize_number( counter["user_voice_channel_count"])), with_me=bold( humanize_number( counter["user_voice_channel_with_me_count"])), categories=bold( humanize_number( counter["channel_categories_count"])), bot_with_me=bold( humanize_number( counter["bots_voice_channel_with_me_count"])), ), ) else: data.add_field( name=_("Channels:"), value= _("\N{SPEECH BALLOON} \N{SPEAKER WITH THREE SOUND WAVES} Total Channels: {total}\n" "\N{BOOKMARK TABS} Categories: {categories}\n" "\N{SPEECH BALLOON} Text Channels: {text}\n" "\N{MONEY BAG} Store Channels: {store}\n" "\N{NO ONE UNDER EIGHTEEN SYMBOL} NSFW Channels: {nsfw}\n" "\N{NEWSPAPER} News Channels: {news}\n" "\N{SPEAKER WITH THREE SOUND WAVES} Voice Channels: {voice}\n" "\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Users in VC: {users}\n" "\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16}\N{MOBILE PHONE} Users in VC on Mobile: {users_mobile}\n" "\N{BUST IN SILHOUETTE}\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Users in VC with me: {with_me}\n" "\N{ROBOT FACE}\N{STUDIO MICROPHONE}\N{VARIATION SELECTOR-16} Bots in VC with me: {bot_with_me}\n" ).format( store=bold( humanize_number( getattr(self.bot.stats.bot, "Store Text Channels", 0))), nsfw=bold( humanize_number( getattr(self.bot.stats.bot, "NSFW Text Channels", 0))), news=bold( humanize_number( getattr(self.bot.stats.bot, "News Text Channels", 0))), users_mobile=bold( humanize_number( getattr(self.bot.stats.bot, "Users in a VC on Mobile", 0))), total=bold( humanize_number( getattr(self.bot.stats.guilds, "Server Channels", 0))), text=bold( humanize_number( getattr(self.bot.stats.guilds, "Text Channels", 0))), voice=bold( humanize_number( getattr(self.bot.stats.guilds, "Voice Channels", 0))), users=bold( humanize_number( getattr(self.bot.stats.guilds, "Users in a VC", 0))), with_me=bold( humanize_number( getattr(self.bot.stats.guilds, "Users in a VC with me", 0))), categories=bold( humanize_number( getattr(self.bot.stats.guilds, "Channel Categories", 0))), bot_with_me=bold( humanize_number( getattr(self.bot.stats.guilds, "Bots in a VC with me", 0))), ), ) region_data = "" if not bot_has_stats: for r, value in sorted(region_count.items(), reverse=False): if value: region_data += f"{bold(humanize_number(value))} - {vc_regions.get(r)}\n" else: for r, value in sorted( self.bot.stats.guilds_regions.__dict__.items(), reverse=False): if value: region_data += f"{bold(humanize_number(value))} - {vc_regions.get(r)}\n" if region_data: data.add_field(name=_("Regions:"), value=region_data) features_data = "" if not bot_has_stats: for r, value in sorted(features_count.items(), reverse=False): if value: features_data += f"{bold(humanize_number(value))} - {features.get(r) or r}\n" else: for k, value in sorted( self.bot.stats.guild_features.__dict__.items(), reverse=False): if value: features_data += f"{bold(humanize_number(value))} - {k}\n" if features_data: data.add_field(name=_("Features:"), value=features_data) if not bot_has_stats: data.add_field( name=_("Misc:"), value=_("Total Roles: {total}\n" "Total Custom Emojis: {emoji_count}\n" "Total Animated Emojis: {animated_emoji}\n" "Total Static Emojis: {static_emojis}\n").format( total=bold(humanize_number(counter["role_count"])), emoji_count=bold( humanize_number(counter["emoji_count"])), animated_emoji=bold( humanize_number(counter["animated_emojis"])), static_emojis=bold( humanize_number(counter["static_emojis"])), ), ) else: data.add_field( name=_("Misc:"), value=_("Total Roles: {total}\n" "Total Custom Emojis: {emoji_count}\n" "Total Animated Emojis: {animated_emoji}\n" "Total Static Emojis: {static_emojis}\n" "Total Currency: {currency}\n").format( total=bold( humanize_number( getattr(self.bot.stats.guilds, "Roles", 0))), emoji_count=bold( humanize_number( getattr(self.bot.stats.guilds, "Emojis", 0))), animated_emoji=bold( humanize_number( getattr(self.bot.stats.guilds, "Animated Emojis", 0))), static_emojis=bold( humanize_number( getattr(self.bot.stats.guilds, "Static Emojis", 0))), currency=bold( humanize_number( getattr(self.bot.stats.currency, "Currency In Circulation", 0))), ), ) if member_msg: data.add_field(name=_("Members:"), value=member_msg) member_msg_web = "" count = 1 for emoji, value in online_stats_web.items(): member_msg_web += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 member_msg_mobile = "" count = 1 for emoji, value in online_stats_mobile.items(): member_msg_mobile += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 member_msg_desktop = "" count = 1 for emoji, value in online_stats_desktop.items(): member_msg_desktop += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 member_msg_bots = "" count = 1 for emoji, value in online_stats_bots.items(): member_msg_bots += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 member_msg_humans = "" count = 1 for emoji, value in online_stats_humans.items(): member_msg_humans += f"{emoji} {bold(humanize_number(value))} " + ( "\n" if count % 2 == 0 else "") count += 1 if member_msg_humans: data.add_field(name=_("Human Statuses:"), value=member_msg_humans) if member_msg_bots: data.add_field(name=_("Bot Statuses:"), value=member_msg_bots) if member_msg_desktop: data.add_field(name=_("Desktop Statuses:"), value=member_msg_desktop) if member_msg_web: data.add_field(name=_("Web Statuses:"), value=member_msg_web) if member_msg_mobile: data.add_field(name=_("Mobile Statuses:"), value=member_msg_mobile) shard_latencies = "" count = 1 for shard_id, latency in self.bot.latencies: shard_latencies += ( f"Shard {shard_id + 1} - {bold(humanize_number(int(latency*1000)))}ms\n" ) count += 1 loaded = set(ctx.bot.extensions.keys()) all_cogs = set(await self.bot._cog_mgr.available_modules()) unloaded = all_cogs - loaded commands = list(self.bot.walk_commands()) data.add_field( name=_("Bot Extensions:"), value=_("Available Cogs: {cogs}\n" "Loaded Cogs: {loaded}\n" "Unloaded Cogs: {unloaded}\nCommands: {commands}").format( cogs=bold(humanize_number(len(all_cogs))), loaded=bold(humanize_number(len(loaded))), unloaded=bold(humanize_number(len(unloaded))), commands=bold(humanize_number(len(commands))), ), ) if audio_cog and not bot_has_stats: data.add_field( name=_("Audio Stats:"), value=_( "Total Players: {total}\n" "Active Players: {active}\n" "Inactive Players: {inactive}").format( total=bold( humanize_number(counter["total_music_players"])), active=bold( humanize_number(counter["active_music_players"])), inactive=bold( humanize_number( counter["inactive_music_players"])), ), ) elif audio_cog and bot_has_stats: data.add_field( name=_("Audio Stats:"), value=_("Total Players: {total}\n" "Active Players: {active}\n" "Inactive Players: {inactive}").format( total=bold( humanize_number( getattr(self.bot.stats.audio, "Music Players"))), active=bold( humanize_number( getattr(self.bot.stats.audio, "Active Music Players"))), inactive=bold( humanize_number( getattr(self.bot.stats.audio, "Inactive Music Players"))), ), ) if shard_latencies: data.add_field(name=_("Shard Latencies:"), value=shard_latencies) await ctx.send(embed=data)
async def alltimestats(self, ctx): """ Persistent stats about the bot """ avatar = self.bot.user.avatar_url_as(static_format="png") uptime = str(self.get_bot_uptime()) errors_count = "{:,}".format(await self.config.command_error()) messages_read = "{:,}".format(await self.config.messages_read()) messages_sent = "{:,}".format(await self.config.msg_sent()) dms_received = "{:,}".format(await self.config.dms_received()) guild_join = "{:,}".format(await self.config.guild_join()) guild_leave = "{:,}".format(await self.config.guild_remove()) resumed_sessions = "{:,}".format(await self.config.sessions_resumed()) commands_count = "{:,}".format(await self.config.processed_commands()) new_mem = "{:,}".format(await self.config.new_members()) left_mem = "{:,}".format(await self.config.members_left()) msg_deleted = "{:,}".format(await self.config.messages_deleted()) msg_edited = "{:,}".format(await self.config.messages_edited()) react_added = "{:,}".format(await self.config.reactions_added()) react_removed = "{:,}".format(await self.config.reactions_removed()) roles_add = "{:,}".format(await self.config.roles_added()) roles_rem = "{:,}".format(await self.config.roles_removed()) roles_up = "{:,}".format(await self.config.roles_updated()) mem_ban = "{:,}".format(await self.config.members_banned()) mem_unban = "{:,}".format(await self.config.members_unbanned()) emoji_add = "{:,}".format(await self.config.emojis_added()) emoji_rem = "{:,}".format(await self.config.emojis_removed()) emoji_up = "{:,}".format(await self.config.emojis_updated()) vc_joins = "{:,}".format(await self.config.users_joined_bot_music_room()) tracks_played = "{:,}".format(self.counter["tracks_played"]) # streams_played = "{:,}".format(await self.config.streams_played()) # yt_streams = "{:,}".format(await self.config.yt_streams_played()) # mixer_streams = "{:,}".format(await self.config.mixer_streams_played()) # ttv_streams = "{:,}".format(await self.config.ttv_streams_played()) # other_streams = "{:,}".format(await self.config.other_streams_played()) # youtube_tracks = "{:,}".format(await self.config.youtube_tracks()) # soundcloud_tracks = "{:,}".format(await self.config.soundcloud_tracks()) # bandcamp_tracks = "{:,}".format(await self.config.bandcamp_tracks()) # vimeo_tracks = "{:,}".format(await self.config.vimeo_tracks()) # mixer_tracks = "{:,}".format(await self.config.mixer_tracks()) # twitch_tracks = "{:,}".format(await self.config.twitch_tracks()) # other_tracks = "{:,}".format(await self.config.other_tracks()) try: total_num = "{:,}/{:,}".format(len(lavalink.active_players()), len(lavalink.all_players())) except AttributeError: total_num = "{:,}/{:,}".format( len([p for p in lavalink.players if p.current is not None]), len([p for p in lavalink.players]), ) em = discord.Embed( title="Persistent usage count of {}:".format(ctx.bot.user.name), color=await ctx.embed_colour(), ) em.add_field( name="Message Stats", value=box( f""" Messages Read: {messages_read} Messages Sent: {messages_sent} Messages Deleted: {msg_deleted} Messages Edited {msg_edited} DMs Recieved: {dms_received}""", lang="prolog", ), inline=False, ) em.add_field( name="Commands Stats", value=box( f""" Commands Processed: {commands_count} Errors Occured: {errors_count} Sessions Resumed: {resumed_sessions}""", lang="prolog", ), inline=False, ) em.add_field( name="Guild Stats", value=box( f""" Guilds Joined: {guild_join} Guilds Left: {guild_leave}""", lang="prolog", ), inline=False, ) em.add_field( name="User Stats", value=box( f""" New Users: {new_mem} Left Users: {left_mem} Banned Users: {mem_ban} Unbanned Users: {mem_unban}""", lang="prolog", ), inline=False, ) em.add_field( name="Role Stats", value=box( f""" Roles Added: {roles_add} Roles Removed: {roles_rem} Roles Updated: {roles_up}""", lang="prolog", ), inline=False, ) em.add_field( name="Emoji Stats", value=box( f""" Reacts Added: {react_added} Reacts Removed: {react_removed} Emoji Added: {emoji_add} Emoji Removed: {emoji_rem} Emoji Updated: {emoji_up}""", lang="prolog", ), inline=False, ) em.add_field( name="Audio Stats", value=box( f""" Users Who Joined VC: {vc_joins} Tracks Played: {tracks_played} Number Of Players: {total_num}""", lang="prolog", ), inline=False, ) em.set_thumbnail(url=avatar) em.set_footer(text=("Since {}").format(uptime)) await ctx.send(embed=em)
async def botstat(self, ctx): """ Get stats about the bot including messages sent and recieved and other info. """ async with ctx.typing(): cpustats = psutil.cpu_percent() ramusage = psutil.virtual_memory() netusage = psutil.net_io_counters() width = max([ len(self._size(n)) for n in [netusage.bytes_sent, netusage.bytes_recv] ]) net_ios = ("\u200b" "\n" "{sent_text:<11}: {sent:>{width}}\n" "{recv_text:<11}: {recv:>{width}}").format( sent_text="Bytes sent", sent=self._size(netusage.bytes_sent), width=width, recv_text="Bytes recv", recv=self._size(netusage.bytes_recv), ) IS_WINDOWS = os.name == "nt" IS_MAC = sys.platform == "darwin" IS_LINUX = sys.platform == "linux" if IS_WINDOWS: os_info = platform.uname() osver = "``{} {} (version {})``".format( os_info.system, os_info.release, os_info.version) elif IS_MAC: os_info = platform.mac_ver() osver = "``Mac OSX {} {}``".format(os_info[0], os_info[2]) elif IS_LINUX: os_info = distro.linux_distribution() osver = "``{} {}``".format(os_info[0], os_info[1]).strip() else: osver = "Could not parse OS, report this on Github." try: cpu = cpuinfo.get_cpu_info()["brand"] except: cpu = "unknown" cpucount = psutil.cpu_count() ramamount = psutil.virtual_memory() ram_ios = "{0:<11} {1:>{width}}".format("", self._size( ramamount.total), width=width) servers = len(self.bot.guilds) shards = self.bot.shard_count totalusers = sum(len(s.members) for s in self.bot.guilds) channels = sum(len(s.channels) for s in self.bot.guilds) numcommands = len(self.bot.commands) uptime = str(self.get_bot_uptime()) tracks_played = "`{:,}`".format(self.counter["tracks_played"]) try: total_num = "`{:,}`".format(len(lavalink.active_players())) except AttributeError: total_num = "`{:,}`".format( len([p for p in lavalink.players if p.current is not None])) red = red_version_info dpy = discord.__version__ embed = discord.Embed( title="Bot Stats for {}".format(ctx.bot.user.name), description= "Below are various stats about the bot and the machine that runs the bot", color=await ctx.embed_color(), ) embed.add_field( name="\N{DESKTOP COMPUTER} Server Info", value=( "CPU usage: `{cpu_usage}%`\n" "RAM usage: `{ram_usage}%`\n" "Network usage: `{network_usage}`\n" "Boot Time: `{boot_time}`\n" "OS: {os}\n" "CPU Info: `{cpu}`\n" "Core Count: `{cores}`\n" "Total Ram: `{ram}`").format( cpu_usage=str(cpustats), ram_usage=str(ramusage.percent), network_usage=net_ios, boot_time=datetime.fromtimestamp( psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S"), os=osver, cpu=cpu, cores=cpucount, ram=ram_ios, ), ) embed.add_field( name="\N{ROBOT FACE} Bot Info", value=("Servers: `{servs:,}`\n" "Users: `{users:,}`\n" "Shard{s}: `{shard:,}`\n" "Playing Music on: `{totalnum:}` servers\n" "Tracks Played: `{tracksplayed:}`\n" "Channels: `{channels:,}`\n" "Number of commands: `{numcommands:,}`\n" "Bot Uptime: `{uptime}`").format( servs=servers, users=totalusers, s="s" if shards >= 2 else "", shard=shards, totalnum=total_num, tracksplayed=tracks_played, channels=channels, numcommands=numcommands, uptime=uptime, ), inline=True, ) embed.add_field( name="\N{BOOKS} Libraries,", value=("Lavalink: `{lavalink}`\n" "Jar Version: `{jarbuild}`\n" "Red Version: `{redversion}`\n" "Discord.py Version: `{discordversion}`").format( lavalink=lavalink.__version__, jarbuild=jarversion, redversion=red, discordversion=dpy, ), ) embed.set_thumbnail(url=ctx.bot.user.avatar_url_as( static_format="png")) embed.set_footer(text=await ctx.bot.db.help.tagline()) return await ctx.send(embed=embed)
async def advusagecount(self, ctx): """ Same as [p]usagecount command but with more stats. """ avatar = self.bot.user.avatar_url_as(static_format="png") counters = defaultdict(int, self.counter) uptime = str(self.get_bot_uptime()) try: total_num = "{}/{}".format( humanize_number(len(lavalink.active_players())), humanize_number(len(lavalink.all_players())), ) except AttributeError: # Remove at 3.2 total_num = "{}/{}".format( humanize_number(len([p for p in lavalink.players if p.current is not None])), humanize_number(len([p for p in lavalink.players])), ) em = discord.Embed( title=_("Usage count of {} since last restart:").format(ctx.bot.user.name), color=await ctx.embed_colour(), ) em.add_field( name=_("Message Stats"), value=box( _( "Messages Read : {messages_read:,}\n" "Messages Sent : {msg_sent:,}\n" "Messages Deleted : {messages_deleted:,}\n" "Messages Edited : {messages_edited:,}\n" "DMs Received : {dms_received:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("Commands Stats"), value=box( _( "Commands Processed : {processed_commands:,}\n" "Errors Occured : {command_error:,}\n" "Sessions Resumed : {sessions_resumed:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("Guild Stats"), value=box( _( "Guilds Joined : {guild_join:,}\n" "Guilds Left : {guild_remove:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("User Stats"), value=box( _( "New Users : {new_members:,}\n" "Left Users : {members_left:,}\n" "Banned Users : {members_banned:,}\n" "Unbanned Users : {members_unbanned:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("Role Stats"), value=box( _( "Roles Added : {roles_added:,}\n" "Roles Removed : {roles_removed:,}\n" "Roles Updated : {roles_updated:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("Emoji Stats"), value=box( _( "Reacts Added : {reactions_added:,}\n" "Reacts Removed : {reactions_removed:,}\n" "Emoji Added : {emojis_added:,}\n" "Emoji Removed : {emojis_removed:,}\n" "Emoji Updated : {emojis_updated:,}\n" ).format_map(counters), lang="prolog", ), inline=False, ) em.add_field( name=_("Audio Stats"), value=box( _( "Users Who Joined VC : {users_joined_bot_music_room:,}\n" "Tracks Played : {tracks_played:,}\n" "Number Of Players : {total_num}" ).format( users_joined_bot_music_room=counters["users_joined_bot_music_room"], tracks_played=counters["tracks_played"], total_num=total_num, ), lang="prolog", ), inline=False, ) em.set_thumbnail(url=avatar) em.set_footer(text=_("Since {}").format(uptime)) await ctx.send(embed=em)
def playing_music(self) -> int: import lavalink return len(lavalink.active_players())