[英]Add perms for a !purge command
你好我試圖創建一個基於權限的清除命令這是沒有任何權限代碼的:
module.exports = {
name: 'purge',
description: "Deletes Messages",
async execute(message, args){
if(!args[0]) return message.reply("Please enter the amount of messages you wish to delete.");
if(isNaN(args[0])) return message.reply("The specified charecters are not numbers, please enter a real number.");
if(args[0] > 100) return message.reply("You have entered a number over 100, please enter a number under that value.");
if(args[0] < 1) return message.reply("You have entered a number under 0, you must enter a number above 0");
await message.channel.messages.fetch({limit: args[1]}).then(messages =>{
message.channel.bulkDelete(messages)
});
}
}
有人可以告訴我如何為此添加基於權限的處理程序嗎 謝謝
if (message.member.hasPermission("MANAGE_MESSAGES")) {
// the guild member has permission
}
您可以將此添加到您的代碼中: if(.message.member.hasPermission("MANAGE_MESSAGES")) { message.channel.send("message to send if member haven't got the permission") }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.