【问题标题】:How can I send a message with discord.py without tts reading it out?如何在没有 tts 读取的情况下使用 discord.py 发送消息?
【发布时间】:2020-11-08 08:15:32
【问题描述】:

我正在使用pythondiscord.pydiscord 机器人。我在discord 上启用了TTS,即使我使用标签tts=False,只要我让机器人向频道发送消息,它就会使用tts 读出消息。我不知道如何禁用它,因为文档只是说使用tts=False,这就是我正在做的。因此,在下面的示例中,当输入 .ping 时,tts 会读出 "Bot says My ping is 10ms" 并将相同的消息发送到频道,我希望它只是将消息发送到频道而不是读出。

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")

@client.event
async def on_ready():
    print("Bot is running")

@client.command()
async def ping(ctx):
    await ctx.send(f"My ping is {round(client.latency * 1000)} ms ",tts=False)

client.run(token)

【问题讨论】:

    标签: python discord bots discord.py text-to-speech


    【解决方案1】:

    检查您的不和谐设置,您可能启用了 TTS 通知。

    设置 > 通知 > 文字转语音通知 > 选择“从不”

    【讨论】:

    • 它已启用,但我希望为某些消息启用 tts 而为其他消息禁用,所以我需要 tts=false 才能工作,而不是在设置中禁用它。
    • 尝试禁用我上面提到的设置,并在“文本和图像”中启用“允许播放和使用 /tts 命令”。这样你就不会经常收到 tts 消息,但你仍然会在tts=True 时听到它们
    • 非常感谢,这完美解决了我的问题。
    【解决方案2】:

    lol 只需删除此命令:

    #your command :
    await ctx.send(f"My ping is {round(client.latency * 1000)} ms ",tts=False)
    #fix :
    await ctx.send(f"My ping is {round(client.latency * 1000)} ms ")
    

    只需删除 (,tts=False)

    这应该可以解决问题

    【讨论】:

      【解决方案3】:

      不确定你是否想要这个:

      @client.command(name="ping", help="Shows latency")
      async def ping(ctx):
          await ctx.send("My ping is {} ms ".format(round(client.latency * 1000)))
      

      【讨论】:

        猜你喜欢
        • 2018-09-24
        • 2020-12-29
        • 2022-08-06
        • 2021-07-23
        • 2019-09-26
        • 1970-01-01
        • 2022-08-22
        • 2020-12-14
        • 2012-05-25
        相关资源
        最近更新 更多