Code
Everything works and all but it does 2 seconds instead of 10seconds and does 1minute instead of 10 I was just wandering if there is anything I did wrong because I have been trying to figure it out for the last 20 minutes and I couldnt find the answer to why it isn't doing the right duration
@client.command()
async def temprole(ctx, member : discord.Member, role : discord.Role, duration, *, reason=None):
if ctx.message.author.guild_permissions.manage_roles:
time_convert = {"s":1, "m":60, "h":3600,"d":86400}
temprole= int(duration[0]) * time_convert[duration[-1]]
await member.add_roles(role)
await ctx.send(embed = discord.Embed(description=f"{member.mention} has been given the role {role} by {ctx.author.mention} for {reason}", color=discord.Color.yellow()), delete_after=15)
embed = discord.Embed(title="Temprole Log", description=f"{member.mention} has been temporarily given the role {role} for {duration} by {ctx.author.mention}", color=0x1355ed)
embed.add_field(name="User", value=f"{member}", inline=True)
embed.add_field(name="UserID", value=f"{member.id}", inline=True)
embed.add_field(name="Moderator", value=f"{ctx.author}", inline=True)
embed.add_field(name="Reason", value=f"{reason}", inline=True)
embed.add_field(name="duration", value=f"{duration}", inline=True)
embed.set_footer(text=f"Temprole Log : {member.name}")
embed.timestamp = datetime.datetime.utcnow()
logchannel = client.get_channel(1015274200841330749)
await logchannel.send(embed=embed)
await ctx.message.delete()
print(f"{member.name} was given the role {role}")
await asyncio.sleep(temprole)
await member.remove_roles(role)
await ctx.send(embed = discord.Embed(description=f"{member.mention} has been removed from the role {role} after {duration}", color=discord.Color.yellow()), delete_after=15)
embed = discord.Embed(title="Temprole Log", description=f"{member.mention} has been removed from the role {role} automatically by <@1013161207072571482> after {duration}", color=0x1355ed)
embed.add_field(name="User", value=f"{member}", inline=True)
embed.add_field(name="UserID", value=f"{member.id}", inline=True)
embed.add_field(name="Moderator", value=f"{ctx.author}", inline=True)
embed.add_field(name="Reason", value=f"{reason}", inline=True)
embed.add_field(name="duration", value=f"{duration}", inline=True)
embed.set_footer(text=f"Temprole Log : {member.name}")
embed.timestamp = datetime.datetime.utcnow()
logchannel = client.get_channel(1015274200841330749)
await logchannel.send(embed=embed)
print(f"{member.name} was removed from the role {role}")
else:
em = discord.Embed(title="Permissions Required!", description=f"{ctx.author.name} You do not have the required Permissions to use this command", color=discord.Colour.red())
await ctx.send(embed=em)