Discord.py静音命令

Discord.py静音命令,第1张

Discord.py静音命令

就像是

silent_channels = set()@BSL.eventasync def on_message(message):    if message.channel in silent_channels:        if not message.author.server_permissions.administrator and  message.author.id != ownerID: await BSL.delete_message(message) return    await BSL.process_commands(message)@BSL.command(pass_context=True)async def silent(ctx, length=0): # Corrected spelling of length    if ctx.message.author.server_permissions.administrator or ctx.message.author.id == ownerID:        silent_channels.add(ctx.message.channel)        await BSL.say('Going silent.')        if length: length = int(length) await asyncio.sleep(length) if ctx.message.channel not in silent_channels: # Woken manually     return silent_channels.discard(ctx.message.channel) await BSL.say('Waking up.')@BSL.command(pass_context=True)async def wake(ctx):    silent_channels.discard(ctx.message.channel)

应该可以工作(我还没有测试过,测试机器人很痛苦)。在集合中快速搜索,因此对每条消息进行搜索都不会真正给您的资源带来负担。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5649534.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存