Rifat Azad commited on
Commit
cad8499
·
1 Parent(s): 834dc38

improvements 21

Browse files
Files changed (1) hide show
  1. pydvpl_bot.py +14 -5
pydvpl_bot.py CHANGED
@@ -84,6 +84,7 @@ async def compress(ctx):
84
 
85
  if not attachments:
86
  await ctx.send("No file attached.")
 
87
  await ctx.message.delete()
88
  return
89
 
@@ -93,6 +94,7 @@ async def compress(ctx):
93
  # Check if the file is already in .dvpl format, if so, skip it
94
  if file_path.endswith(".dvpl"):
95
  await ctx.send(f"File {attachment.filename} is already in .dvpl format. Skipping.")
 
96
  await ctx.message.delete()
97
  continue
98
 
@@ -100,11 +102,13 @@ async def compress(ctx):
100
  compressed_file_path = await compress_file(file_path)
101
  if compressed_file_path:
102
  await ctx.send(file=discord.File(compressed_file_path))
 
103
  await ctx.message.delete()
104
  os.remove(file_path) # Delete the original file
105
  os.remove(compressed_file_path) # Delete the compressed file
106
  else:
107
- await ctx.send("Failed to compress the file.")
 
108
  await ctx.message.delete()
109
 
110
 
@@ -114,6 +118,7 @@ async def decompress(ctx):
114
 
115
  if not attachments:
116
  await ctx.send("No file attached.")
 
117
  await ctx.message.delete()
118
  return
119
 
@@ -123,6 +128,7 @@ async def decompress(ctx):
123
  # Check if the file is not in .dvpl format, if so, skip it
124
  if not file_path.endswith(".dvpl"):
125
  await ctx.send(f"File {attachment.filename} is not in .dvpl format. Skipping.")
 
126
  await ctx.message.delete()
127
  continue
128
 
@@ -130,11 +136,13 @@ async def decompress(ctx):
130
  decompressed_file_path = await decompress_file(file_path)
131
  if decompressed_file_path:
132
  await ctx.send(file=discord.File(decompressed_file_path))
 
133
  await ctx.message.delete()
134
  os.remove(file_path) # Delete the original file
135
  os.remove(decompressed_file_path) # Delete the decompressed file
136
  else:
137
  await ctx.send("Failed to decompress the file.")
 
138
  await ctx.message.delete()
139
 
140
 
@@ -142,7 +150,8 @@ async def decompress(ctx):
142
  async def ping(ctx):
143
  latency = round(bot.latency * 1000) # latency in milliseconds
144
  await ctx.send(f"Pong! Bot latency is {latency}ms.")
145
- await ctx.message.delete()
 
146
 
147
 
148
  @bot.command(help="Cleans all files in received_to_compress and received_to_decompress directories.")
@@ -263,7 +272,7 @@ async def say(ctx, destination_type, *args):
263
  channel = bot.get_channel(channel_id)
264
  if channel:
265
  await channel.send(message)
266
- await ctx.send(f"Message '{message}' sent to channel '{channel.name}'.")
267
  await ctx.message.delete()
268
  else:
269
  await ctx.send("Channel not found.")
@@ -285,13 +294,13 @@ async def say(ctx, destination_type, *args):
285
  announcement_channel = discord.utils.get(server.channels, name="important-announcements")
286
  if announcement_channel:
287
  await announcement_channel.send(message)
288
- await ctx.send(f"Message '{message}' sent to server '{server.name}' in 'important-announcements' channel.")
289
  await ctx.message.delete()
290
  else:
291
  announcements_channel = discord.utils.get(server.channels, name="announcements")
292
  if announcements_channel:
293
  await announcements_channel.send(message)
294
- await ctx.send(f"Message '{message}' sent to server '{server.name}' in 'announcements' channel.")
295
  await ctx.message.delete()
296
  else:
297
  await ctx.send("No announcement channels found in the server.")
 
84
 
85
  if not attachments:
86
  await ctx.send("No file attached.")
87
+ await ctx.send(f"The command `compress` was executed by - {ctx.author.mention}")
88
  await ctx.message.delete()
89
  return
90
 
 
94
  # Check if the file is already in .dvpl format, if so, skip it
95
  if file_path.endswith(".dvpl"):
96
  await ctx.send(f"File {attachment.filename} is already in .dvpl format. Skipping.")
97
+ await ctx.send(f"The command `compress` was executed by - {ctx.author.mention}")
98
  await ctx.message.delete()
99
  continue
100
 
 
102
  compressed_file_path = await compress_file(file_path)
103
  if compressed_file_path:
104
  await ctx.send(file=discord.File(compressed_file_path))
105
+ await ctx.send(f"The command `compress` was executed by - {ctx.author.mention}")
106
  await ctx.message.delete()
107
  os.remove(file_path) # Delete the original file
108
  os.remove(compressed_file_path) # Delete the compressed file
109
  else:
110
+ await ctx.send("Failed to `compress` compress the file.")
111
+ await ctx.send(f"The command was executed by - {ctx.author.mention}")
112
  await ctx.message.delete()
113
 
114
 
 
118
 
119
  if not attachments:
120
  await ctx.send("No file attached.")
121
+ await ctx.send(f"The command `decompress` was executed by - {ctx.author.mention}")
122
  await ctx.message.delete()
123
  return
124
 
 
128
  # Check if the file is not in .dvpl format, if so, skip it
129
  if not file_path.endswith(".dvpl"):
130
  await ctx.send(f"File {attachment.filename} is not in .dvpl format. Skipping.")
131
+ await ctx.send(f"The command `decompress` was executed by - {ctx.author.mention}")
132
  await ctx.message.delete()
133
  continue
134
 
 
136
  decompressed_file_path = await decompress_file(file_path)
137
  if decompressed_file_path:
138
  await ctx.send(file=discord.File(decompressed_file_path))
139
+ await ctx.send(f"The command `decompress` was executed by - {ctx.author.mention}")
140
  await ctx.message.delete()
141
  os.remove(file_path) # Delete the original file
142
  os.remove(decompressed_file_path) # Delete the decompressed file
143
  else:
144
  await ctx.send("Failed to decompress the file.")
145
+ await ctx.send(f"The command `decompress` was executed by - {ctx.author.mention}")
146
  await ctx.message.delete()
147
 
148
 
 
150
  async def ping(ctx):
151
  latency = round(bot.latency * 1000) # latency in milliseconds
152
  await ctx.send(f"Pong! Bot latency is {latency}ms.")
153
+ await ctx.send(f"The command `ping` was executed by - {ctx.author.mention}")
154
+
155
 
156
 
157
  @bot.command(help="Cleans all files in received_to_compress and received_to_decompress directories.")
 
272
  channel = bot.get_channel(channel_id)
273
  if channel:
274
  await channel.send(message)
275
+ await ctx.send(f"Message '{message}' sent to channel `{channel.name}`.")
276
  await ctx.message.delete()
277
  else:
278
  await ctx.send("Channel not found.")
 
294
  announcement_channel = discord.utils.get(server.channels, name="important-announcements")
295
  if announcement_channel:
296
  await announcement_channel.send(message)
297
+ await ctx.send(f"Message '{message}' sent to server `{server.name}` in 'important-announcements' channel.")
298
  await ctx.message.delete()
299
  else:
300
  announcements_channel = discord.utils.get(server.channels, name="announcements")
301
  if announcements_channel:
302
  await announcements_channel.send(message)
303
+ await ctx.send(f"Message '{message}' sent to server `{server.name}` in 'announcements' channel.")
304
  await ctx.message.delete()
305
  else:
306
  await ctx.send("No announcement channels found in the server.")