-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
47 lines (36 loc) · 1.32 KB
/
bot.py
File metadata and controls
47 lines (36 loc) · 1.32 KB
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
import discord
from discord.ext import commands
import asyncio
# Define your bot's prefix
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
# Define the user ID to apply the limit to
LIMITED_USER_ID = 'put user id here'
# Define the cooldown time and maximum messages
COOLDOWN_TIME = 84600 # in seconds
MAX_MESSAGES = 5
# Counter for the number of messages sent by the limited user
message_count = 0
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.event
async def on_message(message):
global message_count
# Ignore messages from bots
if message.author.bot:
return
# Check if the message is from the limited user
if message.author.id == LIMITED_USER_ID:
# Increment message count
message_count += 1
await message.channel.send(f"{5 - message_count} left")
# Check if the user has reached the maximum messages
if message_count > MAX_MESSAGES:
await message.delete()
await message.channel.send(f"<@{LIMITED_USER_ID}>, you are sending messages too quickly. Please slow down.")
# Reset message count after cooldown time
await asyncio.sleep(COOLDOWN_TIME)
message_count -= 1
await bot.process_commands(message)
# Run the bot with your token
bot.run('Discord token here')