我只是想知道如何做,所以我可以让discord.js机器人检测错误并将其发送给我。
答案 0 :(得分:0)
请提供您要在其中处理此错误的代码模块。
似乎您要使用javascript的try...catch
代码块语法。它是这样的:
"use strict";
try {
// Your buggy code:
let result = 2 + "2";
} catch (e) {
// Your instructions if an <e> error occurs
console.log(e);
}
我不知道你的意思
[...]“错误并发送给我。”
您希望客户如何将此错误发送给您?下次请尝试更具体。希望console.log
为您做到。
答案 1 :(得分:0)
您可以从某项操作返回的承诺中发现错误,例如
public class IdName
{
public int StudentID { get; set; }
public string Name { get; set; }
}