import discord
from discord.ext import commands
from discord import app_commands
TOKEN = "봇토큰"
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
try:
synced = await bot.tree.sync()
print(f"슬래시 명령어 {len(synced)}개 동기화 완료")
except Exception as e:
print(e)
print(f"{bot.user} 로그인 완료")
@bot.tree.command(name="임베드생성", description="임베드를 생성합니다.")
@app_commands.describe(
채널="보낼 채널",
제목="임베드 제목",
내용="임베드 내용",
색상="red, blue, green, gold, purple",
이미지="이미지 URL (선택)",
버튼이름="버튼 이름 (선택)",
버튼링크="버튼 링크 (선택)"
)
async def 임베드생성(
interaction: discord.Interaction,
채널: discord.TextChannel,
제목: str,
내용: str,
색상: str,
이미지: str = None,
버튼이름: str = None,
버튼링크: str = None
):
색상목록 = {
"red": discord.Color.red(),
"blue": discord.Color.blue(),
"green": discord.Color.green(),
"gold": discord.Color.gold(),
"purple": discord.Color.purple()
}
embed = discord.Embed(
title=제목,
description=내용,
color=색상목록.get(색상.lower(), discord.Color.blurple())
)
if 이미지:
embed.set_image(url=이미지)
view = None
if 버튼이름 and 버튼링크:
view = discord.ui.View()
button = discord.ui.Button(
label=버튼이름,
url=버튼링크
)
view.add_item(button)
await 채널.send(embed=embed, view=view)
await interaction.response.send_message(
f"✅ {채널.mention} 채널에 임베드를 전송했습니다.",
ephemeral=True
)
bot.run("")