From ae84016035f2122d4ecc7de5fa76213f08cf8532 Mon Sep 17 00:00:00 2001 From: Freslin <160232566+Freslin@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:56:59 +0530 Subject: [PATCH 1/2] Added Slash Block Code --- .../js/discord.js/Interactions/Slash/index.ts | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts diff --git a/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts b/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts new file mode 100644 index 0000000..f8647b0 --- /dev/null +++ b/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts @@ -0,0 +1,180 @@ +import { BlockShape, InputShape, OutputType } from "$lib/utils/blockRegistryTool"; +import {MutatorType} from "$lib/interfaces/mutator"; + +class SlashCommands { + getRegistry() { + return { + id: "SlashCommands", + name: "Slash Commands", + color: "#be4fff", + weight: 6, + blocks: [ + { + func: "ReceiveSlashCommand", + text: "When a slash command is received \n", + inline: false, + color: "#ffab19", + shape: BlockShape.EVENT, + branches: 1 + }, + { + func: "SlashCommandProps", + text: "[PROPERTIES]", + output: [OutputType.STRING, OutputType.DISCORD.MEMBER, OutputType.DISCORD.CHANNEL, OutputType.DISCORD.SERVER].flat(), + arguments: { + PROPERTIES: { + type: InputShape.MENU, + options: [ + ['Interaction Name', 'interaction.CommandName'], + ['Interaction Member', 'interaction.member'], + ['Interaction User', 'interaction.user'], + ['Interaction Channel', 'interaction.channel'], + ['Interaction Server', 'interaction.guild'], + ['Interaction Member Voice Channel', 'interaction.member.voice.channel'], + ['Bot Voice Channel ID', 'interaction.guild.me.voice.ChannelID'] + ] + } + } + }, + { + func: "GetSlashStuff", + text: "Get option [OPTION] with name [NAME]", + output: OutputType.ANY, + arguments: { + NAME: { + type: InputShape.VALUE, + check: OutputType.STRING + }, + OPTION: { + type: InputShape.MENU, + options: [ + ['string', 'string'], + ['integer', 'integer'], + ['boolean', 'boolean'], + ['user', 'user'], + ['member', 'member'], + ['channel', 'channel'], + ['role', 'role'], + ['subcommand', 'subcommand'], + ['subcommand group', 'subcommand group'], + ['attachement', 'attachement'] + ] + } + } + }, + { + func: "AdvancedAttachement", + text: "[TYPE] of attachement option with name [NAME]", + output: OutputType.ANY, + arguments: { + NAME: { + type: InputShape.VALUE, + check: OutputType.STRING, + }, + TYPE: { + type: InputShape.MENU, + options: [ + ['URL', 'url'], + ['File Name', 'File Name'], + ['File ID', 'File ID'], + ['Proxy URL', 'Proxy URL'], + ['Content Type', 'Content Type'] + ] + } + } + }, + { + func: "AttachementSize", + text: "[TYPE] of attachement option with name [NAME]", + output: OutputType.ANY, + arguments: { + NAME: { + type: InputShape.VALUE, + check: OutputType.STRING + }, + TYPE: { + type: InputShape.MENU, + options: [ + ['Height', 'height'], + ['Width', 'width'] + ] + } + } + }, + { + func: "InteractionReply", + text: "Interaction Reply: Ephemeral [EPH]", + color: "#4C97FF", + shape: BlockShape.STATEMENT, + arguments: { + EPH: { + type: InputShape.VALUE, + check: OutputType.BOOLEAN + } + }, + mutator: "ReplyOptions", + mutatorData: { + type: MutatorType.CheckBox, + inputs: [ + { + text: "Content", + type: OutputType.STRING, + defaultValue: true, + }, + { + text: "Embed", + type: OutputType.ANY, + defaultValue: false + }, + { + text: "Attachement", + type: OutputType.ANY, + defaultValue: false + }, + { + text: "Button/Menu Row", + type: OutputType.ANY, + defaultValue: false + } + ] + } + + }, + { + func: "InteractionReplyEdit", + text: "Edit Reply:", + color: "#4C97FF", + shape: BlockShape.STATEMENT, + mutator: "ReplyOptions", + mutatorData: { + type: MutatorType.CheckBox, + inputs: [ + { + text: "Content", + type: OutputType.STRING, + defaultValue: true, + }, + { + text: "Embed", + type: OutputType.ANY, + defaultValue: false + }, + { + text: "Attachement", + type: OutputType.ANY, + defaultValue: false + }, + { + text: "Button/Menu Row", + type: OutputType.ANY, + defaultValue: false + } + ] + } + + } + ] + }; + } +} +export default SlashCommands; From 5b278cedbee109169018765a908dbdcead6cfdd6 Mon Sep 17 00:00:00 2001 From: Freslin <160232566+Freslin@users.noreply.github.com> Date: Fri, 29 Mar 2024 22:12:28 +0530 Subject: [PATCH 2/2] Update index.ts --- .../blockly/blocks/js/discord.js/Interactions/Slash/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts b/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts index f8647b0..ca84f03 100644 --- a/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts +++ b/app/src/lib/blockly/blocks/js/discord.js/Interactions/Slash/index.ts @@ -1,5 +1,4 @@ -import { BlockShape, InputShape, OutputType } from "$lib/utils/blockRegistryTool"; -import {MutatorType} from "$lib/interfaces/mutator"; +import { BlockShape, InputShape, MutatorType, OutputType } from "$lib/utils/constants"; class SlashCommands { getRegistry() {