import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.typing = True
intents.presences = True
intents.voice_states = True
intents.messages = True
bot = commands.Bot(intents = discord.Intents.all(), command_prefix='.')
activity_stats = {}
@bot.event
async def on_ready():
print('Bot is ready.')
@bot.event
async def on_voice_state_update(member, before, after):
if after.channel is not None:
if member.id not in activity_stats:
activity_stats[member.id] = {
'voice_time': 0,
'message_count': 0
}
else:
activity_stats[member.id]['voice_time'] += 1
@bot.event
async def on_message(message):
if not message.author.bot:
author_id = message.author.id
if author_id not in activity_stats:
activity_stats[author_id] = {
'voice_time': 0,
'message_count': 0
}
else:
activity_stats[author_id]['message_count'] += 1
await bot.process_commands(message)
@bot.command()
async def profile(ctx, member: discord.Member = None):
if member is None:
member = ctx.author
if member.id not in activity_stats:
await ctx.send('Профиль не найден.')
else:
voice_time = activity_stats[member.id]['voice_time']
message_count = activity_stats[member.id]['message_count']
days_on_server = (ctx.message.created_at - member.joined_at).days
avatar_url = member.avatar
embed = discord.Embed(title=f'Профиль {member.name}', color=discord.Color.blue())
embed.set_thumbnail(url=avatar_url)
embed.add_field(name='Время в голосовых каналах (в минутах)', value=voice_time, inline=False)
embed.add_field(name='Количество сообщений', value=message_count, inline=False)
embed.add_field(name='Дней на сервере', value=days_on_server, inline=False)
await ctx.send(embed=embed)
И когда я пишу например !profile @Xabari, то мне пишет "Профиль не найден", хотя игрок в сети