[英]How do i make so it only sends a part of the message? discord.js
I got a problem here where i cant find out how i make so it will remove the !suggest in the message thats gonna be sent im trying to make it so when someone uses !suggest {suggestion} in the specific channel a message will be sent in the #suggestions channel ive got the specific channel up i just want to remove so instead of the bot saying "@user#1234 have suggested !suggest add a goodbye command" it will only say "@user#1234 have suggested: add a goodbye command" basically just removing !suggest heres the code its JavaScript我在这里遇到了一个问题,我无法找到我是如何制作的,因此它将删除将要发送的消息中的 !suggest 我正在尝试制作它,因此当有人在特定频道中使用 !suggest {suggest} 时,将发送一条消息在#suggestions 频道中,我打开了特定频道,我只想删除它,而不是机器人说“@user#1234 建议添加再见命令”,它只会说“@user#1234 建议:添加一个再见命令”基本上只是删除!建议这里是它的 JavaScript 代码
//Suggestions
client.on("message", message => {
if (message.content.startsWith("!suggest")){
return client.channels.get('514917785248202773').send(message.author.tag+"
suggested " + message.content)
}
});
how would i make it so it removes the !suggest part only?我将如何使它只删除 !suggest 部分? cant find anything on here or internet at all
在这里或互联网上根本找不到任何东西
A possibility is to split the message on every space (' '), removing the first element (which is always the command), and recombining the string array.一种可能性是在每个空格 (' ') 上拆分消息,删除第一个元素(始终是命令),然后重新组合字符串数组。
Example:例子:
let message = "!suggest add a goodbye command" const args = message.trim().split(' '); args.shift(); console.log(args.join(' '));
client.on('message', msg => {
if(msg.content.startsWith('!suggest')) {
let message = msg.content.split(" ");
const suggestion = message[1];
client.channels.get('514917785248202773').send(message.author.tag+"
suggested " + suggestion)
}
}
this makes 'message' an array这使“消息”成为一个数组
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.