如何使纷争机器人才通知我,当一个用户加入语音通道并且已经留下语音信道超过5分钟之前

0

的问题

@client.event
async def on_voice_state_update(member, before, after):
    # This function is called when not only member join to the voice channel,
    # but also member changed their status to mute.
    # So, it is necessary to catch only events that joining channel.
    if before.channel != after.channel:
        if after.channel is not None and after.channel.id == int(VOICE_CHANNEL_ID1):
            _name = member.nick if member.nick else member.name
            message = {
                "message": "\n" + _name + " Join The Livestream Channel"
            }
            requests.post(LINE_NOTIFY_API_URL, headers=HEADERS, data=message)
    if before.channel != after.channel:
        if after.channel is not None and after.channel.id == int(VOICE_CHANNEL_ID2):
            _name = member.nick if member.nick else member.name
            message = {
                "message": "\n" + _name + " Join The Nongskuy Channel"
            }
            requests.post(LINE_NOTIFY_API_URL, headers=HEADERS, data=message)

client.run(DISCORD_BOT_ACCESS_TOKEN)

所以我试图让一个机器人可以通知我的线组每当有人加入语音信道我不和谐的服务器。 问题是,我的朋友经常玩我的机器人由离开和加入音频道屡和我的机器人将垃圾邮件在我的线组,如果有人加入语音通道。因此,我需要一个有助于使我的机器人才通知我的线组如果一个用户已经离开的声音频道于5分钟,参加再次要语音通道

discord
2021-11-23 15:55:57
1

最好的答案

0

看来你基本上想要检查如果5或更多分钟之间传递的各个语音通道离开/加入的用户。 你可以使用 datetime 模块得到的时候当一个用户加入和离开通道。 如何获得的当前时间蟒蛇. 一旦你得到的时间,你可以得到一分钟的时间是这样的:

>>> now = datetime.now()
>>> print(now)
2021-11-23 14:05:31.787939
>>> print(now.minute)
5

所以你可以储存 now.minute 在另一个变量,并将它用于比较。

2021-11-23 19:11:34

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................