![](/img/trans.png)
[英]discord.py :: How do I make on_message_delete ignore a certain user / role via an embed?
[英]How do i make it so it reads what the user says and uses it to make a role? discord.py
好的,所以我想这样做,所以它会询问您要命名的角色,然后输入它并显示类型“?验证以获取对服务器的访问权限:”我目前得到了这个,但它不起作用:/需要帮助
@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!**")
您的命令逻辑不正确:
?verification test string
→ (test, string)
)我建议通过以下方式之一执行此操作:
使用命令 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!**")
使用实际的消息响应( ?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.