繁体   English   中英

如何发送包含对 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM