如何使discord.py事件删除不符合特定先决条件的任何新创建的线程?

huangapple go评论63阅读模式
英文:

How to make a discord.py event delete any new threads created that don't match a specific requisite?

问题

我不知道是否可能,但我需要类似这样的东西,但用于线程

@bot.event
async def on_guild_channel_create(channel):
    if channel.name != "approved-channel-name":
        await channel.delete()
英文:

I don't know if it's possible, but I needed something just like this, but for threads

@bot.event
async def on_guild_channel_create(channel):
    if channel.name != "approved-channel-name":
        await channel.delete()

答案1

得分: 0

你可以做非常相似的事情 - 只需使用on_thread_create事件,而不是on_guild_channel_create事件。参数是一个Thread对象,它也有一个name属性和一个delete方法。

英文:

You can do very similar - just use the on_thread_create event rather than on_guild_channel_create event. The parameter is a Thread object which also has a name attribute and a delete method.

huangapple
  • 本文由 发表于 2023年2月9日 00:06:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75388560.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定