你好优秀的互联网人
我正在编写代码来设置我的机器人在 discord.js 中的状态.我想知道如何获取用户的完整 args 列表并将其放入一个 let 语句中,比如说 (args[0] + ' ' + args[1], etc)
I am writing code to set the status of my bot in discord.js. I am wondering how I can take a user's full args list and put it into one let statement, like saying (args[0] + ' ' + args[1], etc)
这是我当前的代码
谢谢你,希望你有一个美好的一天
Thank you, hope you have a great day
let statgame = (args[0])
client.user.setActivity(statgame);
鉴于 args 是一个数组,JS 提供了一个 join 函数来为你做这件事
Given args is an array, JS provides a join function that does this for you
let joinedArgs = args.join(" ");
第一个参数是分隔每个元素的字符串
The first argument is the string that separates each element
这篇关于命令后获取完整的参数列表(Discord.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
discord.js v12:我如何等待 DM 频道中的消息?discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 频道中的消息?)
如何让我的机器人提及发出该机器人命令的人how to make my bot mention the person who gave that bot command(如何让我的机器人提及发出该机器人命令的人)
如何修复必须使用导入来加载 ES 模块 discord.jsHow to fix Must use import to load ES Module discord.js(如何修复必须使用导入来加载 ES 模块 discord.js)
如何列出来自特定服务器的所有成员?How to list all members from a specific server?(如何列出来自特定服务器的所有成员?)
Discord bot:修复“找不到 FFMPEG"Discord bot: Fix ‘FFMPEG not found’(Discord bot:修复“找不到 FFMPEG)
使用 discord.js 加入 discord 服务器时的欢迎消息Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服务器时的欢迎消息)