-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
98 lines (83 loc) · 4.64 KB
/
main.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import discord
import asyncio
from discord import app_commands
# Enable necessary bot intents
intents = discord.Intents.default()
intents.guilds = True
intents.guild_messages = True
intents.message_content = True
intents.members = True # Required for moderation commands & mentions
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
@client.event
async def on_ready():
await tree.sync()
print(f"✅ Bot is ready as {client.user} and commands are synced!")
# ✅ `/help` command (Lists all commands)
@tree.command(name="help", description="Lists all available commands and their usage.")
async def help_command(interaction: discord.Interaction):
help_text = (
"**📖 Bot Command Guide**\n\n"
"🔹 **/help** → Shows this message.\n"
"🔹 **/say <message>** → Bot repeats your message.\n"
"🔹 **/devbadge** → Links the discord developer page where you can claim the badge.\n"
"🔹 **/warn <user> <reason>** → Warns a user.\n"
"🔹 **/kick <user> <reason>** → Kicks a user (Requires `Kick Members`).\n"
"🔹 **/ban <user> <reason>** → Bans a user (Requires `Ban Members`).\n"
"🔹 **/sping <user> <pings_per_message> <messages>** → Spams mentions in controlled messages.\n"
"============================================\n"
"**📌 `/sping` Limits:**\n"
"- Keep in mind that the limits are so discord does not limit or block the bot\n"
"� Max **10 mentions per message**\n"
"� Max **20 messages per command**\n"
"� **1-second delay** between messages to avoid rate-limiting\n"
"� Requires **Manage Messages permission**\n"
"============================================\n"
"made by n26g"
)
await interaction.response.send_message(help_text)
# ✅ `/devbadge` command
@tree.command(name="devbadge", description="Get the Developer Badge")
async def devbadge(interaction: discord.Interaction):
await interaction.response.send_message("Check the [Discord Developer Portal](<https://discord.com/developers/active-developer>) to claim")
# ✅ `/warn` command
@tree.command(name="warn", description="Warns a user")
async def warn(interaction: discord.Interaction, user: discord.Member, reason: str):
await interaction.response.send_message(f"⚠️ {user.mention} has been warned for: **{reason}**")
# ✅ `/kick` command
@tree.command(name="kick", description="Kicks a user")
async def kick(interaction: discord.Interaction, user: discord.Member, reason: str):
if interaction.user.guild_permissions.kick_members:
await user.kick(reason=reason)
await interaction.response.send_message(f"👢 {user.mention} has been kicked for: **{reason}**")
else:
await interaction.response.send_message("❌ You do not have permission to kick members.", ephemeral=True)
# ✅ `/ban` command
@tree.command(name="ban", description="Bans a user")
async def ban(interaction: discord.Interaction, user: discord.Member, reason: str):
if interaction.user.guild_permissions.ban_members:
await user.ban(reason=reason)
await interaction.response.send_message(f"🔨 {user.mention} has been banned for: **{reason}**")
else:
await interaction.response.send_message("❌ You do not have permission to ban members.", ephemeral=True)
# ✅ `/sping` command (Spam Ping with user, pings per message, and total messages)
@tree.command(name="sping", description="Spam ping a user multiple times with custom message count")
async def sping(interaction: discord.Interaction, user: discord.Member, pings_per_message: int, messages: int):
if not interaction.user.guild_permissions.manage_messages:
await interaction.response.send_message("❌ You do not have permission to use this command.", ephemeral=True)
return
# Set limits to prevent abuse
max_pings_per_message = 10 # Max 10 mentions per message
max_messages = 20 # Max 20 messages
pings_per_message = min(pings_per_message, max_pings_per_message)
messages = min(messages, max_messages)
await interaction.response.send_message(f"🚨 Spamming {user.mention} **{pings_per_message} times per message** for **{messages} messages**...")
ping_text = " ".join([user.mention] * pings_per_message) # Create message with multiple mentions
for _ in range(messages):
await interaction.channel.send(ping_text)
await asyncio.sleep(1) # Prevent rate-limiting
# Run the bot
TOKEN_PATH = "token.txt"
with open(TOKEN_PATH, "r") as file:
TOKEN = file.read().strip()
client.run(TOKEN)