Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ·
a6cebb0
1
Parent(s): d125ec3
new update for announce command
Browse files- .gitignore +2 -1
- pydvpl_bot.py +36 -4
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
__pycache__
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
.env
|
pydvpl_bot.py
CHANGED
|
@@ -476,17 +476,29 @@ async def say(ctx, destination_type, *args):
|
|
| 476 |
announcement_channel = discord.utils.get(server.channels, name="important-announcements")
|
| 477 |
if announcement_channel:
|
| 478 |
await announcement_channel.send(message)
|
| 479 |
-
await ctx.send(f"Message `{message}` sent to server `{server.name}` in
|
| 480 |
await ctx.message.delete()
|
| 481 |
else:
|
| 482 |
announcements_channel = discord.utils.get(server.channels, name="announcements")
|
| 483 |
if announcements_channel:
|
| 484 |
await announcements_channel.send(message)
|
| 485 |
-
await ctx.send(f"Message `{message}` sent to server `{server.name}` in
|
| 486 |
await ctx.message.delete()
|
| 487 |
else:
|
| 488 |
-
|
| 489 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
else:
|
| 491 |
await ctx.send("Server not found.")
|
| 492 |
await ctx.message.delete()
|
|
@@ -522,6 +534,26 @@ async def say(ctx, destination_type, *args):
|
|
| 522 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 523 |
|
| 524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
@bot.command(help="Show how long the bot has been playing the current game.")
|
| 526 |
async def uptime(ctx):
|
| 527 |
global activity_start_time
|
|
|
|
| 476 |
announcement_channel = discord.utils.get(server.channels, name="important-announcements")
|
| 477 |
if announcement_channel:
|
| 478 |
await announcement_channel.send(message)
|
| 479 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `important-announcements` channel.")
|
| 480 |
await ctx.message.delete()
|
| 481 |
else:
|
| 482 |
announcements_channel = discord.utils.get(server.channels, name="announcements")
|
| 483 |
if announcements_channel:
|
| 484 |
await announcements_channel.send(message)
|
| 485 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `announcements` channel.")
|
| 486 |
await ctx.message.delete()
|
| 487 |
else:
|
| 488 |
+
public_updates_channel = server.public_updates_channel
|
| 489 |
+
if public_updates_channel:
|
| 490 |
+
await public_updates_channel.send(message)
|
| 491 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `public updates` channel.")
|
| 492 |
+
await ctx.message.delete()
|
| 493 |
+
else:
|
| 494 |
+
default_channel = server.system_channel or server.text_channels[0] # Default to the first text channel
|
| 495 |
+
if default_channel:
|
| 496 |
+
await default_channel.send(message)
|
| 497 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in the default channel.")
|
| 498 |
+
await ctx.message.delete()
|
| 499 |
+
else:
|
| 500 |
+
await ctx.send("No announcement channels found in the server. Also, no default `public updates` neither `default` channels found.")
|
| 501 |
+
await ctx.message.delete()
|
| 502 |
else:
|
| 503 |
await ctx.send("Server not found.")
|
| 504 |
await ctx.message.delete()
|
|
|
|
| 534 |
# FUNCTION ------------------------------------------------------ SPLIT
|
| 535 |
|
| 536 |
|
| 537 |
+
@bot.command(help="Send announcements to all servers")
|
| 538 |
+
async def announce(ctx, *, message):
|
| 539 |
+
if str(ctx.author.id) != AUTHORIZED_USER_ID:
|
| 540 |
+
await ctx.send("You are not authorized to use this command.")
|
| 541 |
+
await ctx.message.delete()
|
| 542 |
+
return
|
| 543 |
+
|
| 544 |
+
for server in bot.guilds:
|
| 545 |
+
announcement_channel = server.public_updates_channel
|
| 546 |
+
if announcement_channel:
|
| 547 |
+
await announcement_channel.send(message)
|
| 548 |
+
await ctx.send(f"Announcement `{message}` sent to server `{server.name}` in `public updates` channel.")
|
| 549 |
+
else:
|
| 550 |
+
await ctx.send(f"No 'public updates' channel found in server `{server.name}`.")
|
| 551 |
+
await ctx.message.delete()
|
| 552 |
+
|
| 553 |
+
|
| 554 |
+
# FUNCTION ------------------------------------------------------ SPLIT
|
| 555 |
+
|
| 556 |
+
|
| 557 |
@bot.command(help="Show how long the bot has been playing the current game.")
|
| 558 |
async def uptime(ctx):
|
| 559 |
global activity_start_time
|