Reputation: 45
I am trying to make a discord.py bot with a kick command. So when you do ;kick (member)
it will kick the mentioned user and send that user a dm telling them they are kicked from the server. However it only dms the user if the dm is a normal message and not embed. I'm still pretty new to python so I don't understand whats wrong with the code. Here is my code:
@commands.guild_only()
@has_permissions(kick_members = True)
async def kick(self, ctx, member : discord.Member=None, *, reason="No reason was provided"):
aA=ctx.author.avatar_url
desc1=f"You are missing the following argument(s): `Member`\n```{prefix}kick <member> [reason]```"
embed1=discord.Embed(title="Missing Argument",description=desc1,color=rC)
embed1.set_author(name="Error",icon_url=aA)
try:
if member == None:
await ctx.send(embed=embed1)
return
if member == ctx.author:
await ctx.send(f"You can't kick yourself.")
return
try:
em1=discord.Embed(description=f"You were kicked out from **{ctx.guild.name}**\nReason: `{reason}`.",color=rC)
em1.set_author(icon_url=aA)
await member.send(embed=em1)
except:
pass
em2=discord.Embed(description=f"{tick} {member.mention} has been kicked out of **{ctx.guild.name}**. Reason: `{reason}`",color=gC)
await member.kick(reason = reason)
await ctx.send(embed=em2)
except:
await ctx.send("An unknown error occured.)
There isn't any errors sent in the console when I run the bot or use the command
Upvotes: 0
Views: 638
Reputation: 69
you can use:
await member.send(embed=em2)
ctx will send in the channel where the command was done.
Upvotes: 1