Moved emote cmds to utility category.

Updated Discord.JS version to 12.4.0.
Added channelCreate/remove events.
Removed husky.
This commit is contained in:
Keanu Timmermans 2020-10-20 12:04:13 +00:00 committed by GitHub
parent 74b4d4272c
commit 0c0fc083cf
10 changed files with 110 additions and 95 deletions

1
.husky/.gitignore vendored
View File

@ -1 +0,0 @@
_

View File

@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"
npm test && npx prettier --write .

48
package-lock.json generated
View File

@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"@discordjs/collection": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz",
"integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw=="
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz",
"integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
},
"@discordjs/form-data": {
"version": "3.0.1",
@ -359,30 +359,18 @@
"dev": true
},
"discord.js": {
"version": "12.2.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.2.0.tgz",
"integrity": "sha512-Ueb/0SOsxXyqwvwFYFe0msMrGqH1OMqpp2Dpbplnlr4MzcRrFWwsBM9gKNZXPVBHWUKiQkwU8AihXBXIvTTSvg==",
"version": "12.4.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.4.0.tgz",
"integrity": "sha512-Lc+/vKzih1DPEya/0MO0BAp4Ru/4+MfDsOJkfbyzGoyIlFqiWSQ78RdyRk4tqAtabl6d5QR4Ygo0Ub0TGEsXBg==",
"requires": {
"@discordjs/collection": "^0.1.5",
"@discordjs/collection": "^0.1.6",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"node-fetch": "^2.6.0",
"prism-media": "^1.2.0",
"node-fetch": "^2.6.1",
"prism-media": "^1.2.2",
"setimmediate": "^1.0.5",
"tweetnacl": "^1.0.3",
"ws": "^7.2.1"
},
"dependencies": {
"prism-media": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
},
"ws": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
"integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w=="
}
"ws": "^7.3.1"
}
},
"duplexer": {
@ -610,12 +598,6 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"husky": {
"version": "5.0.0-alpha.6",
"resolved": "https://registry.npmjs.org/husky/-/husky-5.0.0-alpha.6.tgz",
"integrity": "sha512-Ofqq0oHLCO0r8hTb/1PQ3FAfsW945adUli8jFTeXdOIK8gCUmxY9A0BI0mG9oGboPf+Y53bvEmX6ljdrz+yV6w==",
"dev": true
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
@ -1044,6 +1026,11 @@
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==",
"dev": true
},
"prism-media": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
},
"promise.allsettled": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz",
@ -1480,6 +1467,11 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"ws": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz",
"integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA=="
},
"y18n": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",

View File

@ -6,7 +6,7 @@
"private": true,
"dependencies": {
"chalk": "^4.1.0",
"discord.js": "^12.2.0",
"discord.js": "^12.4.0",
"inquirer": "^7.3.1",
"moment": "^2.27.0"
},
@ -15,7 +15,6 @@
"@types/mocha": "^8.0.3",
"@types/node": "^14.0.22",
"@types/ws": "^7.2.6",
"husky": "^5.0.0-alpha.6",
"mocha": "^8.1.2",
"prettier": "2.1.2",
"ts-node": "^9.0.0",
@ -23,7 +22,6 @@
"typescript": "^3.9.6"
},
"scripts": {
"postinstall": "husky install",
"build": "tsc && npm prune --production",
"start": "node dist/index.js",
"once": "tsc && npm start",

View File

@ -3,6 +3,7 @@ import { CommonLibrary, logs, botHasPermission } from '../core/lib';
import { Config, Storage } from '../core/structures';
import { PermissionNames, getPermissionLevel } from '../core/permissions';
import { Permissions } from 'discord.js';
import * as discord from 'discord.js';
function getLogBuffer(type: string) {
return {
@ -107,6 +108,9 @@ export default new Command({
description: 'Purges bot messages.',
permission: Command.PERMISSIONS.BOT_SUPPORT,
async run($: CommonLibrary): Promise<any> {
if ($.message.channel instanceof discord.DMChannel) {
return;
}
$.message.delete();
const msgs = await $.channel.messages.fetch({
limit: 100,

View File

@ -1,59 +0,0 @@
import { MessageEmbed } from 'discord.js';
import Command from '../core/command';
import { CommonLibrary } from '../core/lib';
export default new Command({
description: 'Various utilities.',
endpoint: false,
usage: '',
async run($: CommonLibrary): Promise<any> {},
subcommands: {
lsemotes: new Command({
description: "Lists all emotes the bot has in it's registry,",
endpoint: true,
async run($: CommonLibrary): Promise<any> {
const nsfw: string | string[] = [];
const pages = $.client.emojis.cache
.filter((x) => !nsfw.includes(x.guild.id), this)
.array();
const pagesSplit = $(pages).split(20);
$.log(pagesSplit);
var embed = new MessageEmbed()
.setTitle('**Emoji list!**')
.setColor('AQUA');
let desc = '';
for (const emote of pagesSplit[0]) {
desc += `${emote} | ${emote.name}\n`;
}
embed.setDescription(desc);
const msg = await $.channel.send({ embed });
$.paginate(msg, $.author.id, pages.length, (page) => {
let desc = '';
for (const emote of pagesSplit[page]) {
desc += `${emote} | ${emote.name}\n`;
}
embed.setDescription(desc);
msg.edit(embed);
});
},
}),
emote: new Command({
description: 'Send the specified emote.',
run: 'Please provide a command name.',
any: new Command({
description: 'The emote to send.',
usage: '<emote>',
async run($: CommonLibrary): Promise<any> {
const search = $.args[0].toLowerCase();
const emote = $.client.emojis.cache.find((emote) =>
emote.name.toLowerCase().includes(search),
);
if (!emote) return $.channel.send("That's not a valid emote name!");
$.message.delete();
$.channel.send(`${emote}`);
},
}),
}),
},
});

View File

@ -0,0 +1,21 @@
import { MessageEmbed } from 'discord.js';
import Command from '../../core/command';
import { CommonLibrary } from '../../core/lib';
export default new Command({
description: 'Send the specified emote.',
run: 'Please provide a command name.',
any: new Command({
description: 'The emote to send.',
usage: '<emote>',
async run($: CommonLibrary): Promise<any> {
const search = $.args[0].toLowerCase();
const emote = $.client.emojis.cache.find((emote) =>
emote.name.toLowerCase().includes(search),
);
if (!emote) return $.channel.send("That's not a valid emote name!");
$.message.delete();
$.channel.send(`${emote}`);
},
}),
});

View File

@ -0,0 +1,32 @@
import { MessageEmbed } from 'discord.js';
import Command from '../../core/command';
import { CommonLibrary } from '../../core/lib';
export default new Command({
description: "Lists all emotes the bot has in it's registry,",
endpoint: true,
async run($: CommonLibrary): Promise<any> {
const nsfw: string | string[] = [];
const pages = $.client.emojis.cache
.filter((x) => !nsfw.includes(x.guild.id), this)
.array();
const pagesSplit = $(pages).split(20);
$.log(pagesSplit);
var embed = new MessageEmbed().setTitle('**Emoji list!**').setColor('AQUA');
let desc = '';
for (const emote of pagesSplit[0]) {
desc += `${emote} | ${emote.name}\n`;
}
embed.setDescription(desc);
const msg = await $.channel.send({ embed });
$.paginate(msg, $.author.id, pages.length, (page) => {
let desc = '';
for (const emote of pagesSplit[page]) {
desc += `${emote} | ${emote.name}\n`;
}
embed.setDescription(desc);
msg.edit(embed);
});
},
});

View File

@ -0,0 +1,16 @@
import Event from '../core/event';
import { client } from '../index';
import $ from '../core/lib';
import * as discord from 'discord.js';
export default new Event<'channelCreate'>({
async on(channel) {
const botGuilds = client.guilds;
if (channel instanceof discord.GuildChannel) {
const createdGuild = await botGuilds.fetch(channel.guild.id);
$.log(
`Channel created in '${createdGuild.name}' called '#${channel.name}'`,
);
}
},
});

View File

@ -0,0 +1,16 @@
import Event from '../core/event';
import { client } from '../index';
import $ from '../core/lib';
import * as discord from 'discord.js';
export default new Event<'channelDelete'>({
async on(channel) {
const botGuilds = client.guilds;
if (channel instanceof discord.GuildChannel) {
const createdGuild = await botGuilds.fetch(channel.guild.id);
$.log(
`Channel deleted in '${createdGuild.name}' called '#${channel.name}'`,
);
}
},
});