async for x in users.find().sort("voicetime", -1):
выводило к примеру топ 10 TypeError: object AsyncIOMotorCursor can't be used in 'await' expression
@commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
if before.channel is None and after.channel is not None:
print(f"{member} connect to {after.channel.name}")
elif before.channel is not None and after.channel is None:
print(f"{member} disconnect from {before.channel.name}")
elif before.channel is not None and after.channel is not None:
print(f"{member} move from {before.channel.name} to {after.channel.name}")
@bot.event()
async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel is not None:
print(f"{member} connect to {after.channel.name}")
elif before.channel is not None and after.channel is None:
print(f"{member} disconnect from {before.channel.name}")
elif before.channel is not None and after.channel is not None:
print(f"{member} move from {before.channel.name} to {after.channel.name}")
@tasks.loop(minutes=1)
async def main(self):
users = self.db.get_data2
if users['workdate'] != 0:
time1 = int(users['workdate'] + timedelta(minutes=-10))
now = datetime.now()
if now == time1:
time2 = int(time1.timestamp())
channel2 = self.bot.get_channel(987413413900718170)
await channel2.send(f"<@{users['member_id']}>, твоя смена будет <t:{time2}:R>")
time3 = int(users['workdate'] + timedelta(days=1))
await self.db.update_member({"member_id": users['member_id']}, {"$set": {"workdate": time3}})
Unhandled exception in internal background task 'main'.
Traceback (most recent call last):
File "C:\python\lib\site-packages\disnake\ext\tasks\__init__.py", line 157, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\Creativchak\Desktop\HarukoBot\cogs\tasks.py", line 29, in main
if users['workdate'] != 0:
TypeError: 'method' object is not subscriptable
@tasks.loop(minutes=1)
async def main(self):
users = self.db.get_data2
if users['workdate'] != 0:
time1 = int(users['workdate'] + timedelta(minutes=-10))
now = datetime.now()
if now == time1:
time2 = int(time1.timestamp())
channel2 = self.bot.get_channel(987413413900718170)
await channel2.send(f"<@{users['member_id']}>, твоя смена будет <t:{time2}:R>")
time3 = int(users['workdate'] + timedelta(days=1))
await self.db.update_member({"member_id": users['member_id']}, {"$set": {"workdate": time3}})
Unhandled exception in internal background task 'main'.
Traceback (most recent call last):
File "C:\python\lib\site-packages\disnake\ext\tasks\__init__.py", line 157, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\Creativchak\Desktop\HarukoBot\cogs\tasks.py", line 29, in main
if users['workdate'] != 0:
TypeError: 'method' object is not subscriptable