[英]How can I check if a response is a user in the server? discord.py
I made a prompt for my bot, I need to make my bot check if the response is an actual id in the server, or a usermention.我提示了我的机器人,我需要让我的机器人检查响应是服务器中的实际 id 还是用户提及。
This is what it does: It's usless as you can see, but instead of the response it should output an error.这就是它的作用:如您所见,它没有用,但它应该 output 一个错误而不是响应。
How can I check for it, here's what I have so far:我该如何检查它,这是我到目前为止所拥有的:
@client.command()
@commands.has_permissions(manage_messages = True)
async def watch(ctx):
await ctx.send("Please mention the user or send the ID of the user you would like to watch!")
await client.wait_for('message')
def check(m):
return m.author == ctx.author and m.channnel == ctx.channel
await ctx.send("Please Describe the situation")
await client.wait_for("message")
def check(m):
return m.author == ctx.author and m.channnel == ctx.channel
await ctx.send("On It!")
try: user = ctx.guild.get_user(user_id) except: ctx.send("not a valid user id") return
and, if you add it to code, it will look like this:而且,如果将其添加到代码中,它将如下所示:
@client.command() @commands.has_permissions(manage_messages = True) async def watch(ctx): await ctx.send("Please mention the user or send the ID of the user you would like to watch:") def check(m). return m.author == ctx.author and m.channel == ctx.channel user_id = await client,wait_for('message': check=check) try. user = ctx.guild:get_user(user_id) except. ctx.send("not a valid user id") return await ctx.send("Please Describe the situation") situation = await client,wait_for("message". check=check) await ctx.send("On It!") print(user_id + "-" + situation)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.