[英]How can I make my Discord bot ignore the set prefix for certain commands only? (Discord.js)
[英]How can I make my bot set a slowmode on a Discord channel, Discord.js
我想制作一個命令,在發送命令的通道上設置慢速模式,我知道它涉及.setRateLimitPerUser
但我不確定如何使其工作。
第一個參數是以秒為單位的時間,第二個是可選的,
//5 seconds
<TextChannel>.setRateLimitPerUser(5, "reason");
https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=setRateLimitPerUser
如果您的機器人具有“管理頻道”權限,這應該有效。
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");
}
}
好吧,這是一條遲到的消息,但這是我的慢速模式代碼
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']
}
希望這有幫助:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.