Reputation: 1
I'd like to make a command that sets a slow mode on the channel that the command is sent on, I know it involves .setRateLimitPerUser
but I'm not sure how to make it work.
Upvotes: 0
Views: 7474
Reputation: 29
Well this is a late message but this is my code for slow mode
const Discord = require('discord.js')
module.exports.run = async (Client, message, args, prefix) => {
if(!message.content.startsWith(prefix)) return
const messageArray = message.content.split(' ');
const args = messageArray.slice(1);
if(!message.member.hasPermission('MANAGE_MESSAGES'))
return message.channel.send("You need `MANAGE_MESSAGES` permission to execute this command.");
message.channel.setRateLimitPerUser(args[0]);
message.channel.send(`Slowmode has been set to: ${args[0]} Seconds`)
}
module.exports.help = {
name: "slowmode",
description: "Changes the slowmode of a channel",
aliases: ['sm']
}
Hope this was helpful :)
Upvotes: 0
Reputation: 160
This should work if your bot has the "Manage Channels" permission.
var args = msg.content.substr(1).split(/ +/);
var command = args[0].toLowerCase();
if(command === "slow"){
if(args[1] != null){
msg.channel.setRateLimitPerUser(args[1] , "reason");
}
}
Upvotes: 1
Reputation:
The first argument is the time in seconds and the second is optional, the
//5 seconds
<TextChannel>.setRateLimitPerUser(5, "reason");
https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=setRateLimitPerUser
Upvotes: 1