In my discord bot, there is a /help command that DMs the user a list of commands. My problem is, that some users have their DMs locked. I want it so that IF the user has DMs blocked, the bot will just send the messages in the channel. I've tried using a try catch block but nothing happens. Here's the code:

// defined embeds and stuff before this lime I am also  using a command handler 
/*try {;//.then; message.edit(gotcmds);{embed: modAdmin});{embed: botcmds});{embed: extras});{embed: neededperms});; 

    catch(e) {


    }   */ = {
  name: "help"

To summarise:

=> A /help command works => If the user has blocked their DMs, they will not receive the messages the bot will send. => If there is an error, how would I do it so the bot just sends the messages in the channel the command was executed in?

Also, if I spelt anything wrong please tell me.... #PrepearingForGCSEs

1 Answers

Community On Best Solutions

This code should work as you described. I also incorporate an array of the embeds and use a loop for efficiency.

let embeds = [modAdmin, botcmds, extras, neededperms];

try {
  for (let embed of embeds);'Check your DMs!');
} catch(e) {
  for (let embed of embeds) {
    .catch(e => {
      return console.error();