我想在Discord上为我的服务器实现一个简单的数据库,所以我需要我的机器人来管理我,当变量更改其值时,他用新值编辑DM(使用他发送给我的消息的ID)对于变量。 (对不起,我的英语)
这就是我目前的状态:
async function replyAndLog() {
let sent = await msg.author.send("<database things>");
let id = sent.id;
console.log(id) //the id of the DM
}
//when i need to edit
if (msg.content === '!edit') {
msg.id("id").edit("<new databese>") // here's the problem, i dont know how to write this line
}
答案 0 :(得分:1)
const User = client.users.cache.get("Your UserId");
if (!User.dmChannel) return console.log("No messages found.");
// Getting the message by ID
User.dmChannel.messages.fetch("MessageID").then(dmMessage => {
// Editing the message.
dmMessage.edit("I have an update!");
})
答案 1 :(得分:-1)
给定的答案出现以下错误:
readline.js:1147
throw err;
^
TypeError: Cannot read property 'dmChannel' of undefined
at C:\Users\Shankar\Desktop\bot\Disgd-hax\index.js:29:35
at Interface._onLine (readline.js:327:5)
at Interface._line (readline.js:658:8)
at Interface._ttyWrite (readline.js:1003:14)
at ReadStream.onkeypress (readline.js:205:10)
at ReadStream.emit (events.js:315:20)
at emitKeys (internal/readline/utils.js:335:14)
at emitKeys.next (<anonymous>)
at ReadStream.onData (readline.js:1137:36)
at ReadStream.emit (events.js:315:20)