Discord.js Arguments With Spaces(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 带空格的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Discord.js 带空格的参数
基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
