discord - discord.py 重写 tempmute 命令
问题描述
我的机器人中有一个静音命令,但我想在上面添加一个计时器,不太确定如何操作,这是我当前的代码。它正确添加了代码,并且全部正确发送,但我不太确定的持续时间。任何帮助,将不胜感激!
编辑:我得到了持续时间,但我将如何将其转换为分钟/小时等?
@client.command()
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, mute_time : int, *, reason=None):
role = discord.utils.get(ctx.guild.roles, name="[Muted]")
await member.add_roles(role)
await ctx.send(f'**Muted** {member.mention}\n**Reason: **{reason}\n**Duration:** {mute_time}')
embed = discord.Embed(color=discord.Color.green())
embed.add_field(name=f"You've been **Muted** in {ctx.guild.name}.", value=f"**Action By: **{ctx.author.mention}\n**Reason: **{reason}\n**Duration:** {mute_time}")
await member.send(embed=embed)
await asyncio.sleep(mute_time)
await member.remove_roles(role)
await ctx.send(f"**Unmuted {member.mention}**")
解决方案
推荐阅读
- node.js - 如何使用nodejs在终端中正确执行./filename
- utf-8 - WildFly RestEasy UTF-8 响应
- bpf - BPF 验证器在尝试访问 __sk_buff 成员时拒绝
- ios - 禁用 iOS 系统通知
- reactjs - Create React App serviceworker 不包括生成的文件之一
- python - 如何用分号后带有数字的 Z 字母解析日期时间
- php - 如何在 Windows 加载时旋转滑块按钮弹出窗口
- javascript - 查找所有具有包含 URL 的背景图像的 div/元素并删除文本
- java - 我无法从外部访问我的服务器 Tomcat 9
- events - 如何在注册时输出评论,并在选中时从输出中删除“请选择复选框”