简体   繁体   中英

(Discord.js) I wanna send a message on channel before the bot goes offline

I've trying this:

if(message.content == config.goesOff){
client.channels.fetch(channelId.toString()).then(channel => {
    channel.send("The bot is shutting down").then(()=>{server.close()});
});

server.close();

return

}

But when I use the command.fbOff (config,goesOff) it don't send the message "The bot is shutting down", it just run the

    Sever.close()

try


const channel = await client.channels.fetch(channelId.toString())
await channel.send("The bot is shutting down")
server.close();


Make sure your message event is async:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM