Discord.js 带空格的参数

Discord.js Arguments With Spaces(Discord.js 带空格的参数)
本文介绍了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 带空格的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DiscordJS fetching more then 100 messages(DiscordJS 获取超过 100 条消息)
my discord.js bot doesn#39;t reply to a user message even if there isn#39;t any error(即使没有任何错误,我的 discord.js 机器人也不会回复用户消息)
Make a bot wait for some time before continuing the code(在继续代码之前让机器人等待一段时间)
Invalid Form Body in Discord.js ban command(Discord.js 禁止命令中的无效表单正文)
Set Discord Bot Activity to the number of Online users. Discord.js(将 Discord Bot 活动设置为在线用户数.不和谐.js)
Got quot;Unexpected end of inputquot; in Javascript when making a Discord Bot(得到“输入意外结束;在 Javascript 中制作 Discord Bot)