Added count, added some new playing lines, fixed security issue with hackban
This commit is contained in:
		
							parent
							
								
									e9f4109f43
								
							
						
					
					
						commit
						c65a8115aa
					
				
					 6 changed files with 94 additions and 4 deletions
				
			
		
							
								
								
									
										43
									
								
								commands/count.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								commands/count.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
const client = require("../utils/client.js");
 | 
			
		||||
const paginator = require("../utils/pagination/pagination.js");
 | 
			
		||||
const database = require("../utils/database.js");
 | 
			
		||||
 | 
			
		||||
exports.run = async (message) => {
 | 
			
		||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`;
 | 
			
		||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
 | 
			
		||||
  const counts = (await database.global.findOne({}).lean().exec()).cmdCounts;
 | 
			
		||||
  const countArray = [];
 | 
			
		||||
  const sortedValues = Object.entries(counts).sort((a, b) => {
 | 
			
		||||
    return b[1] - a[1];
 | 
			
		||||
  });
 | 
			
		||||
  console.log(sortedValues);
 | 
			
		||||
  for (const [key, value] of sortedValues) {
 | 
			
		||||
    countArray.push(`**${key}**: ${value}`);
 | 
			
		||||
  }
 | 
			
		||||
  const embeds = [];
 | 
			
		||||
  const groups = countArray.map((item, index) => {
 | 
			
		||||
    return index % 15 === 0 ? countArray.slice(index, index + 15) : null;
 | 
			
		||||
  }).filter((item) => {
 | 
			
		||||
    return item;
 | 
			
		||||
  });
 | 
			
		||||
  for (const [i, value] of groups.entries()) {
 | 
			
		||||
    embeds.push({
 | 
			
		||||
      "embed": {
 | 
			
		||||
        "title": "Command Usage Counts",
 | 
			
		||||
        "color": 16711680,
 | 
			
		||||
        "footer": {
 | 
			
		||||
          "text": `Page ${i + 1} of ${groups.length}`
 | 
			
		||||
        },
 | 
			
		||||
        "description": value.join("\n"),
 | 
			
		||||
        "author": {
 | 
			
		||||
          "name": message.author.username,
 | 
			
		||||
          "icon_url": message.author.avatarURL
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  return paginator(message, embeds);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.category = 1;
 | 
			
		||||
exports.help = "Gets how many times every command was used";
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,8 @@
 | 
			
		|||
const client = require("../utils/client.js");
 | 
			
		||||
 | 
			
		||||
exports.run = async (message, args) => {
 | 
			
		||||
  if (!message.member.permission.has("banMembers")) return `${message.author.mention}, you need to have the \`Ban Members\` permission on this server to ban people!`;
 | 
			
		||||
  if (!message.channel.guild.members.get(client.user.id).permission.has("banMembers") && !message.channel.permissionsOf(client.user.id).has("banMembers")) return `${message.author.mention}, I don't have the \`Ban Members\` permission!`;
 | 
			
		||||
  if (!args[0].match(/^<?[@#]?[&!]?\d+>?$/) && args[0] < 21154535154122752) return `${message.author.mention}, that's not a valid snowflake!`;
 | 
			
		||||
  try {
 | 
			
		||||
    const id = args[0].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", "");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue