Rifat Azad commited on
Commit
f2a123b
·
1 Parent(s): 5a90716
Files changed (1) hide show
  1. 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
- announcement_channel = server.public_updates_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
- else:
635
- announcements_channel = discord.utils.get(server.channels, name="announcements")
636
- if announcements_channel:
637
- await announcements_channel.send(message)
638
- await ctx.send(f"Message `{message}` sent to server `{server.name}` in `announcements` channel.")
639
- await ctx.message.delete()
640
- else:
641
- public_updates_channel = server.public_updates_channel
642
- if public_updates_channel:
643
- await public_updates_channel.send(message)
644
- await ctx.send(f"Message `{message}` sent to server `{server.name}` in `public updates` channel.")
645
- await ctx.message.delete()
646
- else:
647
- default_channel = server.system_channel or server.text_channels[0] # Default to the first text channel
648
- if default_channel:
649
- await default_channel.send(message)
650
- await ctx.send(f"Message `{message}` sent to server `{server.name}` in the default channel.")
651
- await ctx.message.delete()
652
- else:
653
- await ctx.send(f"No 'public updates' channel found in server `{server.name}`.")
 
 
 
 
 
 
 
 
 
 
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