id command to fetch the id for a modmail target
This commit is contained in:
parent
75c5a9cc71
commit
db0cf09e55
39
structure/commands/Id.js
Normal file
39
structure/commands/Id.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
const Command = require('../Command');
|
||||||
|
|
||||||
|
class ModmailID extends Command {
|
||||||
|
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'id',
|
||||||
|
aliases: ['mmid']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute(message, { args }) {
|
||||||
|
|
||||||
|
let channel = null;
|
||||||
|
if (args?.length) {
|
||||||
|
const [ch] = args;
|
||||||
|
channel = await this.client.resolveChannel(ch);
|
||||||
|
} else {
|
||||||
|
({ channel } = message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const chCache = this.client.cache.channels;
|
||||||
|
const result = Object.entries(chCache).find(([, val]) => {
|
||||||
|
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]**`
|
||||||
|
};
|
||||||
|
|
||||||
|
const [userId] = result;
|
||||||
|
return userId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ModmailID;
|
Loading…
Reference in New Issue
Block a user