Category: Discord Bot Tutorials
Discord Bot Tutorial#4Sending Embeds with Slash Commands!
This post was translated from the Korean original.
Contents5 sections
Hi there! Today we'll look at slash commands, which you use all the time when building Discord bots, along with how to make embeds, which let you dress up your messages nicely!
📌 What You Need
- The
discord.pylibrary installed
pip install discord.py📌 Registering a Slash Command
To use slash commands in a Discord bot, use discord.app_commands.
import discord
from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="/", intents=intents)
@bot.event
async def on_ready():
await bot.tree.sync()
print(f"✅ {bot.user} is ready!")
@bot.tree.command(name="임베드", description="Shows a pretty embed!")
async def embed(interaction: discord.Interaction):
embed = discord.Embed(
title="Embed Message",
description="Embeds make your messages look great!",
color=0x00ff00,
)
embed.add_field(name="Field 1", value="Content of the first field", inline=False)
embed.add_field(name="Field 2", value="Content of the second field", inline=True)
embed.set_footer(text="Footer message")
await interaction.response.send_message(embed=embed)
bot.run("YOUR_TOKEN")📌 The Main Parts of an Embed
- Title: The heading.
- Description: Where you write an explanation or an extra message.
- Color: Sets the color of the bar on the left.
- Field: Use this to add detailed information.
- Footer: Use this to put small text at the very bottom.
📌 Tips for Styling Your Embeds
- Matching the color to your bot or server theme gives everything a consistent look.
- You can place fields side by side with
inline=True. - To add an image, use
embed.set_image(url="이미지_링크")!
📌 Checking the Result
Run the bot and type the /임베드 (embed) command in a Discord channel, and a slick embed message will show up!✨
Now it's your turn: use slash commands and embeds to build an even cooler Discord bot!🚀
Series · Part 4 of 32
Discord Bot Tutorial
- #1Discord Bot Tutorial - Mastering Slash Commands!
- #2Adding Options (Arguments) to Slash Commands!
- #3Adding Subcommands to Slash Commands!
- #4Sending Embeds with Slash Commands!You are here
- #5Implementing Button Interactions!
- #6Implementing a Dropdown (Select Menu)!
- #7Getting User Input with a Modal (Python Example)
- #8Styling Embeds with Images and Fields (Python Example)
- #9Connecting AI (Claude & ChatGPT API) to Your Bot! (Python Example)
- #10Adding Multi-Language (i18n) Support! (Python Example)
- #11Building a Web Dashboard with Flask! (Python Example)
- #12Managing Command Cooldowns and Permissions! (Python Example)
- #13Automating Roles and Channels to Manage Your Server! (Python Example)
- #14Saving Data! JSON vs SQLite (Python Example)
- #15슬래시 명령어 그룹(Group)으로 명령어 정리하기! (파이썬 예제) (Korean)
- #16리마인더·알림 기능 만들기! 봇이 먼저 말 걸게 하기 (파이썬 예제) (Korean)
- #17RAG로 문서 기반 답변봇 만들기! 우리 서버 전용 FAQ 봇 (파이썬 예제) (Korean)
- #18투표(Poll) 기능 만들기! 다수결로 정하는 서버 규칙 (파이썬 예제) (Korean)
- #19Cog로 코드 쪼개기! 1000줄 봇도 안 더러워지는 구조 (파이썬 예제) (Korean)
- #20자동 환영 메시지·온보딩 만들기! 규칙 동의 버튼으로 자동 역할 부여 (파이썬 예제) (Korean)
- #21키워드 자동응답·금지어 필터 만들기! 경고 누적으로 자동 제재까지 (파이썬 예제) (Korean)
- #22슬래시 명령어 자동완성(Autocomplete) 만들기! 금지어를 골라서 추가·삭제 (파이썬 예제) (Korean)
- #23aiosqlite로 비동기 DB 제대로 설계하기! JSON 탈출 (파이썬 예제) (Korean)
- #24채널 난독화(Channel Obfuscation) 대응하기! 11/16부터 안 보이는 채널이 생겨요 (파이썬 예제) (Korean)
- #25봇이 죽지 않게! 에러 핸들링·로깅 체계 잡기 (파이썬 예제) (Korean)
- #26티켓(Ticket) 문의 시스템 만들기! 버튼 하나로 1:1 상담 채널 자동 생성 (파이썬 예제) (Korean)
- #27티켓 담당자 배정·우선순위 만들기! 스태프가 여러 명이어도 안 꼬이게 (파이썬 예제) (Korean)
- #28레벨·경험치(XP) 시스템 만들기! 채팅할수록 레벨업, 랭킹판까지 (파이썬 예제) (Korean)
- #29화폐·상점(Economy) 시스템 만들기! 코인 벌어서 아이템 사기 (파이썬 예제) (Korean)
- #30Build a Poll & Survey Bot! Native Polls + Buttons with Real-Time Tallies (Python Example) 🗳️
- #32Build a Server Log & Audit Log Channel! Auto-Log Message Deletes, Edits, Joins/Leaves, and Kicks (Python Example) 🕵️
- #33임시 음성방 확장, 파티방 만들기! 방장 위임·강퇴·초대 전용(비공개) 방 + 전용 채팅방 자동 생성 (파이썬 예제) 🎉 (Korean)
