class My_Cog(commands.Cog, name='Moderation'):
def __init__(self, bot):
self.bot = bot
@client.command()#tempmute command
async def tempmute(ctx, member: discord.Member, time: int, d, *, reason=None):
guild = ctx.guild
for role in guild.roles:
if role.name == "Muted":
await member.add_roles(role)
embed = discord.Embed(title="muted!", description=f"{member.mention} has been tempmuted ", colour=discord.Colour.light_gray())
embed.add_field(name="reason:", value=reason, inline=False)
embed.add_field(name="time left for the mute:", value=f"{time}{d}", inline=False)
await ctx.send(embed=embed)
if d == "s":
await asyncio.sleep(time)
if d == "m":
await asyncio.sleep(time*60)
if d == "h":
await asyncio.sleep(time*60*60)
if d == "d":
await asyncio.sleep(time*60*60*24)
await member.remove_roles(role)
embed = discord.Embed(title="unmute (temp) ", description=f"unmuted -{member.mention} ", colour=discord.Colour.light_gray())
await ctx.send(embed=embed)
return
Hi everyone! What is the command tempmute is already an existing command or alias. in Python? What does it do? I cant understand why cant i create a cog, when this command is in the class? It gives me an error. I dont know what to do
class My_Cog(commands.Cog, name='Moderation'):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=['tempmute'])#tempmute command
async def temp_mute(self, ctx, member: discord.Member, time: int, d, *, reason=None):
guild = ctx.guild
for role in guild.roles:
if role.name == "Muted":
await member.add_roles(role)
embed = discord.Embed(title="muted!", description=f"{member.mention} has been tempmuted ", colour=discord.Colour.light_gray())
embed.add_field(name="reason:", value=reason, inline=False)
embed.add_field(name="time left for the mute:", value=f"{time}{d}", inline=False)
await ctx.send(embed=embed)
if d == "s":
await asyncio.sleep(time)
if d == "m":
await asyncio.sleep(time*60)
if d == "h":
await asyncio.sleep(time*60*60)
if d == "d":
await asyncio.sleep(time*60*60*24)
await member.remove_roles(role)
embed = discord.Embed(title="unmute (temp) ", description=f"unmuted -{member.mention} ", colour=discord.Colour.light_gray())
await ctx.send(embed=embed)
return
You can try this to get rid of the error, but check around and see if you have another command named tempmute. Also, while in a cog, use "@commands.command".