'use strict';

/**
 * Reply to the given message, mentioning its author.
 * @param  {Object} message Chat message
 * @param  {string} content Reply content
 * @return {string[]} List of actions taken, if any, for debugging.
 */
async function reply(message, content) {
  const actions = [];
  await message.reply(content);
  actions.push('replied');
  return actions;
}

/**
 * Respond to the given message in the same channel it was sent from.
 * @param  {Object} message Chat message
 * @param  {string} content Reply content
 * @return {string[]} List of actions taken, if any, for debugging.
 */
async function respond(message, content) {
  const actions = [];
  await message.channel.send(content);
  actions.push('responded');
  return actions;
}

/**
 * Respond to the given message in a direct channel.
 * @param  {Object} message Chat message
 * @param  {string} content Reply content
 * @return {string[]} List of actions taken, if any, for debugging.
 */
async function respondDirect(message, content) {
  const actions = [];
  switch (message.channel.type) {
    case 'dm':
    case 'group': {
      await message.channel.send(content);
      actions.push('responded directly');
      break;
    }
    default: {
      const channel = await message.author.createDM();
      await channel.send(content);
      actions.push('responded directly');
      await channel.delete();
      if (message.deletable) {
        await message.delete();
        actions.push('deleted message');
      }
      break;
    }
  }
  return actions;
}

module.exports = {
  reply,
  respond,
  respondDirect,
};

@@ -1110,83 +1110,54 @@
    a
-wait message.channel.send(content);%0A      actions.push('responded directly'
+ctions.push(...await respond(message, content)
 );%0A 
@@ -1198,24 +1198,8 @@
     
- const channel =
  awa
@@ -1220,40 +1220,8 @@
 hor.
-createDM();%0A      await channel.
 send
@@ -1277,38 +1277,8 @@
 ');%0A
-      await channel.delete();%0A
     

Refactor respondDirect