-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.py
37 lines (28 loc) Β· 1.31 KB
/
chat.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
import discord
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('TOKEN')
CHANNEL_ID = os.getenv('CHANNEL_ID_CHAT')
class MyClient(discord.Client):
async def on_ready(self):
print(f'We have logged in as {self.user}')
async def on_message(self, message):
if message.author == self.user:
return
if message.content.startswith('/μ±ν
μ²μ-') and message.channel.id == int(CHANNEL_ID):
try:
num = message.content.replace('/μ±ν
μ²μ-', '').strip()
num = int(num)
await message.channel.purge(limit=num + 1)
await message.channel.send(f'{num}κ°μ λ©μμ§λ₯Ό μμ νμ΅λλ€.')
except ValueError:
await message.channel.send('μμ ν λ©μμ§μ κ°μλ₯Ό μ νν μ
λ ₯ν΄μ£ΌμΈμ. μ) /μ±ν
μ²μ-7')
if message.content.startswith('/μ±ν
λͺ¨λ μ²μ') and message.channel.id == int(CHANNEL_ID):
deleted = await message.channel.purge(limit=100)
while len(deleted) == 100:
deleted = await message.channel.purge(limit=100)
await message.channel.send('λͺ¨λ λ©μμ§λ₯Ό μμ νμ΅λλ€.')
intents = discord.Intents.all()
client = MyClient(intents=intents)
client.run(TOKEN)