-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspammer.py
44 lines (36 loc) · 1.36 KB
/
spammer.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
import discord
from discord.ext import commands, tasks
import asyncio
# Intents are required to enable certain functionalities
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
intents.messages = True
# Prompt for bot token, guild name, and bot name
TOKEN = input("Enter your bot token: ")
GUILD_NAME = input("Enter your guild name: ")
BOT_NAME = input("Enter your bot's name: ")
bot = commands.Bot(command_prefix='/', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
for guild in bot.guilds:
if guild.name == GUILD_NAME:
print(f'Connected to guild: {guild.name} (ID: {guild.id})')
break
else:
print(f'Guild "{GUILD_NAME}" not found. Exiting...')
await bot.close()
@bot.command(name='spam')
async def spam(ctx, message: str, repeat: int, cooldown: float):
if ctx.guild.name != GUILD_NAME:
await ctx.send("This command can only be used in the specified guild.")
return
if ctx.author.name != BOT_NAME:
await ctx.send("This command can only be used by the specified bot.")
return
await ctx.send(f'Spamming message "{message}" {repeat} times with {cooldown} seconds cooldown.')
for _ in range(repeat):
await ctx.send(message)
await asyncio.sleep(cooldown)
bot.run(TOKEN)