Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commands.complete = {
- modOnly: true,
- adminOnly: false,
- fn: function (bot, msg, suffix, uv, cBack) {
- msg.channel.sendTyping()
- let parts = suffix.split(' ')[0].match(UVRegex)
- let part = suffix.split(' ')
- part.shift()
- let content = part.join(' ')
- if (content.length === 0) {
- msg.reply('you need to provide a reason.').then(errmsg => {
- setTimeout(() => errmsg.delete(), config.timeouts.errorMessageDelete)
- })
- return
- }
- if (content.startsWith('|')) content = content.slice(1).trim()
- let id
- if (parts === null) {
- id = suffix.split(' ')[0]
- } else {
- id = parts[2]
- }
- uv.v1.loginAsOwner().then(c => {
- c.get(`forums/${config.uservoice.forumId}/suggestions/${id}.json`).then((data) => {
- msg.reply(`you're about to mark ${id} for **completion** because \`${content}\`\n__Are you sure this is correct?__ (yes/no)`).then(confirmq => {
- wait(bot, msg).then((q) => {
- if (q === null) {
- msg.reply('you took too long to answer, the operation has been cancelled.').then(successmsg => {
- setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
- })
- }
- if (q === false) {
- msg.reply('thanks for reconsidering, the operation has been cancelled.').then(successmsg => {
- setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
- })
- }
- if (q === true) {
- cBack({
- affected: id
- })
- msg.reply('your report has been sent to the admins, thanks!').then(successmsg => {
- setTimeout(() => bot.Messages.deleteMessages([msg, successmsg, confirmq]), config.timeouts.messageDelete)
- })
- 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, {
- color: 0x3498db,
- author: {
- name: data.suggestion.creator.name,
- icon_url: data.suggestion.creator.avatar_url,
- url: data.suggestion.creator.url
- },
- title: data.suggestion.title,
- description: (data.suggestion.text.length < 1900) ? data.suggestion.text : '*Content too long*',
- url: data.suggestion.url,
- footer: {
- text: (data.suggestion.category !== null) ? data.suggestion.category.name : 'No category'
- }
- }).then(b => {
- r.db('DFB').table('queue').insert({
- id: b.id,
- type: 'adminComplete',
- author: msg.author,
- UvId: id,
- embed: b.embeds[0]
- }).run().then(() => {
- b.addReaction({
- name: 'approve',
- id: '327732629459828748' //This is the testing one change it when push to live
- })
- b.addReaction({
- name: 'deny',
- id: '327732629678063617' // Testing push when goes live
- })
- }).catch(bugsnag.notify)
- })
- }
- })
- })
- }).catch((e) => {
- if (e.statusCode === 404) {
- msg.reply('unable to find a suggestion using your query.').then(errmsg => {
- setTimeout(() => bot.Messages.deleteMessages([msg, errmsg]), config.timeouts.messageDelete)
- })
- } else {
- logger.log(bot, {
- cause: 'delete_search',
- message: (e.message !== undefined) ? e.message : JSON.stringify(e)
- }, e)
- msg.reply('an error occured, please try again later.').then(errmsg => {
- setTimeout(() => bot.Messages.deleteMessages([msg, errmsg]), config.timeouts.errorMessageDelete)
- })
- }
- })
- })
- }
- }
- ERROR:
- Unhandled promise: Promise { <rejected> TypeError: Cannot read property 'loginAsOwner' of undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement