首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用踢命令时不会踢人

使用踢命令时不会踢人
EN

Stack Overflow用户
提问于 2022-10-25 20:04:18
回答 2查看 36关注 0票数 1

我尝试做一个踢的命令,所有的工作,除了当命令是运行,指定的用户将不会被踢。

代码语言:javascript
复制
@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)

我尝试了上面的代码,但是它没有工作,所有的代码都像预期的那样工作。

EN

回答 2

Stack Overflow用户

发布于 2022-10-29 19:20:34

我想出了解决办法。谢谢你的帮助!

票数 1
EN

Stack Overflow用户

发布于 2022-10-26 06:07:05

试着用这个,然后按你的方式去做:

命令应该是!踢@踢的用户理由

代码语言:javascript
复制
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')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74199615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档