Answers for "message await discord.js"

7

await message discord.js

message.channel.awaitMessages(m => m.author.id == message.author.id,
                            {max: 1, time: 30000}).then(collected => {
                                    // only accept messages by the user who sent the command
                                    // accept only 1 message, and return the promise after 30000ms = 30s

                                    // first (and, in this case, only) message of the collection
                                    if (collected.first().content.toLowerCase() == 'yes') {
                                            message.reply('Shutting down...');
                                            client.destroy();
                                    }

                                    else
                                            message.reply('Operation canceled.');      
                            }).catch(() => {
                                    message.reply('No answer after 30 seconds, operation canceled.');
                            });
Posted by: Guest on January-19-2021
1

how to await a message in discordjs

// Filter now needs to be in options aswell
 message.channel.awaitMessages({filter: m => m.author.id == message.author.id, max: 1, time: 30000}).then(collected => {
                                    // only accept messages by the user who sent the command
                                    // accept only 1 message, and return the promise after 30000ms = 30s

                                    // first (and, in this case, only) message of the collection
                                    if (collected.first().content.toLowerCase() == 'yes') {
                                            message.reply('Shutting down...');
                                            client.destroy();
                                    }

                                    else
                                            message.reply('Operation canceled.');      
                            }).catch(() => {
                                    message.reply('No answer after 30 seconds, operation canceled.');
                            });
Posted by: Guest on October-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language