我的地下室里有一个运行在旧服务器上的不和谐机器人。由于某些原因,我无法从回复中获得正确的输出。
完整代码:
module.exports = {
name: 'ping',
description: 'Pings Bot, then replies with latency -- for debuging',
execute(message, args) {
message.channel.send('?Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms');
},
};其中:
message.channel.send('? Pong! Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms');原封不动地写出来:
?Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms机器人不会崩溃,所以我不能拉出任何错误消息,我不确定问题出在哪里,而且我对此还比较陌生
提前感谢!如果还有什么对你有帮助的,尽管问吧。
发布于 2021-05-05 19:46:44
要在字符串中使用${},不能使用单引号('),而需要使用斜引号(`)。否则,它只是将其视为字符串的一部分。
execute(message, args) {
message.channel.send(`?Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`);
},https://stackoverflow.com/questions/67400605
复制相似问题