[英]How do i make it so it reads what the user says and uses it to make a role? discord.py
Okay so i want to make it so it questions you what role you want to name it, then you enter that and it says Type "?verify to gain Access to the Server:" ive currently got this but it does not work :/ need help好的,所以我想这样做,所以它会询问您要命名的角色,然后输入它并显示类型“?验证以获取对服务器的访问权限:”我目前得到了这个,但它不起作用:/需要帮助
@bot.command()
async def verification(ctx, *args):
guild = ctx.guild
msg = ' '.join(args)
def check(message):
return message.author == ctx.author and message.channel == ctx.channel and message.content.lower() == msg
await ctx.send("What do you want to Name the Role?")
await bot.wait_for('message', check=check, timeout=60)
await guild.create_role(name=msg, hoist=True, reason="Verification Role Creation", colour=discord.Colour(0x979c9f))
await ctx.send("**Type ?verify to gain Access to the Server!**")
Your command's logic is incorrect:您的命令逻辑不正确:
?verification test string
→ (test, string)
)它需要您传入 args 的内容( ?verification test string
→ (test, string)
)I suggest do this in one of next ways:我建议通过以下方式之一执行此操作:
Use command args ( ?verification Role Name
→ role Role Name
created )使用命令 args ( ?verification Role Name
→ role Role Name
created )
@bot.command() async def verification(ctx, *, rolename: str): """Create verification role""" # first kwarg is "consume-rest" argument for commands: https://discordpy.readthedocs.io/en/v1.3.4/ext/commands/commands.html#keyword-only-arguments await ctx.guild.create_role(name=rolename, hoist=True, reason="Verification Role Creation", colour=discord.Colour(0x979c9f)) await ctx.send("**Type?verify to gain Access to the Server!**")
Use actual message response ( ?verification
→ Bot asks: What do you want to Name the Role?
→ User responses with (in example) Role Name
→ Role Role Name
created `使用实际的消息响应( ?verification
→ Bot 问: What do you want to Name the Role?
→用户响应(例如) Role Name
→角色Role Name
创建`
@bot.command() async def verification(ctx): """Create verification role""" def check(message): return message.author == ctx.author and message.channel == ctx.channel await ctx.send("What do you want to Name the Role?") rolename = await bot.wait_for('message', check=check, timeout=60) await guild.create_role(name=rolename, hoist=True, reason="Verification Role Creation", colour=discord.Colour(0x979c9f)) await ctx.send("**Type?verify to gain Access to the Server!**")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.