如何让机器人在 discord.py 重写中为频道设置慢速模式?
Posted
技术标签:
【中文标题】如何让机器人在 discord.py 重写中为频道设置慢速模式?【英文标题】:How do you make a bot set the slowmode for a channel in discord.py rewrite? 【发布时间】:2020-09-26 09:17:17 【问题描述】:如何让机器人为discord.py
重写中的频道设置慢速模式?
我试过这样做:ctx.channel.slowmode_delay = 10
它没有出现任何错误,但是当我调用上述命令时,并没有应用慢速模式。
我还能做什么?
【问题讨论】:
【参考方案1】:这是一个示例命令:
@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-StringsContext.channel
TextChannel.edit()
- 将延迟设置为 0 将禁用慢模式。
【讨论】:
以上是关于如何让机器人在 discord.py 重写中为频道设置慢速模式?的主要内容,如果未能解决你的问题,请参考以下文章