Advertisement
Guest User

freuds fun

a guest
Jun 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. commands.complete = {
  2.   modOnly: true,
  3.   adminOnly: false,
  4.   fn: function (bot, msg, suffix, uv, cBack) {
  5.     msg.channel.sendTyping()
  6.     let parts = suffix.split(' ')[0].match(UVRegex)
  7.     let part = suffix.split(' ')
  8.     part.shift()
  9.     let content = part.join(' ')
  10.     if (content.length === 0) {
  11.       msg.reply('you need to provide a reason.').then(errmsg => {
  12.         setTimeout(() => errmsg.delete(), config.timeouts.errorMessageDelete)
  13.       })
  14.       return
  15.     }
  16.     if (content.startsWith('|')) content = content.slice(1).trim()
  17.     let id
  18.     if (parts === null) {
  19.       id = suffix.split(' ')[0]
  20.     } else {
  21.       id = parts[2]
  22.     }
  23.     uv.v1.loginAsOwner().then(c => {
  24.       c.get(`forums/${config.uservoice.forumId}/suggestions/${id}.json`).then((data) => {
  25.         msg.reply(`you're about to mark ${id} for **completion** because \`${content}\`\n__Are you sure this is correct?__ (yes/no)`).then(confirmq => {
  26.          wait(bot, msg).then((q) => {
  27.            if (q === null) {
  28.              msg.reply('you took too long to answer, the operation has been cancelled.').then(successmsg => {
  29.                setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
  30.              })
  31.            }
  32.            if (q === false) {
  33.              msg.reply('thanks for reconsidering, the operation has been cancelled.').then(successmsg => {
  34.                setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
  35.              })
  36.            }
  37.            if (q === true) {
  38.              cBack({
  39.                affected: id
  40.              })
  41.              msg.reply('your report has been sent to the admins, thanks!').then(successmsg => {
  42.                setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
  43.              })
  44.              bot.Channels.find(f => f.name === 'admin-queue').sendMessage(`The following card has been marked for ***completion*** by ${msg.author.username}#${msg.author.discriminator} for the following reason:\n${content}\n\nPlease review this report.`, false, {
  45.                color: 0x3498db,
  46.                author: {
  47.                  name: data.suggestion.creator.name,
  48.                  icon_url: data.suggestion.creator.avatar_url,
  49.                  url: data.suggestion.creator.url
  50.                },
  51.                title: data.suggestion.title,
  52.                description: (data.suggestion.text.length < 1900) ? data.suggestion.text : '*Content too long*',
  53.                url: data.suggestion.url,
  54.                footer: {
  55.                  text: (data.suggestion.category !== null) ? data.suggestion.category.name : 'No category'
  56.                }
  57.              }).then(b => {
  58.                r.db('DFB').table('queue').insert({
  59.                  id: b.id,
  60.                  type: 'adminComplete',
  61.                  author: msg.author,
  62.                  UvId: id,
  63.                  embed: b.embeds[0]
  64.                }).run().then(() => {
  65.                  b.addReaction({
  66.                    name: 'approve',
  67.                     id: '327732629459828748'    //This is the testing one change it when push to live
  68.                  })
  69.                  b.addReaction({
  70.                    name: 'deny',
  71.                    id: '327732629678063617' // Testing push when goes live
  72.                  })
  73.                }).catch(bugsnag.notify)
  74.              })
  75.            }
  76.          })
  77.        })
  78.      }).catch((e) => {
  79.        if (e.statusCode === 404) {
  80.          msg.reply('unable to find a suggestion using your query.').then(errmsg => {
  81.            setTimeout(() => bot.Messages.deleteMessages([msg, errmsg]), config.timeouts.messageDelete)
  82.          })
  83.        } else {
  84.          logger.log(bot, {
  85.            cause: 'delete_search',
  86.            message: (e.message !== undefined) ? e.message : JSON.stringify(e)
  87.          }, e)
  88.          msg.reply('an error occured, please try again later.').then(errmsg => {
  89.            setTimeout(() => bot.Messages.deleteMessages([msg, errmsg]), config.timeouts.errorMessageDelete)
  90.          })
  91.        }
  92.      })
  93.    })
  94.  }
  95. }
  96.  
  97. ERROR:
  98. Unhandled promise: Promise { <rejected> TypeError: Cannot read property 'loginAsOwner' of undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement