我想要一个代码来显示某人在语音通道中的完整时间,但我不知道如何启动和停止计数器。
@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)
我真的不知道该怎么做,所以我真的很感激每一个帮助。
这应该检查特定的人是否有或没有静音角色
@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'
我不知道该怎么做所以我真的很感激我能得到的每一个帮助