21 lines
555 B
JavaScript
21 lines
555 B
JavaScript
/**
|
|
* Serialized channel renames/moves to avoid Discord rate limits (e.g. 2 renames / 10 min per channel).
|
|
*/
|
|
const PQueue = require('p-queue').default;
|
|
|
|
const channelQueue = new PQueue({
|
|
concurrency: 1,
|
|
intervalCap: 2,
|
|
interval: 10000
|
|
});
|
|
|
|
function enqueueRename(channel, newName) {
|
|
return channelQueue.add(() => channel.setName(newName));
|
|
}
|
|
|
|
function enqueueMove(channel, categoryId) {
|
|
return channelQueue.add(() => channel.setParent(categoryId, { lockPermissions: true }));
|
|
}
|
|
|
|
module.exports = { channelQueue, enqueueRename, enqueueMove };
|