'shouting'时如何删除命令的一部分?
How to remove part of a command when 'shouting'?
if (message.content.toLowerCase().startsWith(prefix + `shout`)) {
if (!message.member.roles.some(r => ["shout perms"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
if (!args) {
return;
message.reply('Please specify a message to shout.')
}
const shoutMSG = args.join(" ");
roblox.shout(groupId, shoutMSG)
.then(function() {
console.log(`Shouted ${shoutMSG}`);
})
message.channel.sendMessage(`Shouted ${shoutMSG}`)
.catch(function(error) {
console.log(`Shout error: ${error}`)
});
}
上面是代码,当使用命令时,会向 Roblox 发送喊叫,但是,它也会喊出前缀和命令,如下所示。我该如何解决这个问题,让它只喊出消息而不是前缀和命令?
你只需要截掉前7个字符。 1 为前缀。 5 个用于喊叫,还有 1 个用于 space
var shoutMSG = '!shout Please mark this as correct'
console.log(shoutMSG)
shoutMSG = shoutMSG.substr(7)
console.log(shoutMSG)
if (message.content.toLowerCase().startsWith(prefix + `shout`)) {
if (!message.member.roles.some(r => ["shout perms"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
if (!args) {
return;
message.reply('Please specify a message to shout.')
}
const shoutMSG = args.join(" ");
roblox.shout(groupId, shoutMSG)
.then(function() {
console.log(`Shouted ${shoutMSG}`);
})
message.channel.sendMessage(`Shouted ${shoutMSG}`)
.catch(function(error) {
console.log(`Shout error: ${error}`)
});
}
上面是代码,当使用命令时,会向 Roblox 发送喊叫,但是,它也会喊出前缀和命令,如下所示。我该如何解决这个问题,让它只喊出消息而不是前缀和命令?
你只需要截掉前7个字符。 1 为前缀。 5 个用于喊叫,还有 1 个用于 space
var shoutMSG = '!shout Please mark this as correct'
console.log(shoutMSG)
shoutMSG = shoutMSG.substr(7)
console.log(shoutMSG)