#Counting time in a voice.

1 messages · Page 1 of 1 (latest)

vast bolt
#

Hello, please tell me how to make a system for counting the time spent in the voice channel?

rich furnace
#

user joins voice, mark a timestamp. They leave, mark another timestamp. Calculate the diferences

vast bolt
next ermine
#

show all code from ur task

vast bolt
#

@tasks.loop(minutes=1)
async def voice_check():
for channel in bot.guilds[0].voice_channels:
for member in channel.members:
cursor.execute("UPDATE users SET timeInVoice = timeInVoice + 1 WHERE id = {}".format(member.id))
connection.commit()

voice_check.start()

next ermine
#

you need before task

#

ur task start when ur bot is not ready

#

and I think bcz that bot.guilds is a empty list

vast bolt
vast bolt
rich furnace
vast bolt
next ermine
#

read your error

vast bolt
# next ermine read your error

I already tried to make it so that the cycle was for one server. Help, please, I can not figure out how to solve the problem at all.

for channel in bot.guilds(bot.get_guild(id)).voice_channels:

next ermine
#

That's wrong

vast bolt
next ermine
#

For guild in bot.guilds

#

And stop pinging me, I'm busy right now