From cde456f913b73f865a12eeef236d8b6ec66289e5 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Wed, 9 Aug 2023 11:48:58 +0200 Subject: [PATCH] limited test command system --- commands/message/core/help.js | 2 ++ commands/message/fun/chat.js | 9 +++++---- commands/message/fun/disstrack.js | 15 ++++++++------- commands/message/utils/testing.js | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 commands/message/utils/testing.js diff --git a/commands/message/core/help.js b/commands/message/core/help.js index 447515c..9b8d08a 100644 --- a/commands/message/core/help.js +++ b/commands/message/core/help.js @@ -7,6 +7,7 @@ const { paginator } = require('../../../labscore/client'); const { editOrReply } = require('../../../labscore/utils/message'); const { Permissions } = require("detritus-client/lib/constants"); +const { canUseLimitedTestCommands } = require('../utils/testing'); function createHelpPage(context, title, contents, descriptions){ return { @@ -113,6 +114,7 @@ module.exports = { }, permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], run: async (context, args) => { + if(canUseLimitedTestCommands(context)) categories["limited"] = `${icon("fun")} Limited Test Commands`; if(args.command){ await context.triggerTyping() // Detailed command view diff --git a/commands/message/fun/chat.js b/commands/message/fun/chat.js index 6b2c12c..249e217 100644 --- a/commands/message/fun/chat.js +++ b/commands/message/fun/chat.js @@ -3,23 +3,24 @@ const { format } = require('../../../labscore/utils/ansi') const { editOrReply } = require('../../../labscore/utils/message') const superagent = require('superagent') -const { codeblock } = require('../../../labscore/utils/markdown') +const { codeblock, iconPill } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); +const { canUseLimitedTestCommands } = require('../utils/testing') module.exports = { name: 'chat', label: 'text', metadata: { - description: `Talk to ChatGPT.\n\n<:bonzi:1138585089891106836> He will explore the Internet with you as your very own friend and sidekick! He can talk, walk, and joke like no other friend you've ever had!`, + description: `${iconPill("fun", "LIMITED TESTING")}\n\nTalk to ChatGPT.\n\n<:bonzi:1138585089891106836> He will explore the Internet with you as your very own friend and sidekick! He can talk, walk, and joke like no other friend you've ever had!`, description_short: 'Talk to ChatGPT.', examples: ['chat How many otter species are there?'], - category: 'hidden', + category: 'limited', usage: 'chat ' }, permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], run: async (context, args) => { - if(!process.env.TESTING_SERVER_IDS.split(';').includes(context.guild.id)) return; + if(!canUseLimitedTestCommands(context)) return; context.triggerTyping(); if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]}) try{ diff --git a/commands/message/fun/disstrack.js b/commands/message/fun/disstrack.js index 9666176..f6663f4 100644 --- a/commands/message/fun/disstrack.js +++ b/commands/message/fun/disstrack.js @@ -3,23 +3,24 @@ const { format } = require('../../../labscore/utils/ansi') const { editOrReply } = require('../../../labscore/utils/message') const superagent = require('superagent') -const { codeblock } = require('../../../labscore/utils/markdown') +const { codeblock, iconPill } = require('../../../labscore/utils/markdown') const { Permissions } = require("detritus-client/lib/constants"); +const { canUseLimitedTestCommands } = require('../utils/testing') module.exports = { name: 'disstrack', label: 'text', metadata: { - description: `Talk to ChatGPT.\n\n<:bonzi:1138585089891106836> He will explore the Internet with you as your very own friend and sidekick! He can talk, walk, and joke like no other friend you've ever had!`, - description_short: 'Talk to ChatGPT.', - examples: ['chat How many otter species are there?'], - category: 'hidden', - usage: 'chat ' + description: `${iconPill("fun", "LIMITED TESTING")}\n\nAI Generated Disstracks, powered by ChatGPT`, + description_short: 'AI generated disstracks.', + examples: ['disstrack'], + category: 'limited', + usage: 'disstrack ' }, permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.READ_MESSAGE_HISTORY], run: async (context, args) => { - if(!process.env.TESTING_SERVER_IDS.split(';').includes(context.guild.id)) return; + if(!canUseLimitedTestCommands(context)) return; context.triggerTyping(); if(!args.text) return editOrReply(context, {embeds:[createEmbed("warning", context, `Missing Parameter (text).`)]}) try{ diff --git a/commands/message/utils/testing.js b/commands/message/utils/testing.js new file mode 100644 index 0000000..91a9eb1 --- /dev/null +++ b/commands/message/utils/testing.js @@ -0,0 +1,19 @@ + +// Get Test Config +let LIMITED_TEST_GUILDS; +if(process.env.TESTING_SERVER_IDS) LIMITED_TEST_GUILDS = process.env.TESTING_SERVER_IDS.split(';') +let LIMITED_TEST_CHANNELS; +if(process.env.TESTING_CHANNEL_IDS) LIMITED_TEST_CHANNELS = process.env.TESTING_CHANNEL_IDS.split(';') +let LIMITED_TEST_USERS; +if(process.env.TESTING_USER_IDS) LIMITED_TEST_USERS = process.env.TESTING_USER_IDS.split(';') + +function canUseLimitedTestCommands(context){ + if(LIMITED_TEST_GUILDS && LIMITED_TEST_GUILDS.includes(context.guild.id)) return true; + if(LIMITED_TEST_CHANNELS && LIMITED_TEST_CHANNELS.includes(context.channel.id)) return true; + if(LIMITED_TEST_USERS && LIMITED_TEST_USERS.includes(context.user.id)) return true; + return false; +} + +module.exports = { + canUseLimitedTestCommands +} \ No newline at end of file