python - 我如何发送包含对 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。
推荐阅读
- angular - 不要从 fetch api 分配数据
- node.js - 当我在浏览器中运行 firebase 功能时,出现 403 错误
- python - 如何使用python更改终端中的目录?
- python - Python Pandas:如何检索多个值的行索引
- android - Camera2 API 上相同的分辨率比例下视角不同
- javascript - 如何在插入表之前检查csv文件是否有重复值
- sql - 通过在 mssql 中合并另一个表来更新空值
- css - 如何创建具有固定和自动包装的弹性元素的弹性框?
- python - 加入一个充满元组而不是字符串的列表
- cefsharp - CEF 是否支持 NPAPI 插件?