Answer the question
In order to leave comments, you need to log in
How can I find out how many messages were sent by a member in a day or just for the whole time?
My code is below, it doesn't show correctly:
@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))
Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question