Give ID to the dm message so people can reference it in feedback
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
c7e1ba0021
commit
5bbe5ef303
3 changed files with 45 additions and 14 deletions
|
@ -1,6 +1,8 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
|
const { prefix } = require('../../config.json');
|
||||||
|
const feedbackID = require('../../json/feedbackID.json');
|
||||||
|
|
||||||
class EvalCommand extends Command {
|
class dmCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('dm', {
|
super('dm', {
|
||||||
aliases: ['dm', 'pm'],
|
aliases: ['dm', 'pm'],
|
||||||
|
@ -26,12 +28,28 @@ class EvalCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
|
function uuidv4() {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const uuid = uuidv4();
|
||||||
|
feedbackID[uuid] = args.text;
|
||||||
|
|
||||||
let user = args.user;
|
let user = args.user;
|
||||||
let text = args.text;
|
let text = args.text;
|
||||||
|
|
||||||
|
const Embed = this.client.util.embed()
|
||||||
|
.setTitle('You received a message from the developer!')
|
||||||
|
.setDescription(text)
|
||||||
|
.setFooter(`If you wish to respond use the following command: ${prefix[0]}feedback --reply ${uuid} <message>`)
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
let Attachment = (message.attachments).array();
|
let Attachment = (message.attachments).array();
|
||||||
if (Attachment[0]) {
|
if (Attachment[0]) {
|
||||||
this.client.users.resolve(user.id).send(`**Message from the dev:**\n${text}\n**If you wish to respond use the feedback command**`, {files: [Attachment[0].url]})
|
this.client.users.resolve(user.id).send(Embed, {files: [Attachment[0].url]})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return message.channel.send(`DM sent to ${user.username}`);
|
return message.channel.send(`DM sent to ${user.username}`);
|
||||||
})
|
})
|
||||||
|
@ -40,16 +58,16 @@ class EvalCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.client.users.resolve(user.id).send(`**Message from the dev:**\n${text}\n**If you wish to respond use the feedback command**`)
|
this.client.users.resolve(user.id).send(Embed)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return message.channel.send(`DM sent to ${user.username}`);
|
return message.channel.send(`DM sent to ${user.tag}`);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
return message.channel.send(`Could not send a DM to ${user.username}`);
|
return message.channel.send(`Could not send a DM to ${user.tag}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = EvalCommand;
|
module.exports = dmCommand;
|
|
@ -1,5 +1,6 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const { feedbackChannel } = require('../../config.json');
|
const { feedbackChannel } = require('../../config.json');
|
||||||
|
const feedbackID = require('../../json/feedbackID.json');
|
||||||
|
|
||||||
class FeedbackCommand extends Command {
|
class FeedbackCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -15,7 +16,12 @@ class FeedbackCommand extends Command {
|
||||||
start: 'What do you want to say to the owner?',
|
start: 'What do you want to say to the owner?',
|
||||||
},
|
},
|
||||||
match: 'rest'
|
match: 'rest'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
id: 'reply',
|
||||||
|
match: 'option',
|
||||||
|
flag: '--reply',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Send feedback to the bot owner',
|
content: 'Send feedback to the bot owner',
|
||||||
|
@ -26,19 +32,25 @@ class FeedbackCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message,args) {
|
async exec(message,args) {
|
||||||
// Don't let account new account use this command to prevent spam
|
const Embed = this.client.util.embed()
|
||||||
|
.setAuthor(`${message.author.tag} (${message.author.id})`, message.author.displayAvatarURL())
|
||||||
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (message.guild) Embed.addField('Guild', `${message.guild.name} (${message.guild.id})`, true);
|
||||||
|
|
||||||
|
Embed.addField('Feedback', args.text);
|
||||||
|
|
||||||
|
if (feedbackID[args.reply]) {
|
||||||
|
Embed.addField('Responding to', feedbackID[args.reply]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't let new account use this command to prevent spam, if they have an UUID its fine to skip it
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
if (message.author.createdAt > date.setDate(date.getDate() - 7)) {
|
if (message.author.createdAt > date.setDate(date.getDate() - 7)) {
|
||||||
return message.channel.send('Your account is too new to be able to use this command!');
|
return message.channel.send('Your account is too new to be able to use this command!');
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = this.client.channels.resolve(feedbackChannel);
|
const channel = this.client.channels.resolve(feedbackChannel);
|
||||||
|
|
||||||
const Embed = this.client.util.embed()
|
|
||||||
.setAuthor(`${message.author.username} (${message.author.id})`, message.author.displayAvatarURL());
|
|
||||||
if (message.guild) Embed.addField('Guild', `${message.guild.name} (${message.guild.id})`, true);
|
|
||||||
Embed.addField('Feedback', args.text)
|
|
||||||
.setTimestamp();
|
|
||||||
channel.send({embed: Embed});
|
channel.send({embed: Embed});
|
||||||
|
|
||||||
message.channel.send('Your feedback has been sent!');
|
message.channel.send('Your feedback has been sent!');
|
||||||
|
|
1
json/feedbackID.json
Normal file
1
json/feedbackID.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
Loading…
Reference in a new issue