discord - Discord Bot 获取用户的文本并发布
问题描述
我正在寻找一个用 .py 制作的不和谐机器人,它可以做这三件事:
- 发布到特定频道
- 无论用户写什么,然后机器人将其删除并发布
- 谁在另一个特定频道中写了什么的信息。示例:{user} 写道
Hi my name is Nick
提前致谢!我还没有尝试过,因为我没有那么有经验。非常感谢。
解决方案
尝试这个
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='prefix')
@bot.command()
async def say(ctx, channel: discord.TextChannel, *, arg):
message = ctx.message # Get your message
await channel.send(f"{ctx.author}: {arg}") # Send your message
await message.delete() # Delete user message
bot.run('token')
推荐阅读
- lua - Lua 脚本(鼠标相关)
- ios - Swift - 排队合并请求
- c++ - 为什么不能使用`cout`直接在c++中输出return的地址?
- directory - 为什么配音看不到源文件夹?
- python - 如何在 python 中为电报机器人设置 webhook?
- scala - 将列元素添加到 Dataframe Scala Spark
- javascript - Javascript包含()失败
- javascript - getElementById 返回未定义的数组
- hibernate - 模式验证:子类表中缺少列
- flutter - 如何从 Flutter 中的另一个类访问变量