Rifat Azad commited on
Commit
8d92e23
·
1 Parent(s): 3da1194

udpate 2.0.69

Browse files
Files changed (1) hide show
  1. pydvpl_bot.py +35 -3
pydvpl_bot.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  import discord
3
- from discord.ext import commands
4
  from pydvpl.dvpl import compress_dvpl, decompress_dvpl
5
  from discord.ext.commands import DefaultHelpCommand
6
  import time
@@ -50,11 +50,43 @@ def ensure_folders():
50
  @bot.event
51
  async def on_ready():
52
  global activity_start_time
53
- await bot.change_presence(activity=discord.Game(name=">>help for commands"))
54
  activity_start_time = time.time()
 
 
 
 
 
 
 
55
  print(f'{bot.user} has connected to Discord!')
 
56
  ensure_folders()
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  async def compress_file(file_path):
60
  try:
@@ -202,7 +234,7 @@ async def online(ctx):
202
  await ctx.send("You are not authorized to use this command.")
203
  await ctx.message.delete()
204
  return
205
- await bot.change_presence(activity=discord.Game(name=">>help for commands"))
206
  await ctx.send("Bot's presence set to online.")
207
  await ctx.message.delete()
208
 
 
1
  import os
2
  import discord
3
+ from discord.ext import commands, tasks
4
  from pydvpl.dvpl import compress_dvpl, decompress_dvpl
5
  from discord.ext.commands import DefaultHelpCommand
6
  import time
 
50
  @bot.event
51
  async def on_ready():
52
  global activity_start_time
53
+
54
  activity_start_time = time.time()
55
+
56
+ # Set initial activity to playing time
57
+ await update_playing_time_activity()
58
+
59
+ # Start the task to update playing time
60
+ update_playing_time.start()
61
+
62
  print(f'{bot.user} has connected to Discord!')
63
+
64
  ensure_folders()
65
 
66
+
67
+
68
+
69
+ async def update_playing_time_activity():
70
+ global activity_start_time
71
+ global playing_time_activity
72
+
73
+ current_time = time.time()
74
+ uptime_seconds = int(current_time - activity_start_time)
75
+ minutes, seconds = divmod(uptime_seconds, 60)
76
+ hours, minutes = divmod(minutes, 60)
77
+
78
+ playing_time_activity = f">>help for commands list | online for {hours}h {minutes}m" #seconds {seconds}s
79
+ await bot.change_presence(activity=discord.Game(name=playing_time_activity))
80
+
81
+
82
+ # Define the interval for updating the playing time (in seconds)
83
+ UPDATE_INTERVAL = 60 # Update every minute
84
+
85
+
86
+ @tasks.loop(seconds=UPDATE_INTERVAL)
87
+ async def update_playing_time():
88
+ await update_playing_time_activity()
89
+
90
 
91
  async def compress_file(file_path):
92
  try:
 
234
  await ctx.send("You are not authorized to use this command.")
235
  await ctx.message.delete()
236
  return
237
+ await bot.change_presence(activity=discord.Game(name=playing_time_activity))
238
  await ctx.send("Bot's presence set to online.")
239
  await ctx.message.delete()
240