【发布时间】:2020-08-04 16:11:11
【问题描述】:
else if (message.content.startsWith(prefix + 'test2')) //you can change command name here - not recommended but you can :)
{
message.reply('**Just a Test2**');
fs.truncate('../ConsoleClient/Console/output.txt', 0, function(){});
setTimeout(function () {
var out = fs.readFileSync('../ConsoleClient/RaidAlerts/messages.txt', 'utf-8').toString();
var out3 = "test2";
if(out == "stone")
{
out3 = "Walls are fine";
}
else if(out == "air")
{
out3 = "**WEEWOO** We´re being raided **WEEWOO**";
}
else if(out == "other")
{
out3 = "Someone changed the block. Check ASAP";
}
const outembed = new Discord.RichEmbed()
.setColor(0xe580ff)
.setTimestamp()
.setTitle('Walls')
.addField('Status', "```" + out3 + out + "```")
.setURL("https://de.namemc.com/profile/Memag")
message.channel.sendEmbed(outembed)
fs.truncate('../ConsoleClient/Console/output.txt', 0, function(){});
}, 1000);
}
为什么它说“墙是细石其他”或“墙是细石空气”或“墙是细石”而不是“墙是好的”,“WEEWOO我们正在被突袭WEWOO ”和“有人更改了区块。尽快检查”?
【问题讨论】:
-
out的值显然是"other"或"stoneair"或"stonestone"—'Status', "```" + out3 + out + "```"连接out3和out -
不要在该表达式中包含
out?我不知道您要达到什么目的,也不知道为什么要这样编写代码,但这很可能是问题所在。 -
@Pointy 问题是如果
out是其中之一,那么消息应该以“test2”或“有人更改了块。尽快检查”开头,但它以“墙很好”,尽管out显然不是stone。 -
@JosephSible-ReinstateMonica 应该从“test2”开始 — 究竟如何?
out3变量初始化为“test2”,但后来被覆盖。 -
@Pointy 因为“stonestone”和“stoneair”不等于“stone”、“air”或“other”。如果它是“其他”,那么它仍然应该以“有人更改了块。尽快检查”而不是“墙很好”开头。
标签: javascript discord.js minecraft