UNPKG

jalter

Version:

<a href="https://scathach.dev"><img align="right" src="https://cdn.discordapp.com/attachments/711217607876804629/932506038865911848/alter.png" width=28%></a>

47 lines (40 loc) 1.7 kB
const { rest, delay } = require('./api'); /** * Send message with interval, eg: send '!d bump' every 2hour then fill the third parameter to '120' * @param {number} channel_id The destination channel ID * @param {any} desired_message The desired message * @param {number} interval The interval time per minute * @returns {Promise<Message>} */ async function farmerInterval(channel_id, desired_message, interval) { let waktu if (!interval) waktu = 1; const perMenit = 120000 * waktu; setInterval(async () => { await rest.sendMessage(channel_id, desired_message).then(console.log) }, perMenit); } /** * Normal send message * @param {number} channel_id The destination channel ID * @param {any} desired_message The desired message * @returns {Promise<Message>} */ async function normalSend(channel_id, desired_message) { await rest.sendMessage(channel_id, desired_message).then(console.log) } /** * Send message with cooldown, eg: spamming '!gacha, ppp, punopupupuu' every 5 sec then fill the third parameter to '5000' (ms) * @param {number} channel_id The destination channel ID * @param {any} desired_message The desired message * @param {number} count_message The desired message count for its spamming, eg: 10x just fill '10' * @param {number} cooldown The cooldown time per message (ms) * @returns {Promise<Message>} */ async function farmer(channel_id, desired_message, count_message, cooldown) { for (let i = 0; i < count_message; i++) { await rest.sendMessage(channel_id, desired_message).then(console.log) await delay(cooldown); } } module.exports = { farmerInterval, farmer, normalSend };