2021-09-03 09:34:16 +02:00
|
|
|
const Command = require('../Command');
|
|
|
|
|
|
|
|
class ModmailID extends Command {
|
|
|
|
|
2021-10-22 09:35:04 +02:00
|
|
|
constructor (client) {
|
2021-09-03 09:34:16 +02:00
|
|
|
super(client, {
|
|
|
|
name: 'id',
|
2021-10-22 09:35:04 +02:00
|
|
|
aliases: [ 'mmid' ]
|
2021-09-03 09:34:16 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-22 09:35:04 +02:00
|
|
|
async execute (message, { args }) {
|
2021-09-03 09:34:16 +02:00
|
|
|
|
|
|
|
let channel = null;
|
|
|
|
if (args?.length) {
|
2021-10-22 09:35:04 +02:00
|
|
|
const [ ch ] = args;
|
2021-09-03 09:34:16 +02:00
|
|
|
channel = await this.client.resolveChannel(ch);
|
|
|
|
} else {
|
|
|
|
({ channel } = message);
|
|
|
|
}
|
|
|
|
|
|
|
|
const chCache = this.client.cache.channels;
|
2021-10-22 09:35:04 +02:00
|
|
|
const result = Object.entries(chCache).find(([ , val ]) => {
|
2021-09-03 09:34:16 +02:00
|
|
|
return val === channel.id;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!result) return {
|
|
|
|
error: true,
|
|
|
|
msg: `This doesn't seem to be a valid modmail channel. Cache might be out of sync. **[MISSING TARGET]**`
|
|
|
|
};
|
|
|
|
|
2021-10-22 09:35:04 +02:00
|
|
|
const [ userId ] = result;
|
2021-09-03 09:34:16 +02:00
|
|
|
return userId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ModmailID;
|