【发布时间】:2021-06-16 17:06:17
【问题描述】:
我需要使用某些变量只有在触发时才具有值,但我需要在if 语句之外使用这些变量。有谁知道怎么做?
代码:
let commandRan = false
let User = msg.author.id
if (msg.content.toLowerCase().startsWith("pe!command")){
msg.channel.send('Hello! say 1 or 2');
commandRan = true
User = msg.author.id
};
if (msg.content.toLowerCase().startsWith("1")){
if (commandRan === true) {
if (User === msg.author.id){
msg.channel.send("1!")
}
}
} else if (msg.content.toLowerCase().startsWith("2")){
msg.channel.send("2!")
}
【问题讨论】:
标签: javascript scope discord.js