首页 > 解决方案 > Discord Bot 获取用户的文本并发布

问题描述

我正在寻找一个用 .py 制作的不和谐机器人,它可以做这三件事:

  1. 发布到特定频道
  2. 无论用户写什么,然后机器人将其删除并发布
  3. 谁在另一个特定频道中写了什么的信息。示例:{user} 写道Hi my name is Nick

提前致谢!我还没有尝试过,因为我没有那么有经验。非常感谢。

标签: discorddiscord.py

解决方案


尝试这个

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')


推荐阅读