【发布时间】:2022-01-05 14:36:11
【问题描述】:
如果服务器管理员写信给机器人,那么机器人会向频道发送这条消息吗?
bot 仅从服务器管理员向频道发送消息,管理员向 bot 写入私人消息......
我是新手,谢谢你的帮助
【问题讨论】:
标签: python discord discord.py bots
如果服务器管理员写信给机器人,那么机器人会向频道发送这条消息吗?
bot 仅从服务器管理员向频道发送消息,管理员向 bot 写入私人消息......
我是新手,谢谢你的帮助
【问题讨论】:
标签: python discord discord.py bots
你可以很简单地做到这一点:
@bot.command()
@commands.has_guild_permissions(administrator=True)
async def send_message(ctx, channel: discord.TextChannel, *, message: str):
await channel.send(message)
要使用此命令,请键入:[your_prefix]send_message #channel your message
注意:此命令仅适用于拥有administrator 权限的成员。
【讨论】:
from discord.ext import command 写入。还将bot 替换为client。 [your_prefix]send_message #channel your message 是一个用法示例,您需要在不和谐的聊天中输入它来触发命令。