我尝试做一个踢的命令,所有的工作,除了当命令是运行,指定的用户将不会被踢。
@bot.tree.command(name='kick', description='Kicks a user from the server [S]')
async def embed(interaction : discord.Interaction, user : discord.Member, reason : str = None):
permissions = interaction.user.guild_permissions
is_admin = permissions.kick_members
kick = user.guild.kick
if is_admin == True:
embed = discord.Embed(title='Kick Command', color=discord.Color.blurple(), description='Kicks a user.')
embed.set_author( name = f'{interaction.user}', icon_url= f'{interaction.user.display_avatar}')
await kick
embed.add_field(name = 'Username', value=str(user.mention), inline=True)
embed.add_field(name = 'Reason', value=str(reason), inline=True)
embed.add_field(name = 'Moderation', value='User kicked successfully.', inline=True)
embed.set_footer(text="Command called by: {}".format(interaction.user))
embed.set_image(url='image')
await interaction.response.send_message(embed = embed)我尝试了上面的代码,但是它没有工作,所有的代码都像预期的那样工作。
发布于 2022-10-29 19:20:34
我想出了解决办法。谢谢你的帮助!
发布于 2022-10-26 06:07:05
试着用这个,然后按你的方式去做:
命令应该是!踢@踢的用户理由
import discord
from discord.ext.commands import Bot
from discord.ext import commands
bot= commands.Bot(command_prefix='!', intents=discord.Intents.all())
#adjust intents appropriately for your bot
@commands.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
await bot.kick(member)
await ctx.channel.send(f'User {member} has been kicked')https://stackoverflow.com/questions/74199615
复制相似问题