use ID instead of user to avoid accidental DM

Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
loicbersier 2020-05-02 19:21:53 +02:00
parent 5bbe5ef303
commit 76088da799

View file

@ -10,11 +10,14 @@ class dmCommand extends Command {
args: [ args: [
{ {
id: 'user', id: 'user',
type: 'user' type: 'string'
}, },
{ {
id: 'text', id: 'text',
type: 'string', type: 'string',
prompt: {
start: 'What do you want to send to that user?',
},
match: 'rest' match: 'rest'
} }
], ],
@ -38,7 +41,8 @@ class dmCommand extends Command {
const uuid = uuidv4(); const uuid = uuidv4();
feedbackID[uuid] = args.text; feedbackID[uuid] = args.text;
let user = args.user; let user = this.client.users.resolve(args.user);
if (!user) return message.channel.send('Not a valid ID');
let text = args.text; let text = args.text;
const Embed = this.client.util.embed() const Embed = this.client.util.embed()
@ -49,7 +53,7 @@ class dmCommand extends Command {
let Attachment = (message.attachments).array(); let Attachment = (message.attachments).array();
if (Attachment[0]) { if (Attachment[0]) {
this.client.users.resolve(user.id).send(Embed, {files: [Attachment[0].url]}) this.client.users.resolve(user).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}`);
}) })
@ -58,7 +62,7 @@ class dmCommand extends Command {
}); });
} }
else { else {
this.client.users.resolve(user.id).send(Embed) this.client.users.resolve(user).send(Embed)
.then(() => { .then(() => {
return message.channel.send(`DM sent to ${user.tag}`); return message.channel.send(`DM sent to ${user.tag}`);
}) })