-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bot.py
80 lines (61 loc) · 2.86 KB
/
Bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.event
async def on_ready():
print(f'{bot.user} is ready!')
try:
synced = await bot.tree.sync()
print(f'Synced {len(synced)} commands')
except Exception as e:
print(e)
await bot.change_presence(activity=discord.Game(f'custom status'))
@bot.tree.command(name='all-servers', description='send your message to everyone in all servers')
async def div_all(interaction: discord.Interaction, msg: str):
sent = [interaction.user.id]
await interaction.response.send_message(f"Sending your message to {len(bot.guilds)} servers...", ephemeral=True)
guilds = bot.guilds
for g in guilds:
for m in g.members:
if m.id in sent:
continue
try:
await m.send(msg)
sent.append(m.id)
print(f"[+] Message sent to {m._user}")
except:
print(f"[-] Message couldn't be sent to {m._user}")
@bot.tree.command(name='specific-server', description="send your message to everyone in a specific server")
async def specific(interaction: discord.Interaction, msg: str, id_guild: str):
try:
guild = bot.get_guild(int(id_guild))
await interaction.response.send_message(f"Sending your message to {guild.name}...", ephemeral=True)
sent = [interaction.user.id]
for m in guild.members:
if m.id in sent:
continue
try:
await m.send(msg)
sent.append(m.id)
print(f"[+] Message sent to {m._user}")
except:
print(f"[-] Message couldn't be sent to {m._user}")
except:
await interaction.response.send_message("That server couldn't be found!" , ephemeral=True)
@bot.tree.command(name='dm', description="send your message to somemone's dm")
async def dm(interaction: discord.Interaction, msg: str, user_id: str):
try:
user = bot.get_user(int(user_id))
await user.send(msg)
await interaction.response.send_message(f"✅ Your message was sent to {user.name} ✅", ephemeral=True)
except:
await interaction.response.send_message(f"❌ Your message couldn't be sent to that user ❌", ephemeral=True)
@bot.tree.command(name='channel', description="send your message to a specific server's channel")
async def channel(interaction: discord.Interaction, msg: str, channel_id: str):
try:
channel_ = bot.get_channel(int(channel_id))
await channel_.send(msg)
await interaction.response.send_message(f"✅ Your message was sent to {channel_.name} ✅", ephemeral=True)
except:
await interaction.response.send_message(f"❌ Your message couldn't be sent to that channel ❌", ephemeral=True)
bot.run("your bot's token here")