메시지가 표시되면 지정된 사용자를 추방하는 명령을 만들고 싶습니다. 내가 가진 것은 다음과 같습니다.
@bot.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
await user.kick(reason=reason)
kick = discord.Embed(title=f"Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
await ctx.message.delete()
await ctx.channel.send(embed=kick)
await user.send(embed=kick)
작동하지 않는 것 같습니다. 팁이 있습니까?
여기에 두 가지가 있습니다. on_message
이벤트가을 (를) 사용하여 작동하고 있으므로 아래에 표시된대로을 ( 를) 로 client.event
대체해야 합니다.bot.command
client.command
@client.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
await user.kick(reason=reason)
kick = discord.Embed(title=f"Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
await ctx.message.delete()
await ctx.channel.send(embed=kick)
await user.send(embed=kick)
kick 명령이 여전히 작동하지 않으면 on_message
이벤트가 끝날 때 await client.process_commands(message)
. 아래에 이에 대한 예를 넣겠습니다.
@client.event
async def on_message(message):
if message.content == "Test":
print("recieved")
await client.process_commands(message)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다