import asyncio
import discord
from discord.ext import commands
import json
import time
client = commands.Bot(command_prefix='+', intents = discord.Intents(messages = True, guild_messages = True, members = True, guilds = True))
ever = {}
week = {}
day = {}
active = {}
@client.event
async def on_ready():
print("Ready")
for guild in client.guilds:
for member in guild.members:
ever[member.id] = {"voice": 0, "text": 0}
week[member.id] = {"voice": 0, "text": 0}
day[member.id] = {"voice": 0, "text": 0}
client.loop.create_task(week_vipe())
client.loop.create_task(day_vipe())
@client.event
async def on_member_join(member):
ever[member.id] = {"voice": 0, "text": 0}
week[member.id] = {"voice": 0, "text": 0}
day[member.id] = {"voice": 0, "text": 0}
@client.event
async def on_message(ctx):
ever[ctx.author.id]["text"] = ever[ctx.author.id]["text"] + 1
week[ctx.author.id]["text"] = week[ctx.author.id]["text"] + 1
day[ctx.author.id]["text"] = day[ctx.author.id]["text"] + 1
print(day)
@client.event
async def on_voice_state_update(member, before, after):
print('qwerty')
user = member.id
if before.channel is None and after.channel is not None:
print(user + " joined")
active[user] = time()
if after.channel is None and before.channel is not None:
print(user + "left")
ever[user]["voice"] += time() - active[user]
print(ever[user]["voice"])
async def week_vipe():
global week
while True:
for guild in client.guilds:
for member in guild.members:
week[member.id] = {"voice": 0, "text": 0}
print(f"week_vipe: {week}")
await asyncio.sleep(604800)
async def day_vipe():
global day
while True:
for guild in client.guilds:
for member in guild.members:
day[member.id] = {"voice": 0, "text": 0}
print(f"day_vipe: {day}")
await asyncio.sleep(86400)
client.run('MTAwNTQ3NDM3MzIzMjI1MDk3MQ.GzM1u6.27UKqUdBdJdqCFrqZI22_ThHOkM2z-BZqDszvU')
Вроде все правильно сделал но не работет. Оно даже qwerty не пишет когда я захожу в голосовой чат/ Вообще ничего не понимаю