From 59ecdf2cffd4194d71a1dc069ab0bc15db8a1683 Mon Sep 17 00:00:00 2001 From: Lio Young Date: Thu, 8 Apr 2021 22:12:03 +0200 Subject: [PATCH] test string replacing with Lingua --- package.json | 3 ++- src/events/message.ts | 19 ++++++++++++++----- src/modules/general/info.ts | 2 +- src/utils/lingua | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8b44fc2..b70e5d4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "tsc", "start": "node build/index.js", - "dev": "rm -r build && npm run build && npm run start" + "dev": "rm -r build && npm run build && npm run start", + "update:subs": "git submodule update --remote" }, "repository": { "type": "git", diff --git a/src/events/message.ts b/src/events/message.ts index ac52b08..769a148 100644 --- a/src/events/message.ts +++ b/src/events/message.ts @@ -6,6 +6,7 @@ import { Server, Usage } from "../utils/types"; import config from "../../config"; import { Commands, Shortlink, SourceFinder } from "../utils/wrapper.features"; import lingua from "../utils/lingua"; +import replace from "../utils/replace"; export = { name: "message", @@ -57,7 +58,6 @@ export = { const command = args.shift()?.toLowerCase() const cmd = client.commands.find((c) => (c.name as string).toLowerCase() == command || (c.aliases && c.aliases.includes(command))) - console.log(cmd) if (!cmd) return; if (!client.cooldowns.has(cmd.name)) { @@ -65,15 +65,24 @@ export = { } const ctx = { - client, guild: message.guild, message, channel: message.channel, supabase, config, isDeveloper: config.developers.includes(message.author.id) + client, + guild: message.guild, + message, channel: message.channel, + author: message.author, + member: message.member, + supabase, + config, + isDeveloper: config.developers.find(dev => dev.id === message.author.id) } + // ! Override Command Restrictions if Message Author is on list of Developers + // if (ctx.isDeveloper) cmd.AuthorPermissions = "NONE" - if (ctx.isDeveloper) cmd.AuthorPermissions = "NONE" - - console.log(ctx.isDeveloper) + // ! If Command is NSFW and channel is not marked as such, return if (cmd.nsfw && !ctx.channel.nsfw) return ctx.channel.send( lingua["en_US"].CHANNEL_NOT_NSFW ) + if (cmd.AuthorPermissions !== "NONE" && ctx.member?.permissions.has(cmd.AuthorPermissions)) return ctx.channel.send(replace(/PERMISSIONS/gm, cmd.AuthorPermissions.join(", "), lingua["en_US"].INSUFFICIENT_PERMISSIONS)) + } } \ No newline at end of file diff --git a/src/modules/general/info.ts b/src/modules/general/info.ts index 15b14fc..493b2cc 100644 --- a/src/modules/general/info.ts +++ b/src/modules/general/info.ts @@ -8,7 +8,7 @@ export = class Info extends Command { aliases: ["about"], // module: "General", cooldown: 0, - guildOnly: false, + AuthorPermissions: ["MANAGE_GUILD"], dev: false }) } diff --git a/src/utils/lingua b/src/utils/lingua index 135a6a4..227b467 160000 --- a/src/utils/lingua +++ b/src/utils/lingua @@ -1 +1 @@ -Subproject commit 135a6a484f9dfff34f034f10474162cf9b51fea7 +Subproject commit 227b46726a7d2071dc6b73019aaffbe4fbfa2d21