英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论