消息未定义,我不支持它
message is not defined, i dont get behind it
所以我无法理解如何定义消息,我已经搜索了很多并尝试了一些方法,但它不起作用。我是初学者,所以我可能只是忘记了在哪里或如何做。
client.on("guildMemberAdd", async member => {
try {
await member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("")
message.react("")
});
message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
}
else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
} catch (err) {
console.log(err)
}
})
client.login(token);
message
仅在第一个 .then
函数的回调中定义。在那之后您再次调用了 message
,它不再被定义。将所有对 message 的调用转移到 .then
内以解决此问题。
.then(function (message) {
message.react("")
message.react("")
message.awaitReactions((reaction, user) => user.id == message.author.id &&
(reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
} else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
});
我不确定,但为什么你不在消息范围内移动消息?
client.on("guildMemberAdd", async member => {
try {
await member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("")
message.react("")
message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
}
else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
});
} catch (err) {
console.log(err)
}
})
client.login(token);
所以我无法理解如何定义消息,我已经搜索了很多并尝试了一些方法,但它不起作用。我是初学者,所以我可能只是忘记了在哪里或如何做。
client.on("guildMemberAdd", async member => {
try {
await member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("")
message.react("")
});
message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
}
else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
} catch (err) {
console.log(err)
}
})
client.login(token);
message
仅在第一个 .then
函数的回调中定义。在那之后您再次调用了 message
,它不再被定义。将所有对 message 的调用转移到 .then
内以解决此问题。
.then(function (message) {
message.react("")
message.react("")
message.awaitReactions((reaction, user) => user.id == message.author.id &&
(reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
} else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
});
我不确定,但为什么你不在消息范围内移动消息?
client.on("guildMemberAdd", async member => {
try {
await member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("")
message.react("")
message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '' || reaction.emoji.name == ''),
{ max: 1}).then(collected => {
if (collected.first().emoji.name == '') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
client.destroy();
}
else
message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
})
});
} catch (err) {
console.log(err)
}
})
client.login(token);