diff --git a/structure/commands/Id.js b/structure/commands/Id.js new file mode 100644 index 0000000..5f29efd --- /dev/null +++ b/structure/commands/Id.js @@ -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; \ No newline at end of file