언어/파이썬 디스코드봇
[디스코드봇] 메시지를 이쁘게 출력하기 embed
proqk
2020. 9. 7. 16:57
반응형
import discord
import asyncio
from discord.ext import commands
from discord.ext.commands import Bot
client = discord.Client()
@client.event
async def on_message(message):
if message.content.startswith('!shop'):
embed = discord.Embed(title="SHOP BOT",description="SHOP 아이템 목록. 쇼핑을 합시다", color=0x00aaaa)
embed.add_field(name="STEP🦶", value="빠르게 이동한다", inline=False)
embed.add_field(name="STUN⚔️", value="스턴!", inline=False)
await message.channel.send(embed=embed)
client.run('봇토큰입력')
embed에 메시지를 담아서 출력하면 이쁘게 출력할 수 있다
discord.Embed로 title과 description, color를 정해서 embed에 담는다
embed.add_field로 필드를 추가할 수 있다
msg에 담는다면 이전 글에서 했던 이모지 리액션도 적용할 수 있다
import discord
import asyncio
from discord.ext import commands
from discord.ext.commands import Bot
client = discord.Client()
@client.event
async def on_message(message):
if message.content.startswith('!shop'):
embed = discord.Embed(title="SHOP BOT",description="SHOP 아이템 목록. 쇼핑을 합시다", color=0x00aaaa)
embed.add_field(name="STEP🦶", value="빠르게 이동한다", inline=False)
embed.add_field(name="STUN⚔️", value="스턴!", inline=False)
msg = await message.channel.send(embed=embed)
await msg.add_reaction("🦶") #step
await msg.add_reaction("⚔️") #stun
client.run('봇토큰입력')
봇이 이모지로 반응해 준다
반응형