[英]How do I get a discord bot to add an emoji reaction to a message using discord.py?
[英]How do i send a message including a reaction with discord.py
如何發送包含反應的消息? 我希望用戶能夠使用!Test觸發命令,並且 Bot 以 test 和紅十字作為反應來回復。
我的代碼:
@client.command()
async def Test(ctx, message = "test"):
Message = await ctx.send(apme, "🏳️🌈")
await client.add_reaction(Message, emoji="redCross:423541694600970243")```
很多時候我喜歡走捷徑,所以我個人會這樣寫:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
Client = discord.Client() # Initialise Client
client = commands.Bot(command_prefix = "?") # Initialise client bot
@client.event
async def on_ready():
print("ready")
@client.event
async def on_message(message):
if message.content == "!test" in message.content:
await message.channel.send("test :x:")
client.run("input token")
叫我懶惰,但它有效 XD。
這行得通,我不得不做一些挖掘工作,我發現你必須使用unicode來制作表情符號
您可以使用相同的概念來制作命令。
@client.event
async def on_message(message):
if message.content == "poll" in message.content:
mm = await message.channel.send("react to this")
await mm.add_reaction('\U0001f44d')
await client.process_commands(message)
@client.command()
async def poll(ctx,*,polltext):
mm = await ctx.send(f'{polltext}')
await mm.add_reaction('\U0001f44d')
await mm.add_reaction('\U0001f44e')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.