小编Den*_*erl的帖子

如何在 Python 3 中计算时间?

我想要一个代码来显示某人在语音通道中的完整时间,但我不知道如何启动和停止计数器。

    @bot.event
    async def on_voice_state_update(before, after):

        if after.voice.voice_channel:
            timestrr = time.strftime("%d.%m.%Y-%H:%M:%S")
            voicezeit(after.id, timestrr)
    #here should a timer start
        else:
             #and here should the timer stop
Run Code Online (Sandbox Code Playgroud)

我真的不知道该怎么做,所以我真的很感激每一个帮助。

python python-3.x discord discord.py

8
推荐指数
1
解决办法
5万
查看次数

如何检查用户是否在不和谐中具有特定角色

这应该检查特定的人是否有或没有静音角色

    @bot.command(pass_context=True)
    @commands.has_role("Admin")
    async def unmute(ctx, user: discord.Member):
        role = discord.utils.find(lambda r: r.name == 'Member', 
    ctx.message.server.roles)
        if user.has_role(role):
            await bot.say("{} is not muted".format(user))
        else:
            await bot.add_roles(user, role)
Run Code Online (Sandbox Code Playgroud)

抛出这个错误

命令引发异常:AttributeError: 'Member' object has no attribute 'has_role'

我不知道该怎么做所以我真的很感激我能得到的每一个帮助

python python-3.x discord.py

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

discord.py ×2

python ×2

python-3.x ×2

discord ×1