Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ·
f2a123b
1
Parent(s): 5a90716
updated
Browse files- pydvpl_bot.py +31 -21
pydvpl_bot.py
CHANGED
|
@@ -625,32 +625,42 @@ async def announce(ctx, *, message):
|
|
| 625 |
return
|
| 626 |
|
| 627 |
for server in bot.guilds:
|
| 628 |
-
|
| 629 |
announcement_channel = discord.utils.get(server.channels, name="important-announcements")
|
| 630 |
if announcement_channel:
|
| 631 |
await announcement_channel.send(message)
|
| 632 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `important-announcements` channel.")
|
| 633 |
await ctx.message.delete()
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
await ctx.message.delete()
|
| 655 |
|
| 656 |
|
|
|
|
| 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(message)
|
| 632 |
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `important-announcements` channel.")
|
| 633 |
await ctx.message.delete()
|
| 634 |
+
continue # Move to the next server
|
| 635 |
+
|
| 636 |
+
# If no "important-announcements" channel, check for "announcements" channel
|
| 637 |
+
announcements_channel = discord.utils.get(server.channels, name="announcements")
|
| 638 |
+
if announcements_channel:
|
| 639 |
+
await announcements_channel.send(message)
|
| 640 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `announcements` channel.")
|
| 641 |
+
await ctx.message.delete()
|
| 642 |
+
continue # Move to the next server
|
| 643 |
+
|
| 644 |
+
# If neither, check for "public updates" channel
|
| 645 |
+
public_updates_channel = server.public_updates_channel
|
| 646 |
+
if public_updates_channel:
|
| 647 |
+
await public_updates_channel.send(message)
|
| 648 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in `public updates` channel.")
|
| 649 |
+
await ctx.message.delete()
|
| 650 |
+
continue # Move to the next server
|
| 651 |
+
|
| 652 |
+
# If no specific channel found, send to the default channel (first text channel)
|
| 653 |
+
default_channel = server.system_channel or server.text_channels[0]
|
| 654 |
+
if default_channel:
|
| 655 |
+
await default_channel.send(message)
|
| 656 |
+
await ctx.send(f"Message `{message}` sent to server `{server.name}` in the default channel.")
|
| 657 |
+
await ctx.message.delete()
|
| 658 |
+
continue # Move to the next server
|
| 659 |
+
|
| 660 |
+
# If no appropriate channel found, notify that no suitable channel was found
|
| 661 |
+
await ctx.send(f"No suitable announcement channel found in server `{server.name}`.")
|
| 662 |
+
|
| 663 |
+
# Delete the original command message
|
| 664 |
await ctx.message.delete()
|
| 665 |
|
| 666 |
|