Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ·
ace999e
1
Parent(s): c7c1182
new update
Browse files- pydvpl_bot.py +15 -11
pydvpl_bot.py
CHANGED
|
@@ -152,6 +152,8 @@ async def on_ready():
|
|
| 152 |
# Start the task to update playing time
|
| 153 |
update_playing_time.start()
|
| 154 |
|
|
|
|
|
|
|
| 155 |
print(f'{bot.user} has connected to Discord!')
|
| 156 |
|
| 157 |
ensure_folders()
|
|
@@ -274,7 +276,7 @@ async def decompress_file(file_path):
|
|
| 274 |
# UTILITY USER_CMD ------------------------------------------------------ START
|
| 275 |
|
| 276 |
|
| 277 |
-
@bot.
|
| 278 |
async def compress(ctx):
|
| 279 |
attachments = ctx.message.attachments
|
| 280 |
|
|
@@ -309,7 +311,7 @@ async def compress(ctx):
|
|
| 309 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 310 |
|
| 311 |
|
| 312 |
-
@bot.
|
| 313 |
async def decompress(ctx):
|
| 314 |
attachments = ctx.message.attachments
|
| 315 |
|
|
@@ -343,7 +345,7 @@ async def decompress(ctx):
|
|
| 343 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 344 |
|
| 345 |
|
| 346 |
-
@bot.
|
| 347 |
async def ping(ctx):
|
| 348 |
latency = round(bot.latency * 1000) # latency in milliseconds
|
| 349 |
await ctx.send(f"Pong! Bot latency is {latency}ms.")
|
|
@@ -354,7 +356,7 @@ async def ping(ctx):
|
|
| 354 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 355 |
|
| 356 |
|
| 357 |
-
@bot.
|
| 358 |
async def invite(ctx):
|
| 359 |
permissions = discord.Permissions(
|
| 360 |
read_messages=True,
|
|
@@ -383,7 +385,7 @@ async def invite(ctx):
|
|
| 383 |
|
| 384 |
|
| 385 |
# Command: Feedback
|
| 386 |
-
@bot.
|
| 387 |
async def feedback(ctx, category: str, *, message: str):
|
| 388 |
if category.lower() not in ["requests", "issues"]:
|
| 389 |
await ctx.send("Invalid category. Please choose 'requests' or 'issues'.")
|
|
@@ -624,29 +626,31 @@ async def announce(ctx, *, message):
|
|
| 624 |
await ctx.message.delete()
|
| 625 |
return
|
| 626 |
|
|
|
|
|
|
|
| 627 |
for server in bot.guilds:
|
| 628 |
# First, check for an "important-announcements" channel
|
| 629 |
announcement_channel = discord.utils.get(server.channels, name="important-announcements")
|
| 630 |
if announcement_channel:
|
| 631 |
-
await announcement_channel.send(
|
| 632 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `important-announcements` channel.")
|
| 633 |
else:
|
| 634 |
# If no "important-announcements" channel, check for "announcements" channel
|
| 635 |
announcements_channel = discord.utils.get(server.channels, name="announcements")
|
| 636 |
if announcements_channel:
|
| 637 |
-
await announcements_channel.send(
|
| 638 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `announcements` channel.")
|
| 639 |
else:
|
| 640 |
# If neither channel exists, send to the default channel or public updates channel
|
| 641 |
public_updates_channel = server.public_updates_channel
|
| 642 |
if public_updates_channel:
|
| 643 |
-
await public_updates_channel.send(
|
| 644 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `public updates` channel.")
|
| 645 |
else:
|
| 646 |
default_channel = server.system_channel or server.text_channels[0]
|
| 647 |
-
if
|
| 648 |
-
await default_channel.send(
|
| 649 |
-
await ctx.send(f"Message `{message}` sent to server `{server.name}` in
|
| 650 |
else:
|
| 651 |
await ctx.send(f"No suitable announcement channel found in server `{server.name}`.")
|
| 652 |
|
|
|
|
| 152 |
# Start the task to update playing time
|
| 153 |
update_playing_time.start()
|
| 154 |
|
| 155 |
+
await bot.tree.sync()
|
| 156 |
+
|
| 157 |
print(f'{bot.user} has connected to Discord!')
|
| 158 |
|
| 159 |
ensure_folders()
|
|
|
|
| 276 |
# UTILITY USER_CMD ------------------------------------------------------ START
|
| 277 |
|
| 278 |
|
| 279 |
+
@bot.hybrid_command(help="Compresses attached files.")
|
| 280 |
async def compress(ctx):
|
| 281 |
attachments = ctx.message.attachments
|
| 282 |
|
|
|
|
| 311 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 312 |
|
| 313 |
|
| 314 |
+
@bot.hybrid_command(help="Decompresses attached files.")
|
| 315 |
async def decompress(ctx):
|
| 316 |
attachments = ctx.message.attachments
|
| 317 |
|
|
|
|
| 345 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 346 |
|
| 347 |
|
| 348 |
+
@bot.hybrid_command(help="Pings to check bot's latency")
|
| 349 |
async def ping(ctx):
|
| 350 |
latency = round(bot.latency * 1000) # latency in milliseconds
|
| 351 |
await ctx.send(f"Pong! Bot latency is {latency}ms.")
|
|
|
|
| 356 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 357 |
|
| 358 |
|
| 359 |
+
@bot.hybrid_command(help="Generates an invite link for the bot and sends it to your DM.")
|
| 360 |
async def invite(ctx):
|
| 361 |
permissions = discord.Permissions(
|
| 362 |
read_messages=True,
|
|
|
|
| 385 |
|
| 386 |
|
| 387 |
# Command: Feedback
|
| 388 |
+
@bot.hybrid_command(help="Send feedback or report issues", usage="<requests/issues> <message>")
|
| 389 |
async def feedback(ctx, category: str, *, message: str):
|
| 390 |
if category.lower() not in ["requests", "issues"]:
|
| 391 |
await ctx.send("Invalid category. Please choose 'requests' or 'issues'.")
|
|
|
|
| 626 |
await ctx.message.delete()
|
| 627 |
return
|
| 628 |
|
| 629 |
+
embed = discord.Embed(title="Announcement", description=message, color=discord.Color.blurple())
|
| 630 |
+
|
| 631 |
for server in bot.guilds:
|
| 632 |
# First, check for an "important-announcements" channel
|
| 633 |
announcement_channel = discord.utils.get(server.channels, name="important-announcements")
|
| 634 |
if announcement_channel:
|
| 635 |
+
await announcement_channel.send(embed=embed)
|
| 636 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `important-announcements` channel.")
|
| 637 |
else:
|
| 638 |
# If no "important-announcements" channel, check for "announcements" channel
|
| 639 |
announcements_channel = discord.utils.get(server.channels, name="announcements")
|
| 640 |
if announcements_channel:
|
| 641 |
+
await announcements_channel.send(embed=embed)
|
| 642 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `announcements` channel.")
|
| 643 |
else:
|
| 644 |
# If neither channel exists, send to the default channel or public updates channel
|
| 645 |
public_updates_channel = server.public_updates_channel
|
| 646 |
if public_updates_channel:
|
| 647 |
+
await public_updates_channel.send(embed=embed)
|
| 648 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `public updates` channel.")
|
| 649 |
else:
|
| 650 |
default_channel = server.system_channel or server.text_channels[0]
|
| 651 |
+
if default_channel:
|
| 652 |
+
await default_channel.send(embed=embed)
|
| 653 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `defaults` channel.")
|
| 654 |
else:
|
| 655 |
await ctx.send(f"No suitable announcement channel found in server `{server.name}`.")
|
| 656 |
|