@bot.command()
async def message_count(ctx, member:discord.Member = None):
count = 0
async for i in member.history():
count += 1
await ctx.send("Сообщений {}".format(count))
import datetime
channels = {}
d = datetime.datetime.today() - datetime.timedelta(days=1)
for channel in ctx.guild.text_channels:
if channel.permissions_for(channel.guild.get_member(user_id)).view_channel:
messages = 0
async for message in channel.history(limit=100000, after=d):
messages += 1
channels[channel.id] = messages
c = 0
top_channels = ""
while c != 5:
h = max(channels, key=channels.get)
channel = discord.utils.get(guild.text_channels, id=h)
top_channels += f"`{c + 1}`. {channel.mention}: {channels[h]}\n"
channels.pop(h)
c += 1
yield top_channels