async def tenDaysMarker(ctx, member=None): if member == None: member = ctx.member.discriminator tf, date = sysHelper.tenDaysCheck(member) else: tf, data = sysHelper.tenDaysCheck(member) if tf is not True: await ctx.channel.send( f"It would appear that {member} yet to hit the 10 day mark") else: await ctx.channel.send(f"{member} surpassed ten days on {date}")
async def tenDaysMarker(ctx, member=None): if member == None: member = ctx.author.discriminator tf, date = sysHelper.tenDaysCheck(member) else: tf, date = sysHelper.tenDaysCheck(member) if tf is not True: await ctx.channel.send( f"It would appear that {member} yet to hit the 10 day mark") else: dateWhen = sysHelper.timeConverter( datetime.timestamp(datetime.fromisoformat(date)))[-1] await ctx.channel.send(f"{member} surpassed ten days on {dateWhen}")
async def on_voice_state_update(member, before, after): now = datetime.now() timeNow = datetime.strftime(now, '%m/%d/%Y %H:%M:%S') mbr = member.discriminator timestamp = datetime.timestamp(now) SvrUpdootChnl = discord.utils.get(member.guild.channels, name='timebot') msrPath = os.getcwd() mbrPath = f"{msrPath}/UserData/{mbr}/" mbrPath_exists = os.path.exists(mbrPath) if mbrPath_exists is not True: os.mkdir(mbrPath) if before.channel is None and after.channel is not None: print( f'({mbr}) Joined Channel: ({after.channel.name}) On Server: ({member.guild}) On: ({timeNow})' ) if SvrUpdootChnl is not None: await SvrUpdootChnl.send( f'"{member}" Joined Channel: "{after.channel.name}" On: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}\n----- ¯\_(ツ)_/¯ -----' ) with open(mbrPath + "TempDat.txt", 'w') as tmpDat: #tmpDatArray = [now, member, member.guild, after.channel.name] tmpDat.write(str(timestamp)) if before.channel is not None and after.channel is None: with open(mbrPath + 'TempDat.txt', 'r') as tmpDat: tmpDat = tmpDat.read() joinTime = datetime.fromtimestamp(float(tmpDat)) with open(f"{os.getcwd()}/SysData/online.txt", "r") as oFile: oTime = float(oFile.read()) #Only process 0x0BOJT if bot has been online for more than 5 mins if (timedelta(datetime.timestamp(now) - oTime)) > timedelta(minutes=5): #if client joined before the bot was online, the jointime could be incorrect, so discard the time and process error 0x0BOJT if oTime > datetime.timestamp(joinTime): print( f"ERROR: (0x0BOJT) Bot offline at join time\nUSER(s) AFFECTED: {mbr}" ) if SvrUpdootChnl is not None: await SvrUpdootChnl.send( f"ERROR: (0x0BOJT) Bot offline at join time\nUSER(s) AFFECTED: {mbr}" ) return print( f'({mbr}) Has Left Channel: ({before.channel.name}) On Server: ({member.guild}) On: ({timeNow})' ) if SvrUpdootChnl is not None: await SvrUpdootChnl.send( f'"{member}" Left Channel: "{before.channel.name}" On: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}\n----- ¯\_(ツ)_/¯ -----' ) memberTtime_exists = os.path.isfile(mbrPath + 'Ttime.txt') if memberTtime_exists is not True: print(f'NEW USER: {mbr}') with open(mbrPath + 'Ttime.txt', "w") as crtFile: crtFile.write('0') with open(mbrPath + 'Ttime.txt', "r") as tTime: tmpTdat = tTime.read() TTime = timedelta(seconds=float(tmpTdat)) timeDif = now - joinTime toltalTtime = TTime + timeDif print(toltalTtime) mbr10Days_true, date = sysHelper.tenDaysCheck(mbr) tentime = timedelta(days=10) if mbr10Days_true is not True and toltalTtime >= tentime: with open(mbrPath + '10Days.txt', 'w') as tenDays: print(f"{member} Has Surpassed 10 Days") tenDays.write(str(now)) if os.path.exists(mbrPath + "UsrLogs.csv") == False: with open(mbrPath + "UsrLogs.csv", "w", newline='') as usrLogs_fp: writer = csv.writer(usrLogs_fp) writer.writerow([ 'Server', 'Channel', 'Join Time', 'Leave Time', 'TimeDif', 'Toltal Accumulative' ]) with open(mbrPath + 'UsrLogs.csv', 'a', newline='') as mbrcsv: writer = csv.writer(mbrcsv) writer.writerow([ member.guild, before.channel.name, joinTime, now, timeDif, toltalTtime ]) if os.path.exists(mbrPath + "stats.csv") == False: with open( mbrPath + "stats.csv", "w", ) as stats_fp: writer = csv.writer(stats_fp) writer.writerow([ 'Join Time', 'Leave Time', 'TimeDif', 'Toltal Accumulative' ]) with open( mbrPath + 'stats.csv', 'a', ) as mbrcsv: writer = csv.writer(mbrcsv) writer.writerow([joinTime, now, timeDif, toltalTtime]) with open(mbrPath + 'Ttime.txt', 'w') as ntTime: tstToltal = toltalTtime.total_seconds() print(tstToltal) ntTime.write(str(tstToltal))
async def on_voice_state_update(member, before, after): now = datetime.now() timeNow = datetime.strftime(now, '%m/%d/%Y %H:%M:%S') mbr = member.discriminator timestamp = datetime.timestamp(now) bjoerkChannel = client.get_channel(835204702924046346) #821473151342870548 brianChannel = client.get_channel(847143897448316948) msrPath = os.getcwd() mbrPath = f"{msrPath}/{mbr}/" mbrPath_exists = os.path.exists(mbrPath) if mbrPath_exists is not True: os.mkdir(mbrPath) if before.channel is None and after.channel is not None: print( f'({mbr}) Has Joined Channel: ({after.channel.name}) On Server: ({member.guild}) At: ({timeNow})' ) await bjoerkChannel.send( f'"{member}" Has Joined Channel: "{after.channel.name}" On Server: "{member.guild}" At: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}' ) await brianChannel.send( f'"{member}" Has Joined Channel: "{after.channel.name}" On Server: "{member.guild}" At: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}' ) await bjoerkChannel.send("----- ¯\_(ツ)_/¯ -----") await brianChannel.send("----- ¯\_(ツ)_/¯ -----") with open(f"{msrPath}/{mbr}/" + "TempDat.txt", 'w') as tmpDat: #tmpDatArray = [now, member, member.guild, after.channel.name] tmpDat.write(str(timestamp)) if before.channel is not None and after.channel is None: with open(f"{os.getcwd()}/SysData/online.txt", "r") as oFile: oTime = datetime.fromtimestamp(float(oFile.read())) if oTime > datetime.now(): print( f"ERROR: Bot offline at join time\nUSER(s) AFFECTED: {mbr}" ) await bjoerkChannel.send( f"ERROR: Bot offline at join time\nUSER(s) AFFECTED: {mbr}" ) await brianChannel.send( f"ERROR: Bot offline at join time\nUSER(s) AFFECTED: {mbr}" ) return print( f'({mbr}) Has Left Channel: ({before.channel.name}) On Server: ({member.guild}) At: ({timeNow})' ) await bjoerkChannel.send( f'"{member}" Has Left Channel: "{before.channel.name}" On Server: "{member.guild}" At: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}' ) await brianChannel.send( f'"{member}" Has Left Channel: "{before.channel.name}" On Server: "{member.guild}" At: {sysHelper.timeConverter(datetime.timestamp(datetime.now()))[-1]}' ) with open(f"{msrPath}/{mbr}/" + 'TempDat.txt', 'r') as tmpDat: tmpDat = tmpDat.read() joinTime = datetime.fromtimestamp(float(tmpDat)) memberTtime_exists = os.path.isfile(f"{msrPath}/{mbr}/" + 'Ttime.txt') if memberTtime_exists is not True: with open(f"{msrPath}/{mbr}/" + 'Ttime.txt', "w") as crtFile: crtFile.write('0') with open(f"{msrPath}/{mbr}/" + 'Ttime.txt', "r") as tTime: tmpTdat = tTime.read() TTime = timedelta(seconds=float(tmpTdat)) timeDif = now - joinTime toltalTtime = TTime + timeDif print(toltalTtime) mbr10Days_true, date = sysHelper.tenDaysCheck(mbr) tentime = timedelta(days=10) if mbr10Days_true is not True and toltalTtime >= tentime: with open(f"{msrPath}/{mbr}/" + '10Days.txt', 'w') as tenDays: print(f"{member} Has Surpassed 10 Days") tenDays.write(str(now)) await bjoerkChannel.send( f"@everyone {member} has just surpassed Ten whole days on discord! What the f**k is wrong with you..?" ) await bjoerkChannel.send( f"@everyone {member}'s Toltal Time is now {toltalTtime}") else: await bjoerkChannel.send(f"{member}'s Total Time is {toltalTtime}") await bjoerkChannel.send(" ----- ¯\_(ツ)_/¯ -----") await brianChannel.send(" ----- ¯\_(ツ)_/¯ -----") with open(f"{msrPath}/{mbr}/" + 'stats.csv', 'a') as mbrcsv: writer = csv.writer(mbrcsv) writer.writerow([joinTime, now, timeDif, toltalTtime]) with open(f"{msrPath}/{mbr}/" + 'Ttime.txt', 'w') as ntTime: tstToltal = toltalTtime.total_seconds() print(tstToltal) ntTime.write(str(tstToltal))