Clearchat check for the Manage Messages permission isntead of full on administration

master
masterhc 1 year ago
parent e794d7870f
commit 736f384457

@ -1,5 +1,5 @@
const {Command, ErrorMessage, ErrorType, Client, Message} = require('../../lib.js') const {Command, ErrorMessage, ErrorType, Client, Message, PermissionFlagsBits, PermissionsBitField} = require('../../lib.js')
@ -7,7 +7,6 @@ class clearchat extends Command{
constructor(client){ constructor(client){
super(client, { super(client, {
name: 'clearchat', name: 'clearchat',
needsAdmin: true,
aliases:['clear'], aliases:['clear'],
description: 'Clears the channel where it was used, you can pass a message id to clear around it.' description: 'Clears the channel where it was used, you can pass a message id to clear around it.'
}) })
@ -15,10 +14,11 @@ class clearchat extends Command{
} }
async run(message, args) async run(message, args)
{ {
//verificar admin
const Author = message.author.username; const Author = message.author.username;
const channel = message.channel.name; const channel = message.channel.name;
console.log('ClearChat:',' - ', Author, 'on:', channel, args?args:'No limit' ) console.log('ClearChat:',' - ', Author, 'on:', channel, args?args:'No limit' )
var hasPermission = this.client.guilds.cache.get(message.guild.id).members.cache.get(message.author.id).permissions.has(PermissionFlagsBits.ManageMessages);
if(!hasPermission) return
//Verificar se está na sala bemvindo //Verificar se está na sala bemvindo
if(bemvindo(message)) if(bemvindo(message))
{ {

@ -1,6 +1,6 @@
const path = require('path'); const path = require('path');
const find = require('findit'); const find = require('findit');
const {Client,ClientOptions,GatewayIntentBits,Message, Partials, ActivityType,EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle} = require('discord.js') const {Client,ClientOptions,GatewayIntentBits,Message, Partials, ActivityType,EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField, PermissionFlagsBits } = require('discord.js')
const roleRulesM = require('./models/autoRoleRule'); const roleRulesM = require('./models/autoRoleRule');
const feedM = require('./models/feeds'); const feedM = require('./models/feeds');
const xmlparser = require('xml-js') const xmlparser = require('xml-js')
@ -16,6 +16,8 @@ module.exports.ActionRowBuilder = ActionRowBuilder;
module.exports.ButtonBuilder = ButtonBuilder; module.exports.ButtonBuilder = ButtonBuilder;
module.exports.ButtonStyle = ButtonStyle; module.exports.ButtonStyle = ButtonStyle;
module.exports.Message = Message; module.exports.Message = Message;
module.exports.PermissionsBitField = PermissionsBitField;
module.exports.PermissionFlagsBits = PermissionFlagsBits;
//@ts-check //@ts-check
class CommandOptions class CommandOptions
@ -198,7 +200,7 @@ class _Client extends Client
let isAdmin =false; let isAdmin =false;
try try
{ {
isAdmin = this.guilds.cache.get(message.guild.id).members.cache.get(message.author.id).permissions.has('ADMINISTRATOR'); isAdmin = this.guilds.cache.get(message.guild.id).members.cache.get(message.author.id).permissions.has(PermissionFlagsBits.Administrator);
} catch (error) } catch (error)
{ {
console.log('Lib: Command: Permission Verification: Failed') console.log('Lib: Command: Permission Verification: Failed')

Loading…
Cancel
Save