python - 如何让机器人在 discord.py 重写中为 channel 设置慢速模式?

标签 python discord discord.py discord.py-rewrite

如何让机器人在 discord.py 中为 channel 设置慢速模式改写?

我试过这样做:ctx.channel.slowmode_delay = 10
它没有出现任何错误,但是当我调用上述命令时,没有应用慢速模式。

我还可以做些什么?

最佳答案

这是一个示例命令:

@bot.command()
async def setdelay(ctx, seconds: int):
    await ctx.channel.edit(slowmode_delay=seconds)
    await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")

引用文献:
  • f-Strings
  • Context.channel
  • TextChannel.edit() - 将延迟设置为 0 将禁用慢速模式。
  • 关于python - 如何让机器人在 discord.py 重写中为 channel 设置慢速模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62244594/

    相关文章:

    python - 一次性验证可比较项的二叉搜索树

    python - Discord.py 添加角色

    discord.py - 如何为不和谐的机器人实现仅限 Patreon 的命令?

    python - 我制作了一个获取股票价格的 python 机器人,但我该怎么做才能使参数不使用空格?

    python - Python 中带字符串的二进制文件

    python - 属性错误 : 'QuerySet' object has no attribute 'add'

    python - tensorflow教程中测试数据的计算

    python - discord.py 中的邀请命令(通过 ID 邀请用户到服务器)

    javascript - node.js - 我应该如何组织我的代码?我现在得到的并不可靠

    javascript - Discord Bot 触发其他机器人 Action