-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (24 loc) · 1.01 KB
/
Copy pathmain.py
File metadata and controls
30 lines (24 loc) · 1.01 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
import discord
from discord.ext import commands
from datetime import datetime, timedelta, timezone
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
@bot.event
async def on_member_join(member):
account_age = datetime.utcnow().replace(tzinfo=timezone.utc) - member.created_at
if account_age < timedelta(days=30):
await member.send("Your account is too new to use this server and has been kicked.")
await member.kick(reason="Account age is less than one month.")
@bot.command()
async def check_account(ctx):
account_age = datetime.utcnow().replace(tzinfo=timezone.utc) - ctx.author.created_at
account_age_days = account_age.days
response = f"Your account age is {account_age_days} days."
if account_age < timedelta(days=30):
response += " Your account is too new to use the server."
await ctx.send(response)
bot.run('BOT TOKEN')