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.
This is what it does: It's usless as you can see, but instead of the response it should output an error.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.