#my slash command not working
1 messages ยท Page 1 of 1 (latest)
here code
def is_admin():
async def predicate(ctx):
"Administrator" permission
for role in ctx.author.roles:
if role.permissions.administrator:
return True
return False
return commands.check(predicate)
@bot.slash_command(name="ban", description="This command bans a member from the server.", checks=[is_admin()])
async def ban(ctx, member: disnake.Member, *, reason=None):
"""Bans a member from the server."""
# Check if the bot has permission to ban members
if ctx.guild.me.guild_permissions.ban_members:
await member.ban(reason=reason)
current_time = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
embed = disnake.Embed(title="Member Banned", color=0xFF0000)
embed.set_author(name=member.display_name, icon_url=member.avatar.url)
embed.add_field(name="Reason", value=reason if reason else "No reason provided", inline=False)
embed.add_field(name="Banned By", value=ctx.author.display_name, inline=False)
embed.add_field(name="Banned At", value=current_time, inline=False)
await ctx.send(embed=embed)
else:
await ctx.send("I don't have permission to ban members.")
and it says this in the terminal thingy
plaese help
there is slash command named commands
I would use a decorator instead of my own function for permisisons.
also the name in the decorator is for if you need to change the name to something other then the function
@grave meadow
nope, that's fine
and also entirely unrelated to their issue, as the issue is just that they shadowed the commands module with a method (now slash command) named commands
๐๐ป
which they've been told... four times now?