client.on('ready', () => {
console.log('Ready!');
})
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, time: 30000 }).then(collected => {
if (collected.first().emoji.name == '🇦') {
message.reply('Shutting down...');
client.destroy();
}
else
message.reply('Operation canceled.');
}).catch(() => {
message.reply('No reaction after 30 seconds, operation canceled');
})
}
}
catch
放在try
中。和“)”也都在这里client.on('ready', () => {
console.log('Ready!');
})
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, time: 30000 }).then(collected => {
if (collected.first().emoji.name == '🇦') {
message.reply('Shutting down...');
client.destroy();
}
else
message.reply('Operation canceled.');
}).catch(() => {
message.reply('No reaction after 30 seconds, operation canceled');
})
} catch (err) {
console.log(err)
}
})