
이미 서버가 있는 상태면 패스
---> 해당링크 들어가서 서버 생성 참고하기 서버생성링크
생각보다 질문이 많이 들어와서 같이 정리합니다.
제가 한 방법으로 알려드리니 편한 방법으로 알아서 커스텀 하시면 됩니다.
pip install discord.py
터미널에 입력 후 엔터로 실행
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.command()
async def 청소(ctx, number: int = None):
if number is None:
await ctx.send("지울 메시지 수를 입력해주세요. 예: !청소 3")
return
if not ctx.author.guild_permissions.manage_messages:
await ctx.send("메시지를 관리할 권한이 없습니다!")
return
def is_not_command(msg):
return msg.id != ctx.message.id
deleted = await ctx.channel.purge(limit=number + 1, check=is_not_command)
await ctx.send(f"{len(deleted)}개의 메시지가 삭제되었습니다.", delete_after=5)
bot.run("토큰")