import time
@bot.event
async def on_ready():
print('Bot Connected')
global tdict
tdict = {}
await bot.change_presence(activity = discord.Game('r!help'))
@bot.event
async def on_voice_state_update(member, before, after):
author = member.id
if before.channel is None and after.channel is not None:
print('1')
t1 = time.time()
tdict[author] = t1
elif before.channel is not None and after.channel is None and author in tdict:
t2 = time.time()
print('0')
print(t2-tdict[author])
const Discord = require("discord.js");
const bot = new Discord.Client();
bot.on("ready", async () => {
console.log("Bot Connected");
global.tdict = {};
await bot.user.setActivity("r!help", { type: "PLAYING" });
});
bot.on("voiceStateUpdate", async (before, after) => {
const author = before.member.id || after.member.id;
if (!before.channel && after.channel) {
console.log("1");
const t1 = Math.floor(Date.now() / 1000);
global.tdict[author] = t1;
} else if (before.channel && !after.channel && global.tdict.hasOwnProperty(author)) {
const t2 = Math.floor(Date.now() / 1000);
console.log("0");
console.log(t2 - global.tdict[author]);
}
});