【问题标题】:sending a message from the administrator to the channel (Discord Bot)从管理员向频道发送消息(Discord Bot)
【发布时间】:2022-01-05 14:36:11
【问题描述】:

如果服务器管理员写信给机器人,那么机器人会向频道发送这条消息吗?

bot 仅从服务器管理员向频道发送消息,管理员向 bot 写入私人消息......

我是新手,谢谢你的帮助

【问题讨论】:

    标签: python discord discord.py bots


    【解决方案1】:

    你可以很简单地做到这一点:

    @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 权限的成员。

    【讨论】:

    • 谢谢解答,请问有详细的操作吗?我是新手,如何记录管理员和消息发送到的频道?
    • 好的,我已经编辑了我的答案。
    • 你清楚了吗?
    • 我在使用时遇到错误ibb.co/NFBW10g
    • 从文件开头的from discord.ext import command 写入。还将bot 替换为client[your_prefix]send_message #channel your message 是一个用法示例,您需要在不和谐的聊天中输入它来触发命令。
    猜你喜欢
    • 2021-01-10
    • 2021-03-24
    • 2020-04-07
    • 2023-03-27
    • 2022-01-21
    • 2023-03-07
    • 2020-02-07
    • 2020-10-01
    • 2018-11-24
    相关资源
    最近更新 更多