【问题标题】:I want to send a message to a specific channel when my discord.py bot enables当我的 discord.py 机器人启用时,我想向特定频道发送消息
【发布时间】:2021-10-04 04:46:50
【问题描述】:

当我的 discord.py 机器人启用时如何向特定频道发送消息 我正在使用新的 discord.py,其中 (ctx) 是一个东西

【问题讨论】:

    标签: discord.py


    【解决方案1】:

    获取频道ID后,即可使用

    channel = discord.utils.get(ctx.guild.channels, id = channelID) #or name if you want by name
    await channel.send("This is a test message!")
    

    【讨论】:

    • 您也可以使用bot.get_channel(12345) 从缓存中获取它。没有得到公会对象
    猜你喜欢
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 2019-05-30
    • 2021-06-10
    • 1970-01-01
    • 2020-07-23
    相关资源
    最近更新 更多