diff options
Diffstat (limited to 'src')
28 files changed, 338 insertions, 532 deletions
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 0547bd0..1974297 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -1,29 +1,29 @@ -// import { BushCommand, BushMessage, BushSlashMessage, guildFeatures } from '@lib'; -// import { MessageEmbed } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage, guildFeatures } from '@lib'; +import { MessageEmbed } from 'discord.js'; -// export default class FeaturesCommand extends BushCommand { -// public constructor() { -// super('features', { -// aliases: ['features'], -// category: 'config', -// description: { -// content: 'Toggle features the server.', -// usage: 'features', -// examples: ['features'] -// }, -// slash: true, -// channel: 'guild', -// clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], -// userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] -// }); -// } -// public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { -// if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); -// const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default); -// const featureList: string[] = []; -// const enabledFeatures = message.guild.getSetting('enabledFeatures'); -// guildFeatures.forEach(feature => { -// featureList.push(`${}`) -// }) -// } -// } +export default class FeaturesCommand extends BushCommand { + public constructor() { + super('features', { + aliases: ['features'], + category: 'config', + description: { + content: 'Toggle features the server.', + usage: 'features', + examples: ['features'] + }, + slash: true, + channel: 'guild', + clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] + }); + } + public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { + if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); + const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default); + const featureList: string[] = []; + const enabledFeatures = await message.guild.getSetting('enabledFeatures'); + guildFeatures.forEach((feature) => { + // featureList.push(`**${feature}:** ${enabledFeatures.includes(feature)? util.emojis.}`); + }); + } +} diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 151e4a1..aa421cd 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -24,7 +24,8 @@ export default class TestCommand extends BushCommand { optional: true } } - ] + ], + superUserOnly: true }); } diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts new file mode 100644 index 0000000..5f91dca --- /dev/null +++ b/src/commands/utilities/calculator.ts @@ -0,0 +1,57 @@ +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { MessageEmbed } from 'discord.js'; +import { evaluate } from 'mathjs'; + +export default class CalculatorCommand extends BushCommand { + public constructor() { + super('calculator', { + aliases: ['calculator', 'calc', 'math'], + category: 'utilities', + description: { + content: 'Calculates math expressions.', + usage: 'calculator <expression>', + examples: ['calculator '] + }, + args: [ + { + id: 'expression', + type: 'string', + match: 'rest', + prompt: { + start: 'What would you like to evaluate?', + retry: '{error} Pick something to evaluate.', + optional: false + } + } + ], + slash: true, + slashOptions: [ + { + name: 'expression', + description: 'What would you like to evaluate?', + type: 'STRING', + required: true + } + ], + hidden: true, + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES'] + }); + } + public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> { + const decodedEmbed = new MessageEmbed() + .setTitle(`Calculator`) + .addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression, 'mma')); + try { + const calculated = evaluate(args.expression); + decodedEmbed + .setColor(util.colors.success) + .addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma')); + } catch (error) { + decodedEmbed + .setColor(util.colors.error) + .addField(`📤 Error Calculating`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); + } + return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); + } +} diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts index 05e988a..a5a4c21 100644 --- a/src/commands/utilities/decode.ts +++ b/src/commands/utilities/decode.ts @@ -99,16 +99,14 @@ export default class DecodeCommand extends BushCommand { const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias || 'decoded'); const decodedEmbed = new MessageEmbed() .setTitle(`${encodeOrDecode} Information`) - .addField('📥 Input', await util.inspectCleanRedactCodeblock(data, undefined)); + .addField('📥 Input', await util.inspectCleanRedactCodeblock(data)); try { const decoded = Buffer.from(data, from).toString(to); - decodedEmbed - .setColor(util.colors.success) - .addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded, undefined)); + decodedEmbed.setColor(util.colors.success).addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded)); } catch (error) { decodedEmbed .setColor(util.colors.error) - .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error.stack, undefined)); + .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error?.stack ?? error)); } return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); } diff --git a/src/inhibitors/blacklist/channelGlobalBlacklist.ts b/src/inhibitors/blacklist/channelGlobalBlacklist.ts index 9bbf30f..36a6757 100644 --- a/src/inhibitors/blacklist/channelGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/channelGlobalBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { super('channelGlobalBlacklist', { reason: 'channelGlobalBlacklist', category: 'blacklist', - type: 'all' + type: 'post', + priority: 500 }); } @@ -14,7 +15,6 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedChannels.includes(message.channel!.id)) { - // client.console.debug(`channelGlobalBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/channelGuildBlacklist.ts b/src/inhibitors/blacklist/channelGuildBlacklist.ts index b4c6f3f..54acb34 100644 --- a/src/inhibitors/blacklist/channelGuildBlacklist.ts +++ b/src/inhibitors/blacklist/channelGuildBlacklist.ts @@ -5,7 +5,8 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { super('channelGuildBlacklist', { reason: 'channelGuildBlacklist', category: 'blacklist', - type: 'all' + type: 'post', + priority: 499 }); } @@ -14,7 +15,6 @@ export default class ChannelGuildBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedChannels'))?.includes(message.channel!.id)) { - // client.console.debug(`channelGuildBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/guildBlacklist.ts b/src/inhibitors/blacklist/guildBlacklist.ts index de15d76..ec78995 100644 --- a/src/inhibitors/blacklist/guildBlacklist.ts +++ b/src/inhibitors/blacklist/guildBlacklist.ts @@ -5,7 +5,8 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { super('guildBlacklist', { reason: 'guildBlacklist', category: 'blacklist', - type: 'all' + type: 'all', + priority: 50 }); } @@ -17,7 +18,6 @@ export default class GuildBlacklistInhibitor extends BushInhibitor { ) return false; if (client.cache.global.blacklistedGuilds.includes(message.guild.id)) { - // client.console.debug(`GuildBlacklistInhibitor blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/userGlobalBlacklist.ts b/src/inhibitors/blacklist/userGlobalBlacklist.ts index 967943d..65d763d 100644 --- a/src/inhibitors/blacklist/userGlobalBlacklist.ts +++ b/src/inhibitors/blacklist/userGlobalBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { super('userGlobalBlacklist', { reason: 'userGlobalBlacklist', category: 'blacklist', - type: 'all' + type: 'pre', + priority: 30 }); } @@ -14,7 +15,6 @@ export default class UserGlobalBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if (client.cache.global.blacklistedUsers.includes(message.author.id)) { - // client.console.debug(`userGlobalBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/blacklist/userGuildBlacklist.ts b/src/inhibitors/blacklist/userGuildBlacklist.ts index 0e28ba4..34a24d3 100644 --- a/src/inhibitors/blacklist/userGuildBlacklist.ts +++ b/src/inhibitors/blacklist/userGuildBlacklist.ts @@ -5,7 +5,8 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { super('userGuildBlacklist', { reason: 'userGuildBlacklist', category: 'blacklist', - type: 'all' + type: 'pre', + priority: 20 }); } @@ -14,7 +15,6 @@ export default class UserGuildBlacklistInhibitor extends BushInhibitor { if (client.isOwner(message.author) || client.isSuperUser(message.author) || client.user!.id === message.author.id) return false; if ((await message.guild.getSetting('blacklistedUsers'))?.includes(message.author.id)) { - // client.console.debug(`userGuildBlacklist blocked message.`); return true; } return false; diff --git a/src/inhibitors/noCache.ts b/src/inhibitors/checks/fatal.ts index 673f3ac..6b62507 100644 --- a/src/inhibitors/noCache.ts +++ b/src/inhibitors/checks/fatal.ts @@ -1,10 +1,11 @@ import { BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; -export default class NoCacheInhibitor extends BushInhibitor { +export default class FatalInhibitor extends BushInhibitor { public constructor() { - super('noCache', { - reason: 'noCache', + super('fatal', { + reason: 'fatal', type: 'all', + category: 'checks', priority: 100 }); } @@ -13,7 +14,6 @@ export default class NoCacheInhibitor extends BushInhibitor { if (client.isOwner(message.author)) return false; for (const property in client.cache.global) { if (!client.cache.global[property as keyof typeof client.cache.global]) { - client.console.debug(`NoCacheInhibitor blocked message.`); return true; } } diff --git a/src/inhibitors/checks/guildUnavailable.ts b/src/inhibitors/checks/guildUnavailable.ts new file mode 100644 index 0000000..0bd1bec --- /dev/null +++ b/src/inhibitors/checks/guildUnavailable.ts @@ -0,0 +1,19 @@ +import { BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class GuildUnavailableInhibitor extends BushInhibitor { + public constructor() { + super('guildUnavailable', { + reason: 'guildUnavailable', + type: 'all', + category: 'checks', + priority: 70 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage): Promise<boolean> { + if (message.guild && !message.guild.available) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/dm.ts b/src/inhibitors/command/dm.ts new file mode 100644 index 0000000..4e9c53e --- /dev/null +++ b/src/inhibitors/command/dm.ts @@ -0,0 +1,19 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class DMInhibitor extends BushInhibitor { + public constructor() { + super('dm', { + reason: 'dm', + category: 'command', + type: 'post', + priority: 75 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.channel === 'dm' && message.guild) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/commands/globalDisabledCommand.ts b/src/inhibitors/command/globalDisabledCommand.ts index 9a750cc..a6e24c7 100644 --- a/src/inhibitors/commands/globalDisabledCommand.ts +++ b/src/inhibitors/command/globalDisabledCommand.ts @@ -4,15 +4,15 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { public constructor() { super('disabledGlobalCommand', { reason: 'disabledGlobal', - type: 'pre', - priority: 4 + category: 'command', + type: 'post', + priority: 300 }); } public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { if (message.author.isOwner()) return false; if (client.cache.global.disabledCommands?.includes(command?.id)) { - client.console.debug(`disabledGlobalCommand blocked message.`); return true; } return false; diff --git a/src/inhibitors/command/guild.ts b/src/inhibitors/command/guild.ts new file mode 100644 index 0000000..b960439 --- /dev/null +++ b/src/inhibitors/command/guild.ts @@ -0,0 +1,19 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class GuildInhibitor extends BushInhibitor { + public constructor() { + super('guild', { + reason: 'guild', + category: 'command', + type: 'post', + priority: 80 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.channel === 'guild' && !message.guild) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/commands/guildDisabledCommand.ts b/src/inhibitors/command/guildDisabledCommand.ts index ee798e5..d56e42c 100644 --- a/src/inhibitors/commands/guildDisabledCommand.ts +++ b/src/inhibitors/command/guildDisabledCommand.ts @@ -4,8 +4,9 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { public constructor() { super('disabledGuildCommand', { reason: 'disabledGuild', - type: 'pre', - priority: 3 + category: 'command', + type: 'post', + priority: 250 }); } @@ -14,7 +15,6 @@ export default class DisabledGuildCommandInhibitor extends BushInhibitor { if (message.author.isOwner() || message.author.isSuperUser()) return false; // super users bypass guild disabled commands if ((await message.guild.getSetting('disabledCommands'))?.includes(command?.id)) { - client.console.debug(`disabledGuildCommand blocked message.`); return true; } return false; diff --git a/src/inhibitors/command/nsfw.ts b/src/inhibitors/command/nsfw.ts new file mode 100644 index 0000000..563cb7a --- /dev/null +++ b/src/inhibitors/command/nsfw.ts @@ -0,0 +1,20 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; +import { TextChannel } from 'discord.js'; + +export default class NsfwInhibitor extends BushInhibitor { + public constructor() { + super('nsfw', { + reason: 'notNsfw', + category: 'command', + type: 'post', + priority: 25 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.onlyNsfw && !(message.channel as TextChannel).nsfw) { + return true; + } + return false; + } +} diff --git a/src/inhibitors/command/owner.ts b/src/inhibitors/command/owner.ts new file mode 100644 index 0000000..22ac913 --- /dev/null +++ b/src/inhibitors/command/owner.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class OwnerInhibitor extends BushInhibitor { + public constructor() { + super('owner', { + reason: 'owner', + category: 'command', + type: 'post', + priority: 100 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.ownerOnly) { + if (!client.isOwner(message.author)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/restrictedChannel.ts b/src/inhibitors/command/restrictedChannel.ts new file mode 100644 index 0000000..4578d95 --- /dev/null +++ b/src/inhibitors/command/restrictedChannel.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class RestrictedChannelInhibitor extends BushInhibitor { + public constructor() { + super('restrictedChannel', { + reason: 'restrictedChannel', + category: 'command', + type: 'post', + priority: 10 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.restrictedChannels?.length && message.channel) { + if (!command.restrictedChannels.includes(message.channel.id)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/restrictedGuild.ts b/src/inhibitors/command/restrictedGuild.ts new file mode 100644 index 0000000..7ec6926 --- /dev/null +++ b/src/inhibitors/command/restrictedGuild.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class RestrictedGuildInhibitor extends BushInhibitor { + public constructor() { + super('restrictedGuild', { + reason: 'restrictedGuild', + category: 'command', + type: 'post', + priority: 5 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.restrictedChannels?.length && message.channel) { + if (!command.restrictedChannels.includes(message.channel.id)) { + return true; + } + } + return false; + } +} diff --git a/src/inhibitors/command/superUser.ts b/src/inhibitors/command/superUser.ts new file mode 100644 index 0000000..28674ea --- /dev/null +++ b/src/inhibitors/command/superUser.ts @@ -0,0 +1,21 @@ +import { BushCommand, BushInhibitor, BushMessage, BushSlashMessage } from '@lib'; + +export default class SuperUserInhibitor extends BushInhibitor { + public constructor() { + super('superUser', { + reason: 'superUser', + category: 'command', + type: 'post', + priority: 99 + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, command: BushCommand): Promise<boolean> { + if (command.superUserOnly) { + if (!client.isSuperUser(message.author)) { + return true; + } + } + return false; + } +} diff --git a/src/lib/assets/Roboto-Regular.ttf b/src/lib/assets/Roboto-Regular.ttf Binary files differdeleted file mode 100644 index 3d6861b..0000000 --- a/src/lib/assets/Roboto-Regular.ttf +++ /dev/null diff --git a/src/lib/badlinks.json b/src/lib/badlinks.json deleted file mode 100644 index 39212b5..0000000 --- a/src/lib/badlinks.json +++ /dev/null @@ -1,372 +0,0 @@ -[ - "acercup.com", - "affix-cup.ru", - "affix-sport.ru", - "airdrops.tips", - "aladdinhub.fun", - "allskinz.xyz", - "ano-skinspin.xyz", - "anomalygiveaways.pro", - "anomalyknifes.xyz", - "anomalyskin.xyz", - "anomalyskinz.xyz", - "anoskinzz.xyz", - "berrygamble.com", - "bit-skins.ru", - "bitknife.xyz", - "bitskines.ru", - "casefire.fun", - "challengeme.in", - "challengeme.vip", - "challengme.ru", - "cloud9team.space", - "cmepure.com", - "cmskillcup.com", - "counterpaid.xyz", - "counterspin.top", - "counterstrikegift.xyz", - "cs-beast.xyz", - "cs-lucky.xyz", - "cs-pill.xyz", - "cs-prizeskins.xyz", - "cs-prizeskinz.xyz", - "cs-simpleroll.xyz", - "cs-skinz.xyz", - "cs-smoke.xyz", - "cs-spinz.xyz", - "cs-victory.xyz", - "csallskin.xyz", - "csbuyskins.in", - "cscoat.eu", - "csgo-analyst.com", - "csgo-cash.eu", - "csgo-gifts.com", - "csgo-market.ru.com", - "csgo-market.ru.com", - "csgo-steamanalyst.net", - "csgo-swapskin.com", - "csgo-trade.net", - "csgo-up.com", - "csgobeats.com", - "csgobelieve.ru", - "csgocase.one", - "csgocashs.com", - "csgocheck.ru.com", - "csgocheck.ru", - "csgocompetive.com", - "csgocupp.ru.com", - "csgocybersport.ru.com", - "csgodetails.info", - "csgodreamer.com", - "csgodrs.com", - "csgoeasywin.ru.com", - "csgoelite.xyz", - "csgoencup.com", - "csgoevent.xyz", - "csgogift49.xyz", - "csgoindex.ru.com", - "csgoindex.ru", - "csgoitemdetails.com", - "csgoitemsprices.com", - "csgoko.tk", - "csgomarble.xyz", - "csgomarketplace.net", - "csgomarkets.net", - "csgoorun.ru", - "csgoprocupgo.com", - "csgorcup.com", - "csgorose.com", - "csgoroyalskins1.com", - "csgoskill.ru", - "csgoskinprices.com", - "csgoskinsinfo.com", - "csgoskinsroll.com", - "csgosteamanalysis.com", - "csgosteamanalyst.ru", - "csgoteammate.gq", - "csgothunby.com", - "csgotrades.net", - "csgovip.ru", - "csgoxgiveaway.ru", - "csgozone.net.in", - "csgunskins.xyz", - "csmoneyskinz.xyz", - "csmvcecup.com", - "csprices.in", - "csskill.com", - "csskillpro.xyz", - "csskinz.xyz", - "cstournament.ru", - "csxrnoney.com", - "cybergamearena.ru", - "d2cups.com", - "d2faceit.com", - "deamonbets.ru", - "demonbets.ru", - "denforapasi.cf", - "diablobets.com", - "dicsord.gifts", - "discod.gift", - "discord-gifts.com", - "discord-nitro.gifts", - "discord.blog", - "discord.shop", - "discordgivenitro.com", - "discrod.gift", - "disrcod.com", - "dlscord.info", - "dlscord.online", - "dlscord.press", - "dlscord.store", - "dlscord.world", - "discrod.gifts", - "dlscord.wiki", - "dirscod.gift", - "dirscod.com", - "discorcl.link", - "discod.info", - "dicsord.net", - "discorb.co", - "dicsord.net", - "dicksod.co", - "diskord.ru.com", - "discord-nitro.link", - "discorb.ru.com", - "discordnitrogift.ru", - "discorcl.click", - "doatgiveaway.top", - "dopeskins.com", - "dota2fight.net", - "dota2fight.ru", - "dota2giveaway.top", - "dota2giveaways.top", - "dotafights.vip", - "dotagiveaway.win", - "dragon-up.online", - "earnskinz.xyz", - "emeraldbets.ru", - "eplcups.com", - "esea-mdl.com", - "esportgaming.ru", - "event-games4roll.com", - "exchangeuritems.gq", - "extraskinscs.xyz", - "ezwin24.ru", - "facecup.fun", - "faceiteasyleague.ru", - "fatown.net", - "fineleague.fun", - "fireopencase.com", - "fivetown.net", - "free-skins.ru", - "free-nitro.ru", - "freenitros.ru", - "free-nitros.ru", - "freenitroi.ru", - "g2-give.ru", - "g2-give.ru", - "game4roll.com", - "gameluck.ru", - "gamerich.xyz", - "games-roll.ga", - "games-roll.ml", - "games-roll.ru", - "gift4keys.com", - "giveavvay.com", - "giveawayskin.com", - "global-skins.gq", - "globalcsskins.xyz", - "globalskins.tk", - "goldendota.com", - "goodskins.gq", - "gosteamanalyst.com", - "gtakey.ru", - "go.rancah.com", - "giftsdiscord.ru", - "get-nitro.net", - "hellgiveaway.trade", - "hellstores.xyz", - "hltvcsgo.com", - "hltvgames.net", - "iemcup.com", - "keys-loot.com", - "knifespin.top", - "knifespin.top", - "knifespin.xyz", - "knifespins.xyz", - "knifez-roll.xyz", - "knifez-win.xyz", - "league-csgo.com", - "lehatop-01.ru", - "lootxmarket.com", - "loungeztrade.com", - "lucky-skins.xyz", - "makson-gta.ru", - "maxskins.xyz", - "mvcsgo.com", - "mvpcup.ru", - "mvptournament.com", - "mygames4roll.com", - "made-nitro.com", - "naviback.ru", - "night-skins.com", - "nitros-gift.com", - "nitro-discord.org", - "nwgwroqr.ru", - "ownerbets.com", - "oligarph.club", - "playerskinz.xyz", - "pubggift62.xyz", - "rangskins.com", - "rave-new.ru", - "roll-skins.ru", - "roll4knife.xyz", - "roll4tune.com", - "rollknfez.xyz", - "rollskin-simple.xyz", - "rushbskins.xyz", - "rushskins.xyz", - "s1mple-spin.xyz", - "sakuralive.ru.com", - "scale-navi.pp.ru", - "simple-knifez.xyz", - "simple-win.xyz", - "simplegamepro.ru", - "simpleroll-cs.xyz", - "simplespinz.xyz", - "simplewinz.xyz", - "skin-index.com", - "skin888trade.com", - "skincs-spin.top", - "skincs-spin.xyz", - "skinmarkets.net", - "skins-hub.top", - "skins-info.net", - "skins-jungle.xyz", - "skinsboost.ru", - "skinsdatabse.com", - "skinsind.com", - "skinsmind.ru", - "skinspace.ru", - "skinsplane.com", - "skinsplanes.com", - "skinsplanets.com", - "skinxinfo.net", - "skinxmarket.site", - "skinz-spin.top", - "skinz-spin.xyz", - "skinzjar.ru", - "skinzprize.xyz", - "skinzspin-cs.xyz", - "skinzspinz.xyz", - "sleanmconmunltiy.ru", - "spin-games.com", - "spin4skinzcs.top", - "spin4skinzcs.xyz", - "spinforskin.ml", - "sponsored-simple.xyz", - "staemcomnrnunitiy.ru.com", - "staemcomrnunity.store", - "staermcrommunity.me", - "staffstatsgo.com", - "starrygamble.com", - "stat-csgo.ru", - "stats-cs.ru", - "stceamcomminity.com", - "steam-analyst.ru", - "steam-trades.icu", - "steamanalysts.com", - "steamcomcunity.ru", - "steamcomminutiu.ru", - "steamcomminutiy.ru", - "steamcomminytiu.com", - "steamcomminytiu.ru", - "steamcomminytu.ru", - "steamcommnunily.com", - "steamcommnuninty.com", - "steamcommnuntiy.com", - "steamcommrutiny.ru", - "steamcommuniiy.ru", - "steamcommunily.uno", - "steamcommunityu.com", - "steamcommunityw.com", - "steamcommunlty.pro", - "steamcommunutiy.com", - "steamcommunytiu.ru", - "steamcommunytu.ru", - "steamcommutiny.com", - "steamcommynitu.ru", - "steamcomnmuituy.com", - "steamcomnumity.ru", - "steamcomrnunity.ru", - "steamcomrrnunity.com", - "steamcomrunity.com", - "steamconmunlty.com", - "steamcormmuntiy.com", - "steamgamesroll.ru", - "steamncommuniity.com", - "steamncommunity.com", - "steamnmcomunnity.co", - "steamoemmunity.com", - "steamsupportpowered.icu", - "steancommynity.ru.com", - "steancomnunytu.ru", - "steancomunnity.ru", - "steancomunyiti.ru", - "stearmcommunnitty.online", - "stearmmcomunitty.ru", - "stearmmcomunity.ru", - "stearmmcomuunity.ru", - "stearncomminuty.ru", - "stearncommunity.ru", - "stearncommunytiy.ru", - "stearncormmunity.com", - "steemcommnunity.ru", - "stemcommunnilty.com", - "stermccommunitty.ru", - "stermcommuniity.com", - "stewie2k-giveaway-150days.pro", - "stiemcommunitty.ru", - "store-stempowered.com", - "streamcommulinty.com", - "streamcommuninnity.com", - "streamcommuunnity.com", - "streamcomnumity.ru", - "streamcomunity.com", - "streammcomunnity.ru", - "streancommunuty.ru", - "streancommunuty.ru", - "strearmcommunity.ru", - "strearmcomunity.ru", - "steamcommunityu.ru", - "steamcommunrlity.com", - "stearncommuty.com", - "steamcommunitiyu.com", - "stermcommunnitty.ru", - "steamcommunitlu.com", - "steamcommunity.link", - "steancommunity.link", - "steamcomuniity.ru.com", - "steam-nitro.ru", - "sunnygamble.com", - "swapskins.live", - "test-domuin2.com", - "test-domuin3.ru", - "test-domuin4.ru", - "test-domuin5.ru", - "tf2market.store", - "tournamentt.com", - "ultimateskins.xyz", - "ultracup.fun", - "uspringcup.com", - "waterbets.ru", - "win-skin.top", - "win-skin.xyz", - "winknifespin.xyz", - "winskin-simple.xyz", - "winskins.top", - "wintheskin.xyz", - "xgamercup.com", - "stmeacomunnitty.ru", - "discrodnitro.org" -] diff --git a/src/lib/badwords.json b/src/lib/badwords.json deleted file mode 100644 index fc7a5d6..0000000 --- a/src/lib/badwords.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "nigger": 3, - "nigga": 3, - "retard": 2, - "retarted": 2, - "faggot": 2, - "slut": 1, - "whore": 1, - "卍": 3, - "found a cool software that improves the": 3, - "hi, bro h am leaving cs:go and giving away my skin": 3, - "hi friend, today i am leaving this fucking game": 3, - "hi guys, i'm leaving this fucking game, take my": 3, - "you can choose any skin for yourself": 3, - "discord nitro for free - steam store": 3, - "get 3 months of discord nitro": 3, - "get discord nitro for free": 3, - "free 3 months of discord nitro": 3, - "free discord nitro airdrop": 3 -} diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 21984ab..44a0966 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -9,7 +9,6 @@ import { BushSlashMessage } from './BushSlashMessage'; export type BushCommandHandlerOptions = CommandHandlerOptions; const commandHandlerEvents = BushConstants.CommandHandlerEvents; -const blockedReasons = BushConstants.BlockedReasons; export interface BushCommandHandlerEvents extends CommandHandlerEvents { commandBlocked: [message: BushMessage, command: BushCommand, reason: string]; @@ -34,76 +33,17 @@ export class BushCommandHandler extends CommandHandler { super(client, options); } - // protected override setup(): void { - // super.setup(); - // } - public override async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise<boolean> { - if (command.ownerOnly) { - const isOwner = client.isOwner(message.author); - if (!isOwner) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.OWNER - ); - return true; - } - } - - if (command.superUserOnly) { - const isSuperUser = client.isSuperUser(message.author); - if (!isSuperUser) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.OWNER - ); - return true; - } - } - - if (command.channel === 'guild' && !message.guild) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.GUILD - ); + const reason = this.inhibitorHandler ? await this.inhibitorHandler.test('post', message, command) : null; + if (reason != null) { + this.emit(slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, message, command, reason); return true; } - if (command.channel === 'dm' && message.guild) { - this.emit( - slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED, - message, - command, - blockedReasons.DM - ); - return true; - } - if (command.restrictedChannels?.length && message.channel) { - if (!command.restrictedChannels.includes(message.channel.id)) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, blockedReasons.RESTRICTED_CHANNEL); - return true; - } - } - if (command.restrictedGuilds?.length && message.guild) { - if (!command.restrictedGuilds.includes(message.guild.id)) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, blockedReasons.RESTRICTED_GUILD); - return true; - } - } if (await this.runPermissionChecks(message, command)) { return true; } - const reason = this.inhibitorHandler ? await this.inhibitorHandler.test('post', message, command) : null; - if (reason != null) { - this.emit(commandHandlerEvents.COMMAND_BLOCKED, message, command, reason); - return true; - } + return !!this.runCooldowns(message, command); } } diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts index 215cf79..d10a024 100644 --- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts +++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts @@ -10,10 +10,13 @@ import { BushCommandUtil } from './BushCommandUtil'; export class BushSlashMessage extends AkairoMessage { public declare client: BushClient; public declare util: BushCommandUtil; - public declare guild: BushGuild; public declare author: BushUser; public declare member: BushGuildMember; public constructor(client: BushClient, interaction: CommandInteraction, command: BushCommand) { super(client, interaction, command); } + + public override get guild(): BushGuild | null { + return super.guild as BushGuild | null; + } } diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index 485de37..03e34f5 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -1,4 +1,5 @@ -import { BushCommandHandlerEvents, BushListener, BushMessage } from '@lib'; +import { BushCommand, BushCommandHandlerEvents, BushListener, BushMessage, BushSlashMessage } from '@lib'; +import { InteractionReplyOptions, Message, MessagePayload, ReplyMessageOptions } from 'discord.js'; export default class CommandBlockedListener extends BushListener { public constructor() { @@ -13,38 +14,42 @@ export default class CommandBlockedListener extends BushListener { } public static async handleBlocked( - ...[message, command, reason]: BushCommandHandlerEvents['commandBlocked'] | BushCommandHandlerEvents['slashBlocked'] + message: Message | BushMessage | BushSlashMessage, + command: BushCommand | null, + reason?: string ): Promise<unknown> { - const isSlash = message.util.isSlash; + const isSlash = !!command && !!message.util?.isSlash; void client.console.info( `${isSlash ? 'Slash' : 'Command'}Blocked`, - `<<${message.author.tag}>> tried to run <<${command}>> but was blocked because <<${reason}>>.`, + `<<${message.author.tag}>>${ + command ? ` tried to run <<${command}>> but` : "'s message" + } was blocked because <<${reason}>>.`, true ); const reasons = client.consts.BlockedReasons; switch (reason) { case reasons.OWNER: { - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} Only my developers can run the \`${command}\` command.`, ephemeral: true }); } case reasons.SUPER_USER: { - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} You must be a superuser to run the \`${command}\` command.`, ephemeral: true }); } case reasons.DISABLED_GLOBAL: { - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} My developers disabled the \`${command}\` command.`, ephemeral: true }); } case reasons.DISABLED_GUILD: { - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} The \`${command}\` command is currently disabled in \`${message.guild?.name}\`.`, ephemeral: true }); @@ -52,51 +57,64 @@ export default class CommandBlockedListener extends BushListener { case reasons.CHANNEL_GLOBAL_BLACKLIST: case reasons.CHANNEL_GUILD_BLACKLIST: return isSlash - ? message.util.reply({ content: `${util.emojis.error} You cannot use this bot in this channel.`, ephemeral: true }) - : (message as BushMessage).react(util.emojis.error); + ? await respond({ + content: `${util.emojis.error} You cannot use this bot in this channel.`, + ephemeral: true + }) + : await (message as BushMessage).react(util.emojis.cross); case reasons.USER_GLOBAL_BLACKLIST: case reasons.USER_GUILD_BLACKLIST: return isSlash - ? message.util.reply({ content: `${util.emojis.error} You are blacklisted from using this bot.`, ephemeral: true }) - : (message as BushMessage).react(util.emojis.error); + ? await respond({ + content: `${util.emojis.error} You are blacklisted from using this bot.`, + ephemeral: true + }) + : await (message as BushMessage).react(util.emojis.cross); case reasons.ROLE_BLACKLIST: { return isSlash - ? message.util.reply({ + ? await respond({ content: `${util.emojis.error} One of your roles blacklists you from using this bot.`, ephemeral: true }) - : (message as BushMessage).react(util.emojis.error); + : await (message as BushMessage).react(util.emojis.cross); } case reasons.RESTRICTED_CHANNEL: { + if (!command) break; const channels = command.restrictedChannels; const names: string[] = []; channels.forEach((c) => { names.push(`<#${c}>`); }); const pretty = util.oxford(names, 'and'); - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`, ephemeral: true }); } case reasons.RESTRICTED_GUILD: { + if (!command) break; const guilds = command.restrictedGuilds; const names: string[] = []; guilds.forEach((g) => { names.push(`\`${client.guilds.cache.get(g)?.name}\``); }); const pretty = util.oxford(names, 'and'); - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`, ephemeral: true }); } default: { - return await message.util.reply({ + return await respond({ content: `${util.emojis.error} Command blocked with reason \`${reason}\``, ephemeral: true }); } } + + // some inhibitors do not have message.util yet + function respond(content: string | MessagePayload | ReplyMessageOptions | InteractionReplyOptions) { + return message.util ? message.util.reply(content) : message.reply(content); + } } } diff --git a/src/listeners/commands/messageBlocked.ts b/src/listeners/commands/messageBlocked.ts new file mode 100644 index 0000000..a36c03d --- /dev/null +++ b/src/listeners/commands/messageBlocked.ts @@ -0,0 +1,17 @@ +import { BushCommandHandlerEvents, BushListener } from '@lib'; + +export default class MessageBlockedListener extends BushListener { + public constructor() { + super('messageBlocked', { + emitter: 'commandHandler', + event: 'messageBlocked' + }); + } + + public override async exec(...[message, reason]: BushCommandHandlerEvents['messageBlocked']): Promise<unknown> { + const reasons = client.consts.BlockedReasons; + if ([reasons.CLIENT, reasons.BOT].includes(reason)) return; + // return await CommandBlockedListener.handleBlocked(message as Message, null, reason); + return void client.console.verbose(`MessageBlocked`, `<<${message.author.tag}>>'s message was blocked because ${reason}`); + } +} diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts index 3f1780f..cfe3970 100644 --- a/src/listeners/message/automodCreate.ts +++ b/src/listeners/message/automodCreate.ts @@ -1,8 +1,11 @@ import { BushListener, BushMessage } from '@lib'; +// @ts-expect-error: ts doesn't recognize json5 +import _badLinks from '@root/lib/badlinks'; // Stolen from https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json +// @ts-expect-error: ts doesn't recognize json5 +import _badLinksSecret from '@root/lib/badlinks-secret'; // shhhh +// @ts-expect-error: ts doesn't recognize json5 +import badWords from '@root/lib/badwords'; import { MessageEmbed, TextChannel } from 'discord.js'; -import _badLinksSecret from '../../lib/badlinks-secret.json'; // shhhh -import _badLinks from '../../lib/badlinks.json'; // Stolen from https://github.com/nacrt/SkyblockClient-REPO/blob/main/files/scamlinks.json -import badWords from '../../lib/badwords.json'; import { BushClientEvents } from '../../lib/extensions/discord.js/BushClientEvents'; export default class AutomodMessageCreateListener extends BushListener { @@ -26,7 +29,7 @@ export default class AutomodMessageCreateListener extends BushListener { let temp = _badLinks; if (_badLinksSecret) temp = temp.concat(_badLinksSecret); - temp.forEach((link) => { + temp.forEach((link: string) => { badLinks[link] = 3; }); |