Reputation: 11
This kick command worked, but after adding an embed it doesn't. Any idea why?
#KICK COMMAND
@bot.command()
@commands.has_permissions(administrator=True)
async def kick(ctx, user : discord.Member,*,reason):
kickbed = discord.Embed(title="Kick Log",description=f"Kicked by {ctx.author}.", color=23457535)
kickbed.add_field(name="User Kicked:", value=f'{user}',inline=False)
kickbed.add_field(name="Reason:", value=f'{Reason}',inline=False)
await user.kick(reason=reason)
await ctx.send(embed=kickbed)
Upvotes: 0
Views: 403
Reputation: 2653
First, you used variable reason
, but then in:
kickbed.add_field(name="Reason:", value=f'{Reason}',inline=False)
You used the variable Reason
(uppercase first letter), which is not defined. You just have to change it to reason
.
Then you used 23457535
as a color, which is incorrect because the value you pass to the color=
should be less than or equal to 16777215
.
As stated by @NikkieDev:
It could be because you're trying to mention a user that is not in the server.
When I tested it works (mentioning while a user is not on the server), but if you want you could send the message first and then kick the user:
await ctx.send(embed=kickbed) # changed the order of last 2 lines
await user.kick(reason=reason)
Upvotes: 2
Reputation: 209
It could be because you're trying to mention a user that is not in the server. Therefore it cannot mention the user.
Try this instead:
from discord.ext import commands
import discord
@commands.has_permissions(administrator=True)
async def kick(self, ctx, member: discord.Member, reason="No reason given"):
kickDM=discord.Embed(title='Kicked', description=(f"You've been kicked from {member.guild.name} for {reason} by {ctx.author}"))
kickMSG=discord.Embed(title='Kicked', description=(f"{member} has been kicked from {member.guild.name} for {reason} by {ctx.author}"))
await member.send(embed=kickDM)
await ctx.send(embed=kickMSG)
await member.kick(reason=reason)
bot.add_command(kick)
Upvotes: 0