本文介绍了Discord.js 带空格的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

所以我正在尝试创建我的机器人,我希望有一个命令可以将信息添加到 sqlite 数据库

So I'm trying to create my bot and I want there to be a command which adds information to a sqlite database

https://gyazo.com/6961a05dc2d6aeca6683b59f888c2e82

if (command === "addplayer") {
  message.delete()
  let [name, crew, rank, weapon, df, talent, profession, other] = args;
  if(!name) return message.author.send("Name argument is required!");
  let id = name.toLowerCase();
  if(!crew) {let crew = "Blank";}
  if(!rank) {let rank = "Blank";}
  if(!weapon) {let weapon = "Blank";}
  if(!df) {let df = "Blank";}
  if(!talent) {let talent = "Blank";}
  if(!profession) {let profession = "Blank";}
  if(!other) {let other = "Blank";}

  sql.run("INSERT INTO players (id, Name, Crew, Rank, Weapon, DF,
Talent, Profession, Other) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", [id,
name, crew, rank, weapon, df, talent, profession, other]);
  return
}

我真正想知道的是如何在参数中添加空格键这样我就可以做到

All I want to know really is how to add like a space key to the arguments so I can do

>用空格添加玩家信息,更多信息,甚至更多,等等

当我执行其他命令时,它会这样列出:

And when I do the other command it lists it out like this:

Info1:带空格的信息Info2:更多信息Info3:更多Info4:等等

推荐答案

我刚刚决定使用多个命令,例如

I've just decided to go with multiple commands like

>编辑示例然后做类似的事情

>editname EXAMPLE1将名称设置为EXAMPLE1而不是EXAMPLE

>editname EXAMPLE1 setting the name to EXAMPLE1 instead of EXAMPLE

这篇关于Discord.js 带空格的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 00:26