Discord strip_after_prefix 不工作
Discord strip_after_prefix is not working
我想要一个代码,用户可以在其中输入 !play TicTacToe,机器人将启动 tictactoe。目前我的机器人没有响应,我认为这是因为它在播放后有一个 space,并且在 TicTacToe 中大写。我究竟做错了什么? (p.s。它还说
strip_after_prefix:True,
^
ReferenceError: True 未定义
#an example of one of my commands that needs strip_after_prefix
module.exports = {
name: 'clear',
description: "Clears x amount of messages",
strip_after_prefix=True,
async execute(message, args){
if(!args[0]) return message.reply('please enter the amount of messages you want to clear');
if(isNaN(args[0])) return message.reply('please enter a real number')
if(args[0] > 100) return message.reply('the max amount your can clear is 20')
if(args[0] < 1) return message.reply('the minimum deletion number is 1')
await message.channel.messages.fetch({limit: args[0]}).then(messages =>{
message.channel.bulkDelete(messages);
});
}
}
各位游子大家好!我找到了我自己问题的答案,并且我了解到 strip_after_prefix 已被删除!
相反,如果您尝试执行 !play tictactoe player1 player2(例如),您可以将命令用作列表:
const args = message.content.slice(prefix.length).trim().split(/ +/g); #args is the variable I use
let command = args.toString().toLowerCase().replace(/,/g, ' '); #this makes it so !play TiCtAcToe and normal !play ticatactoe both work
这个列表应该像 [tictactoe, player1, player2]
接下来要访问此列表,请执行 args[(number)] 并将其用于函数。
(如果有人能编辑这篇文章,我将非常感激,因为我的英语很烂。祝你有美好的一天。)
我想要一个代码,用户可以在其中输入 !play TicTacToe,机器人将启动 tictactoe。目前我的机器人没有响应,我认为这是因为它在播放后有一个 space,并且在 TicTacToe 中大写。我究竟做错了什么? (p.s。它还说 strip_after_prefix:True, ^
ReferenceError: True 未定义
#an example of one of my commands that needs strip_after_prefix
module.exports = {
name: 'clear',
description: "Clears x amount of messages",
strip_after_prefix=True,
async execute(message, args){
if(!args[0]) return message.reply('please enter the amount of messages you want to clear');
if(isNaN(args[0])) return message.reply('please enter a real number')
if(args[0] > 100) return message.reply('the max amount your can clear is 20')
if(args[0] < 1) return message.reply('the minimum deletion number is 1')
await message.channel.messages.fetch({limit: args[0]}).then(messages =>{
message.channel.bulkDelete(messages);
});
}
}
各位游子大家好!我找到了我自己问题的答案,并且我了解到 strip_after_prefix 已被删除!
相反,如果您尝试执行 !play tictactoe player1 player2(例如),您可以将命令用作列表:
const args = message.content.slice(prefix.length).trim().split(/ +/g); #args is the variable I use
let command = args.toString().toLowerCase().replace(/,/g, ' '); #this makes it so !play TiCtAcToe and normal !play ticatactoe both work
这个列表应该像 [tictactoe, player1, player2] 接下来要访问此列表,请执行 args[(number)] 并将其用于函数。
(如果有人能编辑这篇文章,我将非常感激,因为我的英语很烂。祝你有美好的一天。)