首页 > 解决方案 > 我如何发送包含对 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")```

标签: pythonasynchronousdiscorddiscord.py

解决方案


很多时候我喜欢走捷径,所以我个人会这样写:

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。


推荐阅读