亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

你怎么能讓你的機器人發送第二個參數

你怎么能讓你的機器人發送第二個參數

開心每一天1111 2021-11-18 20:25:21
就像 !L JohnGameRage#0000 已經把 L 給了 user#0000
查看完整描述

1 回答

?
慕工程0101907

TA貢獻1887條經驗 獲得超5個贊

構造參數的一種簡單方法是這樣的:


let full = message.content.substr(1).trim(); //remove the prefix

let split = full.split(/ +/g); //seperate the words in the String and put them into an array

let cmd = split[0]; //the command is the first word in the array

let args = split.slice(1); //the arguments are all words except for the first one

在您的示例L中將是命令并且JohnGameRage#0000將是第一個參數。


您可以像這樣從數組中讀取單個參數:


//Command = !L firstArg secondArg thirdArg fourthArg etc

cmd //returns 'L'

args[0] //returns 'firstArg'

args[1] //returns 'secondArg '

args[2] //returns 'thirdArg '

args[3] //returns 'fourthArg '

args[4] //returns 'etc'


查看完整回答
反對 回復 2021-11-18
  • 1 回答
  • 0 關注
  • 149 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號