UNPKG

nova-golds-transfer

Version:

A library to monitor gold transfer in Nova Golds bot on Discord.

35 lines (31 loc) 1.05 kB
/** * @param {object} options * @param {string} options.botId * @param {string} options.userId * @param {number} options.amount * @param {number} options.timeout * @param {Channel} options.channel * @returns {Promise<boolean>} */ async function TransferGolds({ botId, userId, amount, timeout, channel }) { return new Promise((resolve) => { const collector = channel.createMessageCollector({ filter: (message) => message.author.id === botId && message.content.includes(`has transferred`) && message.content.includes(`<@${userId}>`) && message.content.includes(`$${amount}`), time: timeout, }); collector.on('collect', () => { resolve(true); collector.stop(); }); collector.on('end', (collected, reason) => { if (reason === 'time') { resolve(false); } }); }); } module.exports = TransferGolds;