validate IP address format and handle errors in mcs command
This commit is contained in:
		
							parent
							
								
									b8e11d5c5c
								
							
						
					
					
						commit
						a55f7f660e
					
				| @ -36,6 +36,12 @@ const options = { | |||||||
| export default class McsCommand extends Command { | export default class McsCommand extends Command { | ||||||
|   |   | ||||||
|   async run(ctx: CommandContext<typeof options>) { |   async run(ctx: CommandContext<typeof options>) { | ||||||
|  |     if (ctx.options.ip && !/^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(:\d+)?$/.test(ctx.options.ip)) { | ||||||
|  |       await ctx.write({ | ||||||
|  |         content: 'Invalid IP address' | ||||||
|  |       }) | ||||||
|  |       return | ||||||
|  |     } | ||||||
|     const res = await prisma.mcsBind.findFirst({ |     const res = await prisma.mcsBind.findFirst({ | ||||||
|       where: { |       where: { | ||||||
|         channelId: ctx.channelId |         channelId: ctx.channelId | ||||||
| @ -65,7 +71,10 @@ export default class McsCommand extends Command { | |||||||
|       }) |       }) | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       console.error(e) |       console.error(e) | ||||||
|       return `ERROR, ${e}` |       await ctx.write({ | ||||||
|  |         content: `${e}` | ||||||
|  |       })  | ||||||
|  |       return | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const page = await browser.newPage(); |     const page = await browser.newPage(); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user