<commit_before>
import discord
from discord.ext import commands

import asyncio
import datetime
import copy
import ctypes
import inspect
import json
import os
import random
import subprocess
import sys
import traceback

import git
import pkg_resources  # from setuptools
import psutil

import clients
from modules import utilities
from utilities import checks

def setup(bot):
	bot.add_cog(Meta(bot))

class Meta(commands.Cog):
	
	def __init__(self, bot):
		self.bot = bot
		clients.create_file("stats", content = {"uptime" : 0, "restarts" : 0, "cogs_reloaded" : 0, "commands_executed" : 0, "commands_usage": {}, "reaction_responses": 0})
	
	@commands.command()
	@commands.is_owner()
	async def allcommands(self, ctx):
		'''All the commands'''
		# TODO: Fix/Deprecate?, all_commands alias
		formatter = commands.HelpFormatter(show_check_failure = True, show_hidden = True)
		await formatter.format_help_for(ctx, self.bot)
		_commands = await formatter.filter_command_list()
		_allcommands = ""
		for name, _command in _commands:
			_allcommands += name + ' '
		await ctx.whisper(_allcommands[:-1])
	
	@commands.command()
	@commands.is_owner()
	async def benchmark(self, ctx):
		'''Benchmark'''
		process = psutil.Process()
		memory = process.memory_info().rss / 2 ** 20
		process.cpu_percent()
		embed = discord.Embed(color = ctx.bot.bot_color)
		embed.add_field(name = "RAM", value = "{:.2f} MiB".format(memory))
		embed.add_field(name = "CPU", value = "Calculating CPU usage..")
		message = await ctx.send(embed = embed)
		await asyncio.sleep(1)
		cpu = process.cpu_percent() / psutil.cpu_count()
		embed.set_field_at(1, name = "CPU", value = "{}%".format(cpu))
		await message.edit(embed = embed)
	
	@commands.command(aliases = ["category"])
	@checks.not_forbidden()
	async def cog(self, ctx, command):
		'''Find what cog/category a command is in'''
		if command not in self.bot.all_commands:
			await ctx.embed_reply(":no_entry: Error: command not found")
			return
		await ctx.embed_reply(self.bot.all_commands[command].cog_name)
	
	@commands.command()
	@commands.is_owner()
	async def disable(self, ctx, command : str):
		'''Disable a command'''
		self.bot.all_commands[command].enabled = False
		await ctx.embed_reply("`{}{}` has been disabled".format(ctx.prefix, command))
	
	@commands.command()
	@commands.is_owner()
	async def enable(self, ctx, command : str):
		'''Enable a command'''
		self.bot.all_commands[command].enabled = True
		await ctx.embed_reply("`{}{}` has been enabled".format(ctx.prefix, command))
	
	@commands.command()
	async def points(self, ctx):
		'''WIP'''
		commands_executed = await ctx.bot.db.fetchval(
			"""
			SELECT commands_executed
			FROM users.stats
			WHERE user_id = $1
			""", 
			ctx.author.id
		)
		await ctx.embed_reply(f"You have {commands_executed} points")
	
	@commands.command()
	@commands.is_owner()
	async def servers(self, ctx):
		'''Every server I'm in'''
		for guild in self.bot.guilds:
			embed = discord.Embed(color = ctx.bot.bot_color)
			embed.description = (f"```Name: {guild.name}\n"
									f"ID: {guild.id}\n"
									f"Owner: {guild.owner} ({guild.owner.id})\n"
									f"Server Region: {guild.region}\n"
									f"Members: {guild.member_count}\n"
									f"Created at: {guild.created_at}\n```")
			embed.set_thumbnail(url = guild.icon_url)
			await ctx.whisper(embed = embed)
	
	@commands.command(aliases = ["setprefixes"])
	@checks.is_permitted()
	async def setprefix(self, ctx, *prefixes : str):
		'''
		Set the bot prefix(es)
		For the server or for DMs
		Separate prefixes with spaces
		Use quotation marks for prefixes with spaces
		'''
		if not prefixes:
			prefixes = ['!']
		with open(clients.data_path + "/prefixes.json", 'r') as prefixes_file:
			all_prefixes = json.load(prefixes_file)
		if isinstance(ctx.channel, discord.DMChannel):
			all_prefixes[ctx.channel.id] = prefixes
		else:
			all_prefixes[ctx.guild.id] = prefixes
		with open(clients.data_path + "/prefixes.json", 'w') as prefixes_file:
			json.dump(all_prefixes, prefixes_file, indent = 4)
		await ctx.embed_reply("Prefix(es) set: {}".format(' '.join(['`"{}"`'.format(prefix) for prefix in prefixes])))
	
	@commands.command(aliases = ["typing"], hidden = True)
	@checks.not_forbidden()
	async def type(self, ctx):
		'''Sends typing status'''<commit_msg>[Discord] Add shards and shards recommended commands<commit_after>
import discord
from discord.ext import commands

import asyncio
import datetime
import copy
import ctypes
import inspect
import json
import os
import random
import subprocess
import sys
import traceback

import git
import pkg_resources  # from setuptools
import psutil

import clients
from modules import utilities
from utilities import checks

def setup(bot):
	bot.add_cog(Meta(bot))

class Meta(commands.Cog):
	
	def __init__(self, bot):
		self.bot = bot
		clients.create_file("stats", content = {"uptime" : 0, "restarts" : 0, "cogs_reloaded" : 0, "commands_executed" : 0, "commands_usage": {}, "reaction_responses": 0})
	
	@commands.command()
	@commands.is_owner()
	async def allcommands(self, ctx):
		'''All the commands'''
		# TODO: Fix/Deprecate?, all_commands alias
		formatter = commands.HelpFormatter(show_check_failure = True, show_hidden = True)
		await formatter.format_help_for(ctx, self.bot)
		_commands = await formatter.filter_command_list()
		_allcommands = ""
		for name, _command in _commands:
			_allcommands += name + ' '
		await ctx.whisper(_allcommands[:-1])
	
	@commands.command()
	@commands.is_owner()
	async def benchmark(self, ctx):
		'''Benchmark'''
		process = psutil.Process()
		memory = process.memory_info().rss / 2 ** 20
		process.cpu_percent()
		embed = discord.Embed(color = ctx.bot.bot_color)
		embed.add_field(name = "RAM", value = "{:.2f} MiB".format(memory))
		embed.add_field(name = "CPU", value = "Calculating CPU usage..")
		message = await ctx.send(embed = embed)
		await asyncio.sleep(1)
		cpu = process.cpu_percent() / psutil.cpu_count()
		embed.set_field_at(1, name = "CPU", value = "{}%".format(cpu))
		await message.edit(embed = embed)
	
	@commands.command(aliases = ["category"])
	@checks.not_forbidden()
	async def cog(self, ctx, command):
		'''Find what cog/category a command is in'''
		if command not in self.bot.all_commands:
			await ctx.embed_reply(":no_entry: Error: command not found")
			return
		await ctx.embed_reply(self.bot.all_commands[command].cog_name)
	
	@commands.command()
	@commands.is_owner()
	async def disable(self, ctx, command : str):
		'''Disable a command'''
		self.bot.all_commands[command].enabled = False
		await ctx.embed_reply("`{}{}` has been disabled".format(ctx.prefix, command))
	
	@commands.command()
	@commands.is_owner()
	async def enable(self, ctx, command : str):
		'''Enable a command'''
		self.bot.all_commands[command].enabled = True
		await ctx.embed_reply("`{}{}` has been enabled".format(ctx.prefix, command))
	
	@commands.command()
	async def points(self, ctx):
		'''WIP'''
		commands_executed = await ctx.bot.db.fetchval(
			"""
			SELECT commands_executed
			FROM users.stats
			WHERE user_id = $1
			""", 
			ctx.author.id
		)
		await ctx.embed_reply(f"You have {commands_executed} points")
	
	@commands.command()
	@commands.is_owner()
	async def servers(self, ctx):
		'''Every server I'm in'''
		for guild in self.bot.guilds:
			embed = discord.Embed(color = ctx.bot.bot_color)
			embed.description = (f"```Name: {guild.name}\n"
									f"ID: {guild.id}\n"
									f"Owner: {guild.owner} ({guild.owner.id})\n"
									f"Server Region: {guild.region}\n"
									f"Members: {guild.member_count}\n"
									f"Created at: {guild.created_at}\n```")
			embed.set_thumbnail(url = guild.icon_url)
			await ctx.whisper(embed = embed)
	
	@commands.command(aliases = ["setprefixes"])
	@checks.is_permitted()
	async def setprefix(self, ctx, *prefixes : str):
		'''
		Set the bot prefix(es)
		For the server or for DMs
		Separate prefixes with spaces
		Use quotation marks for prefixes with spaces
		'''
		if not prefixes:
			prefixes = ['!']
		with open(clients.data_path + "/prefixes.json", 'r') as prefixes_file:
			all_prefixes = json.load(prefixes_file)
		if isinstance(ctx.channel, discord.DMChannel):
			all_prefixes[ctx.channel.id] = prefixes
		else:
			all_prefixes[ctx.guild.id] = prefixes
		with open(clients.data_path + "/prefixes.json", 'w') as prefixes_file:
			json.dump(all_prefixes, prefixes_file, indent = 4)
		await ctx.embed_reply("Prefix(es) set: {}".format(' '.join(['`"{}"`'.format(prefix) for prefix in prefixes])))
	
	@commands.group(aliases = ["shard"], invoke_without_command = True)
	async def shards(self, ctx):
		'''Current number of shards'''
		await ctx.embed_reply(ctx.bot.shard_count or 1)
	
	@shards.command(aliases = ["recommend"])
	async def recommended(self, ctx):
		'''Recommended number of shards to use by Discord API'''
		count, _ = await ctx.bot.http.get_bot_gateway()
		await ctx.embed_reply(count)
	
	@commands.command(aliases = ["typing"], hidden = True)
	@checks.not_forbidden()
	async def type(self, ctx):
		'''Sends typing status'''
{'fraction_non_alphanumeric': 0.14432647644326477, 'fraction_numerical': 0.0032072550320725503, 'mean_word_length': 4.437763078773301, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '71873', 'n_tokens_mistral': 3410, 'n_tokens_neox': 3066, 'n_words': 755}