diff --git a/src/App.vue b/src/App.vue index bb11abca0..18873ce8b 100755 --- a/src/App.vue +++ b/src/App.vue @@ -21,6 +21,10 @@ import "./blocks/discord/message-event/"; import "./blocks/discord/join-event/"; import "./blocks/discord/leave-event/"; import "./blocks/discord/reaction-event/"; +import "./blocks/discord/edited-event/"; +import "./blocks/discord/thread-event"; +import "./blocks/discord/direct"; +import "./blocks/discord/slash"; import "./blocks/discord/channels/"; import "./blocks/discord/servers/"; diff --git a/src/blocks/discord/channels/channel_category.js b/src/blocks/discord/channels/channel_category.js new file mode 100644 index 000000000..18361e5c8 --- /dev/null +++ b/src/blocks/discord/channels/channel_category.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_channel_category"; + +const blockData = { + "message0": "%{BKY_CHANNEL_CATEGORY}", + "args0": [ + { + "type": "input_value", + "name": "CHANNEL", + "check": "Channel" + } + ], + "colour": "#50a6c9", + "output": "Category", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC); + return [ `${channel}.parent`, Blockly.JavaScript.ORDER_NONE ]; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_VALID_CHANNEL", + types: [ + "CHANNEL" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/channels/index.js b/src/blocks/discord/channels/index.js index 154ca2f09..5faae8ec5 100644 --- a/src/blocks/discord/channels/index.js +++ b/src/blocks/discord/channels/index.js @@ -3,3 +3,5 @@ import "./get_channel"; import "./send_channel"; import "./send_wait_reply"; import "./send_wait_reply_value"; +import "./start_typing"; +import "./channel_category"; diff --git a/src/blocks/discord/channels/send_channel.js b/src/blocks/discord/channels/send_channel.js index c7a66b4fa..901977b98 100644 --- a/src/blocks/discord/channels/send_channel.js +++ b/src/blocks/discord/channels/send_channel.js @@ -9,15 +9,21 @@ const blockData = { { "type": "input_value", "name": "CONTENT", - "check": [ "MessageEmbed", "String", "Number" ] + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" }, { "type": "input_value", "name": "CHANNEL", "check": "Channel" - }, + } ], "colour": "#4C97FF", + "inputsInline": false, "previousStatement": null, "nextStatement": null, "tooltip": "", @@ -31,38 +37,22 @@ Blockly.Blocks[blockName] = { }; Blockly.JavaScript[blockName] = function(block){ - const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC); const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); - if(block.getInput("CONTENT").connection.targetConnection){ - const contentType = block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_ ? - block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_[0] : - null; - if((contentType === "MessageEmbed") || (!contentType && typeof contentType === "object")){ - const code = `${channel}.send(${content});\n`; - return code; - } else { - const code = `${channel}.send(String(${content}));\n`; - return code; - } + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(content.length > 2){ + return(`${channel}.send({embeds: ${embed}, content: ${content}});\n`) } else { - const code = `${channel}.send(String(${content}));\n`; - return code; + return(`${channel}.send({embeds: ${embed}});\n`) } -}; +} registerRestrictions(blockName, [ { type: "notempty", - message: "RES_SEND_CHANNEL_CONTENT", - types: [ - "CONTENT" - ] - }, - { - type: "notempty", - message: "RES_SEND_CHANNEL_CHANNEL", + message: "RES_MISSING_CONTENT", types: [ - "CHANNEL" + "CONTENT" ] } ]); diff --git a/src/blocks/discord/channels/start_typing.js b/src/blocks/discord/channels/start_typing.js new file mode 100644 index 000000000..3aade3dae --- /dev/null +++ b/src/blocks/discord/channels/start_typing.js @@ -0,0 +1,46 @@ + +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_start_typing"; + +const blockData = { + "message0": "%{BKY_START_TYPING}", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_value", + "name": "CHANNEL", + "check": "Channel" + } + ], + "colour": "#4C97FF", + "tooltip": "Will type in channel for 3 seconds", + "helpUrl": "", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC); + return `${channel}.sendTyping();\n`; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_VALID_MEMBER", + types: [ + "CHANNEL" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/direct/direct_author_raw.js b/src/blocks/discord/direct/direct_author_raw.js new file mode 100644 index 000000000..29ac3625b --- /dev/null +++ b/src/blocks/discord/direct/direct_author_raw.js @@ -0,0 +1,69 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_author_raw"; + +const blockData = { + "message0": "%{BKY_DIRECT_AUTHOR_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_USERNAME}", + "USERNAME" + ], + [ + "%{BKY_DISCRIMINATOR}", + "DISCRIMINATOR" + ], + [ + "id", + "ID" + ], + [ + "%{BKY_TAG}", + "TAG" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["s4dmessage.author.id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "USERNAME"){ + const code = ["s4dmessage.author.username", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "DISCRIMINATOR"){ + const code = ["s4dmessage.author.discriminator", Blockly.JavaScript.ORDER_NONE]; + return code; + }else if(searchType === "TAG"){ + const code = ["s4dmessage.author.tag", Blockly.JavaScript.ORDER_NONE]; + return code + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_bot.js b/src/blocks/discord/direct/direct_bot.js new file mode 100644 index 000000000..7e8401e0e --- /dev/null +++ b/src/blocks/discord/direct/direct_bot.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_bot"; + +const blockData = { + "message0": "%{BKY_DIRECT_BOT}", + "colour": "#5B80A5", + "tooltip": "", + "output": "Boolean", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dmessage.author.bot", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_DIRECT", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_content.js b/src/blocks/discord/direct/direct_content.js new file mode 100644 index 000000000..579c95943 --- /dev/null +++ b/src/blocks/discord/direct/direct_content.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_content"; + +const blockData = { + "message0": "%{BKY_DIRECT_CONTENT}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dmessage.content", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_DIRECT", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_id.js b/src/blocks/discord/direct/direct_id.js new file mode 100644 index 000000000..a0e48a89d --- /dev/null +++ b/src/blocks/discord/direct/direct_id.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_id"; + +const blockData = { + "message0": "%{BKY_DIRECT_ID}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dmessage.id", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_DIRECT", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_react.js b/src/blocks/discord/direct/direct_react.js new file mode 100644 index 000000000..5a15f648f --- /dev/null +++ b/src/blocks/discord/direct/direct_react.js @@ -0,0 +1,49 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_reaction"; + +const blockData = { + "message0": "%{BKY_DIRECT_REACTION}", + "args0": [ + { + "type": "input_value", + "name": "REACTION", + "check": "String" + } + ], + "previousStatement": null, + "nextStatement": null, + "colour": "#4C97FF", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const reaction = Blockly.JavaScript.valueToCode(block, "REACTION", Blockly.JavaScript.ORDER_ATOMIC); + const code = `s4dmessage.react(${reaction});`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_ADD_REACTION_MISSING_REACTION", + types: [ + "REACTION" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_remove.js b/src/blocks/discord/direct/direct_remove.js new file mode 100644 index 000000000..48435f820 --- /dev/null +++ b/src/blocks/discord/direct/direct_remove.js @@ -0,0 +1,34 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_delete"; + +const blockData = { + "message0": "%{BKY_DELETE_DIRECT}", + "colour": "#4C97FF", + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(){ + const code = `s4dmessage.delete();\n`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/direct_reply.js b/src/blocks/discord/direct/direct_reply.js new file mode 100644 index 000000000..5ec486ce4 --- /dev/null +++ b/src/blocks/discord/direct/direct_reply.js @@ -0,0 +1,72 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_direct_reply"; + +const blockData = { + "message0": "%{BKY_DIRECT_REPLY}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "MENTION", + "check": "Boolean" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const mention = Blockly.JavaScript.valueToCode(block, "MENTION", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(mention === "true") { + if(content.length > 2){ + return(`s4dmessage.reply({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`s4dmessage.reply({embeds: ${embed}});\n`) + } + }else { + if(content.length > 2){ + return(`s4dmessage.channel.send({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`s4dmessage.channel.send({embeds: ${embed}});\n`) + } + }} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_DIRECT", + types: [ + "s4d_on_direct" + ] + } +]); diff --git a/src/blocks/discord/direct/index.js b/src/blocks/discord/direct/index.js new file mode 100644 index 000000000..5dfbbd13c --- /dev/null +++ b/src/blocks/discord/direct/index.js @@ -0,0 +1,8 @@ +import "./on_direct"; +import "./direct_reply"; +import "./direct_content"; +import "./direct_id"; +import "./direct_author_raw"; +import "./direct_bot"; +import "./direct_remove"; +import "./direct_react"; diff --git a/src/blocks/discord/direct/on_direct.js b/src/blocks/discord/direct/on_direct.js new file mode 100644 index 000000000..366db48e4 --- /dev/null +++ b/src/blocks/discord/direct/on_direct.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_direct"; + +const blockData = { + "message0": "%{BKY_ON_DIRECT} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('messageCreate', async (s4dmessage) => {\nif(s4dmessage.channel.type === "DM"){\n${statements}\n}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/edited-event/edited_author.js b/src/blocks/discord/edited-event/edited_author.js new file mode 100644 index 000000000..0c57ca326 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_author.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_author"; + +const blockData = { + "message0": "%{BKY_EDITED_AUTHOR}", + "colour": "#187795", + "output": "Member", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["newMessage.member", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_author_raw.js b/src/blocks/discord/edited-event/edited_author_raw.js new file mode 100644 index 000000000..4fdbf3988 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_author_raw.js @@ -0,0 +1,62 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_author_raw"; + +const blockData = { + "message0": "%{BKY_EDITED_AUTHOR_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_USERNAME}", + "USERNAME" + ], + [ + "%{BKY_NICKNAME}", + "NICKNAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["newMessage.author.id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "USERNAME"){ + const code = ["newMessage.author.username", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NICKNAME"){ + const code = ["(newMessage.member || await newMessage.guild.members.fetch(newMessage.author.id)).nickname", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_channel.js b/src/blocks/discord/edited-event/edited_channel.js new file mode 100644 index 000000000..77f64fbb3 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_channel.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_channel"; + +const blockData = { + "message0": "%{BKY_EDITED_MESSAGE_CHANNEL}", + "colour": "#a55b80", + "output": "Channel", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["newMessage.channel", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_channel_raw.js b/src/blocks/discord/edited-event/edited_channel_raw.js new file mode 100644 index 000000000..22a6ca6ff --- /dev/null +++ b/src/blocks/discord/edited-event/edited_channel_raw.js @@ -0,0 +1,55 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_channel_raw"; + +const blockData = { + "message0": "%{BKY_EDITED_CHANNEL_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_NAME}", + "NAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["(newMessage.channel || {}).id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NAME"){ + const code = ["(newMessage.channel || {}).name", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_delete.js b/src/blocks/discord/edited-event/edited_delete.js new file mode 100644 index 000000000..ffe750231 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_delete.js @@ -0,0 +1,34 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_delete"; + +const blockData = { + "message0": "%{BKY_DELETE_EDITED_MESSAGE}", + "colour": "#4C97FF", + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(){ + const code = `newMessage.delete();\n`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_guild_raw.js b/src/blocks/discord/edited-event/edited_guild_raw.js new file mode 100644 index 000000000..e6beafdcf --- /dev/null +++ b/src/blocks/discord/edited-event/edited_guild_raw.js @@ -0,0 +1,55 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_guild_raw"; + +const blockData = { + "message0": "%{BKY_EDITED_GUILD_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_NAME}", + "NAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["(newMessage.guild || {}).id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NAME"){ + const code = ["(newMessage.guild || {}).name", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_id.js b/src/blocks/discord/edited-event/edited_id.js new file mode 100644 index 000000000..ab775c886 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_id.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_id"; + +const blockData = { + "message0": "%{BKY_EDITED_ID}", + "colour": "#5BA58C", + "output": "String", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["newMessage.id", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_reaction.js b/src/blocks/discord/edited-event/edited_reaction.js new file mode 100644 index 000000000..0b7381e0c --- /dev/null +++ b/src/blocks/discord/edited-event/edited_reaction.js @@ -0,0 +1,49 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_add_edited_reaction"; + +const blockData = { + "message0": "%{BKY_ADD_REACTION}", + "args0": [ + { + "type": "input_value", + "name": "REACTION", + "check": "String" + } + ], + "previousStatement": null, + "nextStatement": null, + "colour": "#4C97FF", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const reaction = Blockly.JavaScript.valueToCode(block, "REACTION", Blockly.JavaScript.ORDER_ATOMIC); + const code = `newMessage.react(${reaction});`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_ADD_REACTION_MISSING_REACTION", + types: [ + "REACTION" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_reply.js b/src/blocks/discord/edited-event/edited_reply.js new file mode 100644 index 000000000..dd4c01a61 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_reply.js @@ -0,0 +1,72 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_reply"; + +const blockData = { + "message0": "%{BKY_EDITED_REPLY}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "MENTION", + "check": "Boolean" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const mention = Blockly.JavaScript.valueToCode(block, "MENTION", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(mention === "true") { + if(content.length > 2){ + return(`newMessage.reply({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`newMessage.reply({embeds: ${embed}});\n`) + } + }else { + if(content.length > 2){ + return(`newMessage.channel.send({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`newMessage.channel.send({embeds: ${embed}});\n`) + } + }} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/edited_server.js b/src/blocks/discord/edited-event/edited_server.js new file mode 100644 index 000000000..7c689fa14 --- /dev/null +++ b/src/blocks/discord/edited-event/edited_server.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_server"; + +const blockData = { + "message0": "%{BKY_EDITED_GUILD}", + "colour": "#D85E47", + "output": "Server", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["newMessage.guild", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/index.js b/src/blocks/discord/edited-event/index.js new file mode 100644 index 000000000..fe85386dc --- /dev/null +++ b/src/blocks/discord/edited-event/index.js @@ -0,0 +1,15 @@ +import("./on_edited"); +import("./new_content"); +import("./old_content"); +import("./edited_author"); +import("./edited_server"); +import("./edited_id"); +import("./new_edited_mentioned_member"); +import("./edited_delete"); +import("./edited_reply"); +import("./edited_reaction"); +import("./old_edited_mentioned_member"); +import("./edited_channel"); +import("./edited_author_raw"); +import("./edited_channel_raw"); +import("./edited_guild_raw"); diff --git a/src/blocks/discord/edited-event/new_content.js b/src/blocks/discord/edited-event/new_content.js new file mode 100644 index 000000000..3de6c7bde --- /dev/null +++ b/src/blocks/discord/edited-event/new_content.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_new_content"; + +const blockData = { + "message0": "%{BKY_NEW_CONTENT}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["newMessage.content", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/new_edited_mentioned_member.js b/src/blocks/discord/edited-event/new_edited_mentioned_member.js new file mode 100644 index 000000000..8db301e1e --- /dev/null +++ b/src/blocks/discord/edited-event/new_edited_mentioned_member.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_new_mentioned_member"; + +const blockData = { + "message0": "%{BKY_NEW_EDITED_MENTIONED_MEMBER}", + "colour": "#187795", + "tooltip": "", + "output": "Member", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = [`newMessage.mentions.members.first()`, Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/old_content.js b/src/blocks/discord/edited-event/old_content.js new file mode 100644 index 000000000..997a1dc39 --- /dev/null +++ b/src/blocks/discord/edited-event/old_content.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_old_content"; + +const blockData = { + "message0": "%{BKY_OLD_CONTENT}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["oldMessage.content", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/old_edited_mentioned_member.js b/src/blocks/discord/edited-event/old_edited_mentioned_member.js new file mode 100644 index 000000000..a705a6690 --- /dev/null +++ b/src/blocks/discord/edited-event/old_edited_mentioned_member.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_edited_old_mentioned_member"; + +const blockData = { + "message0": "%{BKY_OLD_EDITED_MENTIONED_MEMBER}", + "colour": "#187795", + "tooltip": "", + "output": "Member", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = [`oldMessage.mentions.members.first()`, Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_edited" + ] + } +]); diff --git a/src/blocks/discord/edited-event/on_edited.js b/src/blocks/discord/edited-event/on_edited.js new file mode 100644 index 000000000..4499badd7 --- /dev/null +++ b/src/blocks/discord/edited-event/on_edited.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_edited"; + +const blockData = { + "message0": "%{BKY_ON_EDITED} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('messageUpdate', async(oldMessage, newMessage) => {\n${statements}\n});\n`; + return code; +}; \ No newline at end of file diff --git a/src/blocks/discord/join-event/joining_guild.js b/src/blocks/discord/join-event/joining_guild.js index 7b0ef11aa..a8120859b 100644 --- a/src/blocks/discord/join-event/joining_guild.js +++ b/src/blocks/discord/join-event/joining_guild.js @@ -18,7 +18,7 @@ Blockly.Blocks[blockName] = { }; Blockly.JavaScript[blockName] = function() { - const code = ["s4d.joiningMember.guild", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.guild", Blockly.JavaScript.ORDER_NONE]; return code; }; diff --git a/src/blocks/discord/join-event/joining_guild_raw.js b/src/blocks/discord/join-event/joining_guild_raw.js index 2ce41dd63..87fba5472 100644 --- a/src/blocks/discord/join-event/joining_guild_raw.js +++ b/src/blocks/discord/join-event/joining_guild_raw.js @@ -36,10 +36,10 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block) { const searchType = block.getFieldValue("SEARCH_TYPE"); if(searchType === "ID"){ - const code = ["s4d.joiningMember.guild.id", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.guild.id", Blockly.JavaScript.ORDER_NONE]; return code; } else if(searchType === "NAME"){ - const code = ["s4d.joiningMember.guild.name", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.guild.name", Blockly.JavaScript.ORDER_NONE]; return code; } }; diff --git a/src/blocks/discord/join-event/joining_member.js b/src/blocks/discord/join-event/joining_member.js index a9a98d35b..a46c1ab94 100644 --- a/src/blocks/discord/join-event/joining_member.js +++ b/src/blocks/discord/join-event/joining_member.js @@ -18,7 +18,7 @@ Blockly.Blocks[blockName] = { }; Blockly.JavaScript[blockName] = function() { - const code = ["s4d.joiningMember", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember", Blockly.JavaScript.ORDER_NONE]; return code; }; diff --git a/src/blocks/discord/join-event/joining_member_raw.js b/src/blocks/discord/join-event/joining_member_raw.js index 2b8e59ca1..7a8b19644 100644 --- a/src/blocks/discord/join-event/joining_member_raw.js +++ b/src/blocks/discord/join-event/joining_member_raw.js @@ -40,13 +40,13 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block) { const searchType = block.getFieldValue("SEARCH_TYPE"); if(searchType === "ID"){ - const code = ["s4d.joiningMember.id", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.id", Blockly.JavaScript.ORDER_NONE]; return code; } else if(searchType === "USERNAME"){ - const code = ["s4d.joiningMember.user.username", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.user.username", Blockly.JavaScript.ORDER_NONE]; return code; } else if(searchType === "NICKNAME"){ - const code = ["s4d.joiningMember.nickname", Blockly.JavaScript.ORDER_NONE]; + const code = ["s4dJoiningMember.nickname", Blockly.JavaScript.ORDER_NONE]; return code; } }; diff --git a/src/blocks/discord/join-event/on_member_join.js b/src/blocks/discord/join-event/on_member_join.js index f85a64e0f..30a7996c4 100644 --- a/src/blocks/discord/join-event/on_member_join.js +++ b/src/blocks/discord/join-event/on_member_join.js @@ -24,6 +24,6 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block) { const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); - const code = `s4d.client.on('guildMemberAdd', async (param1) => {\ns4d.joiningMember = param1;\n${statements}s4d.joiningMember = null\n});\n`; + const code = `s4d.client.on('guildMemberAdd', async (s4dJoiningMember) => {\n${statements}\n});\n`; return code; }; diff --git a/src/blocks/discord/members/index.js b/src/blocks/discord/members/index.js index b92edb6ee..7e149ef29 100644 --- a/src/blocks/discord/members/index.js +++ b/src/blocks/discord/members/index.js @@ -9,3 +9,5 @@ import "./member_tag"; import "./member_username"; import "./send_message"; import "./set_member_nickname"; +import "./member_status"; +import "./member_is_streaming"; diff --git a/src/blocks/discord/members/member_is_streaming.js b/src/blocks/discord/members/member_is_streaming.js new file mode 100644 index 000000000..2e64699fe --- /dev/null +++ b/src/blocks/discord/members/member_is_streaming.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_member_streaming"; + +const blockData = { + "message0": "%{BKY_MEMBER_IS_STREAMING}", + "args0": [ + { + "type": "input_value", + "name": "MEMBER", + "check": "Member" + } + ], + "colour": "#5B80A5", + "output": "Boolean", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const member = Blockly.JavaScript.valueToCode(block, "MEMBER", Blockly.JavaScript.ORDER_ATOMIC); + return [ `${member}.presence ? ${member}.presence.activities[0] ? ${member}.presence.activities[0].type === "STREAMING" : false : false`, Blockly.JavaScript.ORDER_NONE ]; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_VALID_MEMBER", + types: [ + "MEMBER" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/members/member_status.js b/src/blocks/discord/members/member_status.js new file mode 100644 index 000000000..90df6925e --- /dev/null +++ b/src/blocks/discord/members/member_status.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_member_status"; + +const blockData = { + "message0": "%{BKY_MEMBER_STATUS}", + "args0": [ + { + "type": "input_value", + "name": "MEMBER", + "check": "Member" + } + ], + "colour": "#50a6c9", + "output": "String", + "tooltip": "Get status of member. (May return online, offline, idle, dnd)", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const member = Blockly.JavaScript.valueToCode(block, "MEMBER", Blockly.JavaScript.ORDER_ATOMIC); + return [ `${member}.presence ? ${member}.presence.status : 'offline'`, Blockly.JavaScript.ORDER_NONE ]; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_VALID_MEMBER", + types: [ + "MEMBER" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/members/send_message.js b/src/blocks/discord/members/send_message.js index fff553005..5b36ed0e3 100644 --- a/src/blocks/discord/members/send_message.js +++ b/src/blocks/discord/members/send_message.js @@ -9,7 +9,12 @@ const blockData = { { "type": "input_value", "name": "CONTENT", - "check": [ "MessageEmbed", "String", "Number" ] + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" }, { "type": "input_value", @@ -32,21 +37,12 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block) { const member = Blockly.JavaScript.valueToCode(block, "MEMBER", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); - if(block.getInput("CONTENT").connection.targetConnection){ - const contentType = block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_ ? - block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_[0] : - null; - if((contentType === "MessageEmbed") || (!contentType && typeof contentType === "object")){ - const code = `${member}.send(${content});\n`; - return code; - } else { - const code = `${member}.send(String(${content}));\n`; - return code; - } + if(content.length > 2){ + return(`${member}.send({embeds: ${embed}, content: ${content}});\n`) } else { - const code = `${member}.send(String(${content}));\n`; - return code; + return(`${member}.send({embeds: ${embed}});\n`) } }; diff --git a/src/blocks/discord/message-event/index.js b/src/blocks/discord/message-event/index.js index cd3c22954..f227ba6d3 100644 --- a/src/blocks/discord/message-event/index.js +++ b/src/blocks/discord/message-event/index.js @@ -12,4 +12,7 @@ import "./message_guild"; import "./message_guild_raw"; import "./on_message"; import "./reply"; -import "./purge"; \ No newline at end of file +import "./purge"; +import "./reference_reply"; +import "./message_start_thread"; +import "./started_thread"; \ No newline at end of file diff --git a/src/blocks/discord/message-event/mentioned_member.js b/src/blocks/discord/message-event/mentioned_member.js index d4caf35f5..48fa50f7d 100644 --- a/src/blocks/discord/message-event/mentioned_member.js +++ b/src/blocks/discord/message-event/mentioned_member.js @@ -18,7 +18,7 @@ Blockly.Blocks[blockName] = { }; Blockly.JavaScript[blockName] = function() { - const code = [`s4dmessage.mentions.members.first()`, Blockly.JavaScript.ORDER_NONE]; + const code = [`oldMessage.mentions.members.first()`, Blockly.JavaScript.ORDER_NONE]; return code; }; diff --git a/src/blocks/discord/message-event/message_embed.js b/src/blocks/discord/message-event/message_embed.js index 4306f9f13..216fe364b 100644 --- a/src/blocks/discord/message-event/message_embed.js +++ b/src/blocks/discord/message-event/message_embed.js @@ -91,17 +91,13 @@ Blockly.Extensions.registerMutator("s4d_message_embed_mutator", BORDER_MUTATOR_M Blockly.JavaScript["s4d_message_embed"] = function(block){ return [ ` - { - embed: { + [{ title: ${Blockly.JavaScript.valueToCode(block, "TITLE", Blockly.JavaScript.ORDER_ATOMIC) || null}, color: ${Blockly.JavaScript.valueToCode(block, "COLOR", Blockly.JavaScript.ORDER_ATOMIC) || null}, image: { url: ${Blockly.JavaScript.valueToCode(block, "IMAGE", Blockly.JavaScript.ORDER_ATOMIC) || null} }, - description: ${Blockly.JavaScript.valueToCode(block, "MESSAGE", Blockly.JavaScript.ORDER_ATOMIC) || null}, footer: { text: ${Blockly.JavaScript.valueToCode(block, "FOOTER", Blockly.JavaScript.ORDER_ATOMIC) || null} }, thumbnail: { url: ${Blockly.JavaScript.valueToCode(block, "THUMBNAIL", Blockly.JavaScript.ORDER_ATOMIC) || null} } - - } - } + }] `, Blockly.JavaScript.ORDER_ATOMIC ]; }; \ No newline at end of file diff --git a/src/blocks/discord/message-event/message_start_thread.js b/src/blocks/discord/message-event/message_start_thread.js new file mode 100644 index 000000000..9cba4111a --- /dev/null +++ b/src/blocks/discord/message-event/message_start_thread.js @@ -0,0 +1,94 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_message_start_thread"; + +const blockData = { + "message0": "%{BKY_MESSAGE_CREATE_THREAD}", + "args0": [ + { + "type": "input_value", + "name": "NAME", + "check": "String" + }, + { + "type": "field_dropdown", + "name": "ARCHIVE", + "options": [ + [ + "%{BKY_THREAD_HOUR}", + "60" + ], + [ + "%{BKY_THREAD_DAY}", + "1440" + ], + [ + "%{BKY_THREAD_3DAY}", + "4320" + ], + [ + "%{BKY_THREAD_WEEK}", + "10080" + ], + ] + }, + { + "type": "input_statement", + "name": "CODE" + }, + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "NOTENOUGH" + }, + { + "type": "input_dummy" + }, + { + "type": "input_dummy" + }, + { + "type": "input_dummy" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const name = Blockly.JavaScript.valueToCode(block, "NAME", Blockly.JavaScript.ORDER_ATOMIC); + const archiveAfter = block.getFieldValue("ARCHIVE"); + const code = Blockly.JavaScript.statementToCode(block, "CODE"); + const catchd = Blockly.JavaScript.statementToCode(block, "NOTENOUGH"); + return(`s4dmessage.startThread({name: ${name}, autoArchiveDuration: ${archiveAfter}})\n.then(s4dCreatedThread => {\n${code}\n})\n.catch(s4dThreadErr => {if (String(s4dThreadErr) === 'DiscordAPIError: Guild premium subscription level too low'){\n${catchd}\n}});\n`) +} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CHANNEL", + types: [ + "CHANNEL" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_message" + ] + } +]); diff --git a/src/blocks/discord/message-event/on_message.js b/src/blocks/discord/message-event/on_message.js index ecf392802..00cbb1b45 100644 --- a/src/blocks/discord/message-event/on_message.js +++ b/src/blocks/discord/message-event/on_message.js @@ -24,6 +24,6 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block) { const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); - const code = `s4d.client.on('messageCreate', async (s4dmessage) => {\n${statements}\n});\n`; + const code = `s4d.client.on('messageCreate', async (s4dmessage) => {\nif(s4dmessage.channel.type === "GUILD_TEXT"){\n${statements}\n}\n});\n`; return code; }; diff --git a/src/blocks/discord/message-event/reference_reply.js b/src/blocks/discord/message-event/reference_reply.js new file mode 100644 index 000000000..3c0a79d2a --- /dev/null +++ b/src/blocks/discord/message-event/reference_reply.js @@ -0,0 +1,68 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_reference_reply"; + +const blockData = { + "message0": "%{BKY_REPLY_REFERENCE}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "CODE" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const code = Blockly.JavaScript.statementToCode(block, "CODE"); + if(content.length > 2){ + return(`try {s4dmessage.channel.messages.cache.get(s4dmessage.reference.messageId).reply({embeds: ${embed}, content: ${content}})}\ncatch {\n${code}\n}\n`) + } else { + return(`try {s4dmessage.channel.messages.cache.get(s4dmessage.reference.messageId).reply({embeds: ${embed}})} catch {\n${code}\n}\n;\n`) + } +} + + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_message" + ] + } +]); diff --git a/src/blocks/discord/message-event/reply.js b/src/blocks/discord/message-event/reply.js index 647ddb69f..17a9e857b 100644 --- a/src/blocks/discord/message-event/reply.js +++ b/src/blocks/discord/message-event/reply.js @@ -9,10 +9,21 @@ const blockData = { { "type": "input_value", "name": "CONTENT", - "check": [ "Number", "String", "MessageEmbed" ] + "check": ["Number", "String"] }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "MENTION", + "check": "Boolean" + } ], "colour": "#4C97FF", + "inputsInline": false, "previousStatement": null, "nextStatement": null, "tooltip": "", @@ -27,22 +38,21 @@ Blockly.Blocks[blockName] = { Blockly.JavaScript[blockName] = function(block){ const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); - if(block.getInput("CONTENT").connection.targetConnection){ - const contentType = block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_ ? - block.getInput("CONTENT").connection.targetConnection.getSourceBlock().outputConnection.check_[0] : - null; - if((contentType === "MessageEmbed") || (!contentType && typeof contentType === "object")){ - const code = `s4dmessage.channel.send(${content});\n`; - return code; + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const mention = Blockly.JavaScript.valueToCode(block, "MENTION", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(mention === "true") { + if(content.length > 2){ + return(`s4dmessage.reply({embeds: ${embed}, content: ${content}});\n`) } else { - const code = `s4dmessage.channel.send(String(${content}));\n`; - return code; + return(`s4dmessage.reply({embeds: ${embed}});\n`) } - } else { - const code = `s4dmessage.channel.send(String(${content}));\n`; - return code; - } -}; + }else { + if(content.length > 2){ + return(`s4dmessage.channel.send({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`s4dmessage.channel.send({embeds: ${embed}});\n`) + } + }} registerRestrictions(blockName, [ { diff --git a/src/blocks/discord/message-event/started_thread.js b/src/blocks/discord/message-event/started_thread.js new file mode 100644 index 000000000..8a0f0e43b --- /dev/null +++ b/src/blocks/discord/message-event/started_thread.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_started_message_thread"; + +const blockData = { + "message0": "%{BKY_CREATED_THREAD}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dCreatedThread", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "hasparent", + message: "RES_MUST_BE_IN_ON_THREAD_START", + types: [ + "s4d_message_start_thread" + ] + } +]); diff --git a/src/blocks/discord/roles/get_role.js b/src/blocks/discord/roles/get_role.js index 3f578820b..b41f0ae45 100644 --- a/src/blocks/discord/roles/get_role.js +++ b/src/blocks/discord/roles/get_role.js @@ -118,13 +118,13 @@ Blockly.JavaScript[blockName] = function(block){ if(server){ return [ `${server}.roles.cache.find((role) => role.name === ${value})`, Blockly.JavaScript.ORDER_NONE ]; } else { - return [ `Array.prototype.concat.apply([], s4d.client.guilds.cache.array().map((g) => g.roles.cache.array())).find((role) => role.name === ${value})`, Blockly.JavaScript.ORDER_NONE ]; + return [ `s4d.client.guilds.cache.find((g) => g.roles.cache.find((role) => role.name === ${value}) !== undefined).roles.cache.find((role) => role.name === ${value})`, Blockly.JavaScript.ORDER_NONE ]; } } else { if(server){ - return [ `${server}.roles.get(${value})`, Blockly.JavaScript.ORDER_NONE ]; + return [ `${server}.roles.cache.get(${value})`, Blockly.JavaScript.ORDER_NONE ]; } else { - return [ `Array.prototype.concat.apply([], s4d.client.guilds.cache.array().map((g) => g.roles.cache.array())).get(${value})`, Blockly.JavaScript.ORDER_NONE ]; + return [ `s4d.client.guilds.cache.find((g) => g.roles.cache.get(${value}) !== undefined).roles.cache.get(${value})`, Blockly.JavaScript.ORDER_NONE ]; } } }; diff --git a/src/blocks/discord/roles/has_role.js b/src/blocks/discord/roles/has_role.js new file mode 100644 index 000000000..094ace56c --- /dev/null +++ b/src/blocks/discord/roles/has_role.js @@ -0,0 +1,55 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_has_role"; + +const blockData = { + "message0": "%{BKY_HAS_ROLE}", + "args0": [ + { + "type": "input_value", + "name": "ROLE", + "check": "Role" + }, + { + "type": "input_value", + "name": "MEMBER", + "check": "Member" + } + ], + "output": "Boolean", + "colour": "#4C97FF", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const role = Blockly.JavaScript.valueToCode(block, "ROLE", Blockly.JavaScript.ORDER_ATOMIC); + const member = Blockly.JavaScript.valueToCode(block, "MEMBER", Blockly.JavaScript.ORDER_ATOMIC); + const code = [`${member}._roles.includes(${role}.id)`, Blockly.JavaScript.ORDER_NONE ]; + return code; + +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_HAS_ROLE_MISSING_ROLE", + types: [ + "ROLE" + ] + }, + { + type: "notempty", + message: "RES_HAS_ROLE_MISSING_MEMBER", + types: [ + "MEMBER" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/roles/index.js b/src/blocks/discord/roles/index.js index 0c6736b7b..e36ecf55d 100644 --- a/src/blocks/discord/roles/index.js +++ b/src/blocks/discord/roles/index.js @@ -1,3 +1,5 @@ import "./add_role"; import "./get_role"; import "./remove_role"; +import "./has_role"; +import "./role_exists"; diff --git a/src/blocks/discord/roles/role_exists.js b/src/blocks/discord/roles/role_exists.js new file mode 100644 index 000000000..c9c30af6f --- /dev/null +++ b/src/blocks/discord/roles/role_exists.js @@ -0,0 +1,41 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_role_exist"; + +const blockData = { + "message0": "%{BKY_ROLE_EXIST}", + "args0": [ + { + "type": "input_value", + "name": "ROLE", + "check": "Role" + }, + ], + "output": "Boolean", + "colour": "#4C97FF", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const role = Blockly.JavaScript.valueToCode(block, "ROLE", Blockly.JavaScript.ORDER_ATOMIC); + const code = [`typeof ${role} !== undefined`, Blockly.JavaScript.ORDER_NONE ]; + return code; + +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_HAS_ROLE_MISSING_ROLE", + types: [ + "ROLE" + ] + }]); \ No newline at end of file diff --git a/src/blocks/discord/slash/index.js b/src/blocks/discord/slash/index.js new file mode 100644 index 000000000..ad9b4e872 --- /dev/null +++ b/src/blocks/discord/slash/index.js @@ -0,0 +1,7 @@ +import "./on_slash"; +import "./slash_value"; +import "./slash_name"; +import "./slash_author"; +import "./slash_channel"; +import "./slash_server"; +import "./slash_reply"; diff --git a/src/blocks/discord/slash/on_slash.js b/src/blocks/discord/slash/on_slash.js new file mode 100644 index 000000000..ef30af1bb --- /dev/null +++ b/src/blocks/discord/slash/on_slash.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_slash"; + +const blockData = { + "message0": "%{BKY_ON_SLASH} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('interactionCreate', async (s4dInteraction) => {\n${statements}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/slash/slash_author.js b/src/blocks/discord/slash/slash_author.js new file mode 100644 index 000000000..f5561e0f2 --- /dev/null +++ b/src/blocks/discord/slash/slash_author.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_slash_author"; + +const blockData = { + "message0": "%{BKY_SLASH_AUTHOR}", + "colour": "#187795", + "output": "Member", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dInteraction.member", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_SLASH", + types: [ + "s4d_on_slash" + ] + } +]); diff --git a/src/blocks/discord/slash/slash_channel.js b/src/blocks/discord/slash/slash_channel.js new file mode 100644 index 000000000..614e6a03e --- /dev/null +++ b/src/blocks/discord/slash/slash_channel.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_slash_channel"; + +const blockData = { + "message0": "%{BKY_SLASH_CHANNEL}", + "colour": "#a55b80", + "output": "Channel", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dInteraction.channel", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_SLASH", + types: [ + "s4d_on_slash" + ] + } +]); diff --git a/src/blocks/discord/slash/slash_name.js b/src/blocks/discord/slash/slash_name.js new file mode 100644 index 000000000..5886547f0 --- /dev/null +++ b/src/blocks/discord/slash/slash_name.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_slash_name"; + +const blockData = { + "message0": "%{BKY_SLASH_NAME}", + "colour": "#5BA58C", + "output": "String", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dInteraction.commandName", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_SLASH", + types: [ + "s4d_on_slash" + ] + } +]); diff --git a/src/blocks/discord/slash/slash_reply.js b/src/blocks/discord/slash/slash_reply.js new file mode 100644 index 000000000..33b0e961b --- /dev/null +++ b/src/blocks/discord/slash/slash_reply.js @@ -0,0 +1,64 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_slash_reply"; + +const blockData = { + "message0": "%{BKY_SLASH_REPLY}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "EPHEMERAL", + "check": "Boolean" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const ephemeral = Blockly.JavaScript.valueToCode(block, "EPHEMERAL", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(content.length > 2){ + return(`s4dInteraction.reply({embeds: ${embed}, content: ${content}, ephemeral: ${ephemeral}});\n`) + } else { + return(`s4dInteraction.reply({embeds: ${embed}, ephemeral: ${ephemeral}});\n`) + } +} +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_slash" + ] + } +]); diff --git a/src/blocks/discord/slash/slash_server.js b/src/blocks/discord/slash/slash_server.js new file mode 100644 index 000000000..92e2d9264 --- /dev/null +++ b/src/blocks/discord/slash/slash_server.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_slash_server"; + +const blockData = { + "message0": "%{BKY_SLASH_SERVER}", + "colour": "#D85E47", + "output": "Server", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dInteraction.guild", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_SLASH", + types: [ + "s4d_on_slash" + ] + } +]); diff --git a/src/blocks/discord/slash/slash_value.js b/src/blocks/discord/slash/slash_value.js new file mode 100644 index 000000000..56eef4234 --- /dev/null +++ b/src/blocks/discord/slash/slash_value.js @@ -0,0 +1,97 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + + +const blockName = "s4d_slash_value"; + +const blockData = { + "message0": "%{BKY_SLASH_VALUE}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH", + "options": [ + [ + "string", + "String" + ], + [ + "integer", + "Integer" + ], + [ + "boolean", + "Boolean" + ], + [ + "user", + "User" + ], + [ + "member", + "Member" + ], + [ + "channel", + "Channel" + ], + [ + "role", + "Role" + ], + [ + "subcommand", + "Subcommand" + ], + [ + "subcommand group", + "SubcommandGroup" + ] + + ] + }, + { + "type": "input_value", + "name": "NAME", + "check": "String", + }, + ], + "colour": "#4C97FF", + "output": ["String", "Member", "Channel", "Role"], + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + + +Blockly.JavaScript[blockName] = function(block) { + const string = Blockly.JavaScript.valueToCode(block, "NAME", Blockly.JavaScript.ORDER_ATOMIC); + const searchType = block.getFieldValue("SEARCH"); + + const code = [`s4dInteraction.options.get${searchType}(${string})`, Blockly.JavaScript.ORDER_NONE]; + return code; + +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_SLASH", + types: [ + "s4d_on_slash" + ] + }, + { + type: "notempty", + message: "RES_MISSING_SLASH_NAME", + types: [ + "NAME" + ] + } + +]); diff --git a/src/blocks/discord/thread-event/channel_thread.js b/src/blocks/discord/thread-event/channel_thread.js new file mode 100644 index 000000000..2546756f4 --- /dev/null +++ b/src/blocks/discord/thread-event/channel_thread.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_channel"; + +const blockData = { + "message0": "%{BKY_CHANNEL_OF_THREAD}", + "args0": [ + { + "type": "input_value", + "name": "CHANNEL", + "check": "Thread" + } + ], + "colour": "#50a6c9", + "output": "Channel", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC); + return [ `${channel}.parent`, Blockly.JavaScript.ORDER_NONE ]; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_VALID_CHANNEL", + types: [ + "CHANNEL" + ] + } +]); \ No newline at end of file diff --git a/src/blocks/discord/thread-event/created-thread.js b/src/blocks/discord/thread-event/created-thread.js new file mode 100644 index 000000000..816a2f95e --- /dev/null +++ b/src/blocks/discord/thread-event/created-thread.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_created_thread_on"; + +const blockData = { + "message0": "%{BKY_CREATED_THREAD_ON}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_START", + types: [ + "s4d_on_thread_create" + ] + } +]); diff --git a/src/blocks/discord/thread-event/deleted_thread.js b/src/blocks/discord/thread-event/deleted_thread.js new file mode 100644 index 000000000..6680d0780 --- /dev/null +++ b/src/blocks/discord/thread-event/deleted_thread.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_deleted_thread"; + +const blockData = { + "message0": "%{BKY_DELETED_THREAD}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThreadDeleted", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_DELETE", + types: [ + "s4d_on_thread_delete" + ] + } +]); diff --git a/src/blocks/discord/thread-event/index.js b/src/blocks/discord/thread-event/index.js new file mode 100644 index 000000000..384a2183c --- /dev/null +++ b/src/blocks/discord/thread-event/index.js @@ -0,0 +1,26 @@ +import "./on_new_thread"; +import "./on_thread_archive"; +import "./on_thread_unarchive"; +import "./on_thread_remove"; +import "./on_thread_message"; +import "./message_thread"; +import "./start_thread"; +import "./channel_thread"; +import "./thread_message_content"; +import "./thread_message_id"; +import "./thread_message_author"; +import "./message_thread_guild"; +import "./thread_message_author_raw"; +import "./thread_thread_raw"; +import "./thread_guild_raw"; +import "./thread_reply"; +import "./thread_react"; +import "./thread_message_delete"; +import "./unarchived_thread"; +import "./thread_archive"; +import "./started_thread"; +import "./send_thread"; +import "./created-thread"; +import "./deleted_thread"; +import "./thread_name"; +import "./thread_server"; diff --git a/src/blocks/discord/thread-event/message_thread.js b/src/blocks/discord/thread-event/message_thread.js new file mode 100644 index 000000000..08a17d8e6 --- /dev/null +++ b/src/blocks/discord/thread-event/message_thread.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_message_thread"; + +const blockData = { + "message0": "%{BKY_MESSAGE_THREAD}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread.channel", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/message_thread_guild.js b/src/blocks/discord/thread-event/message_thread_guild.js new file mode 100644 index 000000000..1021b6b03 --- /dev/null +++ b/src/blocks/discord/thread-event/message_thread_guild.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_server_thread"; + +const blockData = { + "message0": "%{BKY_THREAD_MESSAGE_GUILD}", + "colour": "#D85E47", + "output": "Server", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread.guild", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/on_new_thread.js b/src/blocks/discord/thread-event/on_new_thread.js new file mode 100644 index 000000000..2cce6b2bc --- /dev/null +++ b/src/blocks/discord/thread-event/on_new_thread.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_thread_create"; + +const blockData = { + "message0": "%{BKY_ON_THREAD_CREATE} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('threadCreate', async (s4dThread) => {\n${statements}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/thread-event/on_thread_archive.js b/src/blocks/discord/thread-event/on_thread_archive.js new file mode 100644 index 000000000..f5ba63002 --- /dev/null +++ b/src/blocks/discord/thread-event/on_thread_archive.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_thread_archive"; + +const blockData = { + "message0": "%{BKY_ON_THREAD_ARCHIVE} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('threadUpdate', async (s4dOldThread, s4dNewThread) => {\nif (!s4dOldThread.archived && s4dNewThread.archived) {\n${statements}\n}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/thread-event/on_thread_message.js b/src/blocks/discord/thread-event/on_thread_message.js new file mode 100644 index 000000000..8c380e4d3 --- /dev/null +++ b/src/blocks/discord/thread-event/on_thread_message.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_thread_message"; + +const blockData = { + "message0": "%{BKY_ON_THREAD_MESSAGE} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('messageCreate', async (s4dThread) => {\nif(s4dThread.channel.type === "GUILD_PUBLIC_THREAD" || s4dThread.channel.type === "GUILD_PUBLIC_THREAD" ){\n${statements}\n}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/thread-event/on_thread_remove.js b/src/blocks/discord/thread-event/on_thread_remove.js new file mode 100644 index 000000000..02c3a45f1 --- /dev/null +++ b/src/blocks/discord/thread-event/on_thread_remove.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_thread_delete"; + +const blockData = { + "message0": "%{BKY_ON_THREAD_DELETE} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('threadDelete', async (s4dThreadDeleted) => {\n${statements}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/thread-event/on_thread_unarchive.js b/src/blocks/discord/thread-event/on_thread_unarchive.js new file mode 100644 index 000000000..17b32c653 --- /dev/null +++ b/src/blocks/discord/thread-event/on_thread_unarchive.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly"; + +const blockName = "s4d_on_thread_unarchive"; + +const blockData = { + "message0": "%{BKY_ON_THREAD_UNARCHIVE} %1 %2", + "colour": "#F5AB1A", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "STATEMENTS" + } + ] +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const statements = Blockly.JavaScript.statementToCode(block, "STATEMENTS"); + const code = `s4d.client.on('threadUpdate', async (s4dOldThread, s4dNewThread) => {\nif (s4dOldThread.archived && !s4dNewThread.archived) {\n${statements}\n}\n});\n`; + return code; +}; diff --git a/src/blocks/discord/thread-event/send_thread.js b/src/blocks/discord/thread-event/send_thread.js new file mode 100644 index 000000000..cd87158fc --- /dev/null +++ b/src/blocks/discord/thread-event/send_thread.js @@ -0,0 +1,58 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_send_thread"; + +const blockData = { + "message0": "%{BKY_SEND_THREAD}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "CHANNEL", + "check": "Thread" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(content.length > 2){ + return(`${channel}.send({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`${channel}.send({embeds: ${embed}});\n`) + } +} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + } +]); diff --git a/src/blocks/discord/thread-event/start_thread.js b/src/blocks/discord/thread-event/start_thread.js new file mode 100644 index 000000000..380eb0b33 --- /dev/null +++ b/src/blocks/discord/thread-event/start_thread.js @@ -0,0 +1,90 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_start_thread"; + +const blockData = { + "message0": "%{BKY_CREATE_THREAD}", + "args0": [ + { + "type": "input_value", + "name": "CHANNEL", + "check": "Channel" + }, + { + "type": "input_value", + "name": "NAME", + "check": "String" + }, + { + "type": "field_dropdown", + "name": "ARCHIVE", + "options": [ + [ + "%{BKY_THREAD_HOUR}", + "60" + ], + [ + "%{BKY_THREAD_DAY}", + "1440" + ], + [ + "%{BKY_THREAD_3DAY}", + "4320" + ], + [ + "%{BKY_THREAD_WEEK}", + "10080" + ], + ] + }, + { + "type": "input_statement", + "name": "CODE" + }, + { + "type": "input_dummy" + }, + { + "type": "input_statement", + "name": "NOTENOUGH" + }, + { + "type": "input_dummy" + }, + { + "type": "input_dummy" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const channel = Blockly.JavaScript.valueToCode(block, "CHANNEL", Blockly.JavaScript.ORDER_ATOMIC); + const name = Blockly.JavaScript.valueToCode(block, "NAME", Blockly.JavaScript.ORDER_ATOMIC); + const archiveAfter = block.getFieldValue("ARCHIVE"); + const code = Blockly.JavaScript.statementToCode(block, "CODE"); + const catchd = Blockly.JavaScript.statementToCode(block, "NOTENOUGH"); + return(`${channel}.threads.create({name: ${name}, autoArchiveDuration: ${archiveAfter}})\n.then(s4dCreatedThread => {\n${code}\n})\n.catch(s4dThreadErr => {if (String(s4dThreadErr) === 'DiscordAPIError: Guild premium subscription level too low'){\n${catchd}\n}});\n`) +} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CHANNEL", + types: [ + "CHANNEL" + ] + } +]); diff --git a/src/blocks/discord/thread-event/started_thread.js b/src/blocks/discord/thread-event/started_thread.js new file mode 100644 index 000000000..962c7e5b7 --- /dev/null +++ b/src/blocks/discord/thread-event/started_thread.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_started_thread"; + +const blockData = { + "message0": "%{BKY_CREATED_THREAD}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dCreatedThread", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "hasparent", + message: "RES_MUST_BE_IN_THREAD_START", + types: [ + "s4d_start_thread" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_archive.js b/src/blocks/discord/thread-event/thread_archive.js new file mode 100644 index 000000000..3a2320882 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_archive.js @@ -0,0 +1,64 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_archive"; + +const blockData = { + "message0": "%{BKY_THREAD_ARCHIVE}", + "args0": [ + { + "type": "field_dropdown", + "name": "TYPE", + "options": [ + [ + "archive", + "true" + ], + [ + "unarchive", + "false" + ], + [ + "delete", + "delete" + ] + ] + }, + { + "type": "input_value", + "name": "THREAD", + "check": "Thread" + } + ], + "previousStatement": null, + "nextStatement": null, + "colour": "#AA97D8", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const type = block.getFieldValue("TYPE"); + const thread = Blockly.JavaScript.valueToCode(block, "THREAD", Blockly.JavaScript.ORDER_ATOMIC); + if(type === "true" || type === "false"){ + return(`${thread}.setArchived(${type});\n`); + }else{ + return(`${thread}.delete()`) + } +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_THREAD", + types: [ + "THREAD" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_guild_raw.js b/src/blocks/discord/thread-event/thread_guild_raw.js new file mode 100644 index 000000000..214b6def8 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_guild_raw.js @@ -0,0 +1,55 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_guild_raw"; + +const blockData = { + "message0": "%{BKY_THREAD_GUILD_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_NAME}", + "NAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["(s4dThread.guild || {}).id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NAME"){ + const code = ["(s4dThread.guild || {}).name", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_message_author.js b/src/blocks/discord/thread-event/thread_message_author.js new file mode 100644 index 000000000..8ea1ff7b5 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_message_author.js @@ -0,0 +1,33 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_message_author"; + +const blockData = { + "message0": "%{BKY_THREAD_MESSAGE_AUTHOR}", + "colour": "#187795", + "output": "Member", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread.member", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_message_author_raw.js b/src/blocks/discord/thread-event/thread_message_author_raw.js new file mode 100644 index 000000000..586b2d8c8 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_message_author_raw.js @@ -0,0 +1,62 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_message_author_raw"; + +const blockData = { + "message0": "%{BKY_THREAD_MESSAGE_AUTHOR_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_USERNAME}", + "USERNAME" + ], + [ + "%{BKY_NICKNAME}", + "NICKNAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["s4dThread.author.id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "USERNAME"){ + const code = ["s4dThread.author.username", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NICKNAME"){ + const code = ["(s4dThread.member || await s4dThread.guild.members.fetch(s4dThread.author.id)).nickname", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_message_content.js b/src/blocks/discord/thread-event/thread_message_content.js new file mode 100644 index 000000000..b24a9201c --- /dev/null +++ b/src/blocks/discord/thread-event/thread_message_content.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_message_content"; + +const blockData = { + "message0": "%{BKY_THREAD_MESSAGE_CONTENT}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread.content", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_message_delete.js b/src/blocks/discord/thread-event/thread_message_delete.js new file mode 100644 index 000000000..5b004a688 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_message_delete.js @@ -0,0 +1,34 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_message_delete"; + +const blockData = { + "message0": "%{BKY_DELETE_THREAD_MESSAGE}", + "colour": "#4C97FF", + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(){ + const code = `s4dThread.delete();\n`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_message_id.js b/src/blocks/discord/thread-event/thread_message_id.js new file mode 100644 index 000000000..66d128029 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_message_id.js @@ -0,0 +1,33 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_message_id"; + +const blockData = { + "message0": "%{BKY_THREAD_MESSAGE_ID}", + "colour": "#5BA58C", + "tooltip": "", + "output": "String", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dThread.id", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_name.js b/src/blocks/discord/thread-event/thread_name.js new file mode 100644 index 000000000..6529e99cb --- /dev/null +++ b/src/blocks/discord/thread-event/thread_name.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_name"; + +const blockData = { + "message0": "%{BKY_THREAD_NAME}", + "args0": [ + { + "type": "input_value", + "name": "THREAD", + "check": "Thread", + } + ], + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const thread = Blockly.JavaScript.valueToCode(block, "THREAD", Blockly.JavaScript.ORDER_ATOMIC); + return(`${thread}.name`) +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_THREAD", + types: [ + "THREAD" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_react.js b/src/blocks/discord/thread-event/thread_react.js new file mode 100644 index 000000000..7c66b7e3c --- /dev/null +++ b/src/blocks/discord/thread-event/thread_react.js @@ -0,0 +1,49 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_reaction"; + +const blockData = { + "message0": "%{BKY_THREAD_REACTION}", + "args0": [ + { + "type": "input_value", + "name": "REACTION", + "check": "String" + } + ], + "previousStatement": null, + "nextStatement": null, + "colour": "#4C97FF", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const reaction = Blockly.JavaScript.valueToCode(block, "REACTION", Blockly.JavaScript.ORDER_ATOMIC); + const code = `s4dThread.react(${reaction});`; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_ADD_REACTION_MISSING_REACTION", + types: [ + "REACTION" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_reply.js b/src/blocks/discord/thread-event/thread_reply.js new file mode 100644 index 000000000..f7f8a5e1a --- /dev/null +++ b/src/blocks/discord/thread-event/thread_reply.js @@ -0,0 +1,72 @@ +import * as Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_reply"; + +const blockData = { + "message0": "%{BKY_THREAD_REPLY}", + "args0": [ + { + "type": "input_value", + "name": "CONTENT", + "check": ["Number", "String"] + }, + { + "type": "input_value", + "name": "EMBED", + "check": "MessageEmbed" + }, + { + "type": "input_value", + "name": "MENTION", + "check": "Boolean" + } + ], + "colour": "#4C97FF", + "inputsInline": false, + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const content = Blockly.JavaScript.valueToCode(block, "CONTENT", Blockly.JavaScript.ORDER_ATOMIC); + const embed = Blockly.JavaScript.valueToCode(block, "EMBED", Blockly.JavaScript.ORDER_ATOMIC) || null; + const mention = Blockly.JavaScript.valueToCode(block, "MENTION", Blockly.JavaScript.ORDER_ATOMIC) || "false"; + if(mention === "true") { + if(content.length > 2){ + return(`s4dThread.reply({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`s4dThread.reply({embeds: ${embed}});\n`) + } + }else { + if(content.length > 2){ + return(`s4dThread.channel.send({embeds: ${embed}, content: ${content}});\n`) + } else { + return(`s4dThread.channel.send({embeds: ${embed}});\n`) + } + }} + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_CONTENT", + types: [ + "CONTENT" + ] + }, + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_THREAD_MESSAGE", + types: [ + "s4d_on_thread_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_server.js b/src/blocks/discord/thread-event/thread_server.js new file mode 100644 index 000000000..ec6f97bd4 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_server.js @@ -0,0 +1,40 @@ +import * as Blockly from "blockly"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_server"; + +const blockData = { + "message0": "%{BKY_THREAD_SERVER}", + "args0": [ + { + "type": "input_value", + "name": "THREAD", + "check": "Thread", + } + ], + "colour": "#AA97D8", + "output": "Server", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const thread = Blockly.JavaScript.valueToCode(block, "THREAD", Blockly.JavaScript.ORDER_ATOMIC); + return(`${thread}.guild`) +}; + +registerRestrictions(blockName, [ + { + type: "notempty", + message: "RES_MISSING_THREAD", + types: [ + "THREAD" + ] + } +]); diff --git a/src/blocks/discord/thread-event/thread_thread_raw.js b/src/blocks/discord/thread-event/thread_thread_raw.js new file mode 100644 index 000000000..8c1aae560 --- /dev/null +++ b/src/blocks/discord/thread-event/thread_thread_raw.js @@ -0,0 +1,55 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_thread_raw"; + +const blockData = { + "message0": "%{BKY_THREAD_RAW}", + "args0": [ + { + "type": "field_dropdown", + "name": "SEARCH_TYPE", + "options": [ + [ + "%{BKY_NAME}", + "NAME" + ], + [ + "id", + "ID" + ] + ] + } + ], + "output": "String", + "colour": "#5BA58C", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block) { + const searchType = block.getFieldValue("SEARCH_TYPE"); + if(searchType === "ID"){ + const code = ["(s4dThread.channel || {}).id", Blockly.JavaScript.ORDER_NONE]; + return code; + } else if(searchType === "NAME"){ + const code = ["(s4dThread.channel || {}).name", Blockly.JavaScript.ORDER_NONE]; + return code; + } +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_MESSAGE", + types: [ + "s4d_on_message" + ] + } +]); diff --git a/src/blocks/discord/thread-event/unarchived_thread.js b/src/blocks/discord/thread-event/unarchived_thread.js new file mode 100644 index 000000000..5c6d76fd2 --- /dev/null +++ b/src/blocks/discord/thread-event/unarchived_thread.js @@ -0,0 +1,34 @@ +import Blockly from "blockly/core"; +import { registerRestrictions } from "../../../restrictions"; + +const blockName = "s4d_unarchived_thread"; + +const blockData = { + "message0": "%{BKY_UNARCHIVED_THREAD}", + "colour": "#AA97D8", + "output": "Thread", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["s4dNewThread", Blockly.JavaScript.ORDER_NONE]; + return code; +}; + +registerRestrictions(blockName, [ + { + type: "toplevelparent", + message: "RES_MUST_BE_IN_ON_UNARCHIVE_THREAD", + types: [ + "s4d_on_thread_unarchive", + "s4d_on_thread_archive" + ] + } +]); diff --git a/src/blocks/other/cpu_model.js b/src/blocks/other/cpu_model.js new file mode 100644 index 000000000..e2f059287 --- /dev/null +++ b/src/blocks/other/cpu_model.js @@ -0,0 +1,22 @@ +import Blockly from "blockly/core"; + +const blockName = "s4d_cpu_model"; + +const blockData = { + "message0": "%{BKY_CPU_MODEL}", + "colour": "#D14081", + "output": "String", + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function() { + const code = ["os.cpus()[0].model", Blockly.JavaScript.ORDER_NONE]; + return code; +}; diff --git a/src/blocks/other/eval.js b/src/blocks/other/eval.js new file mode 100644 index 000000000..66b9151ef --- /dev/null +++ b/src/blocks/other/eval.js @@ -0,0 +1,30 @@ +import * as Blockly from "blockly/core"; + +const blockName = "s4d_eval"; + +const blockData = { + "message0": "eval %1", + "args0": [ + { + "type": "input_value", + "name": "EVAL", + "check": [ "Number", "String" ] + } + ], + "colour": "#D14081", + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const code = Blockly.JavaScript.valueToCode(block, "EVAL", Blockly.JavaScript.ORDER_ATOMIC); + return `await eval(${code});\n`; +}; \ No newline at end of file diff --git a/src/blocks/other/index.js b/src/blocks/other/index.js index ddda73fe2..a7b5d4f38 100644 --- a/src/blocks/other/index.js +++ b/src/blocks/other/index.js @@ -1,3 +1,6 @@ import "./current"; import "./run_save_output"; import "./wait_seconds"; +import "./eval"; +import "./log"; +import "./cpu_model"; diff --git a/src/blocks/other/log.js b/src/blocks/other/log.js new file mode 100644 index 000000000..9c4731469 --- /dev/null +++ b/src/blocks/other/log.js @@ -0,0 +1,29 @@ +import * as Blockly from "blockly/core"; + +const blockName = "s4d_log"; + +const blockData = { + "message0": "%{BKY_LOG}", + "args0": [ + { + "type": "input_value", + "name": "TEXT" + } + ], + "colour": "#D14081", + "previousStatement": null, + "nextStatement": null, + "tooltip": "", + "helpUrl": "" +}; + +Blockly.Blocks[blockName] = { + init: function() { + this.jsonInit(blockData); + } +}; + +Blockly.JavaScript[blockName] = function(block){ + const text = Blockly.JavaScript.valueToCode(block, "TEXT", Blockly.JavaScript.ORDER_ATOMIC); + return `console.log(${text});\n`; +}; \ No newline at end of file diff --git a/src/components/NavigationBar/LanguageMenu.vue b/src/components/NavigationBar/LanguageMenu.vue deleted file mode 100644 index 92c072b7a..000000000 --- a/src/components/NavigationBar/LanguageMenu.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/components/NavigationBar/NavigationBar.vue b/src/components/NavigationBar/NavigationBar.vue index f352c5ada..f7c91bad4 100644 --- a/src/components/NavigationBar/NavigationBar.vue +++ b/src/components/NavigationBar/NavigationBar.vue @@ -12,18 +12,14 @@ - {{ $t('help') }} + {{ $t('slash') }} - {{ $t("untitled") }} - - - @@ -38,8 +34,6 @@ import JSZip from "jszip"; import FileMenu from "./FileMenu.vue"; import EditMenu from "./EditMenu.vue"; -import LanguageMenu from "./LanguageMenu.vue"; -import RunModal from "./RunModal.vue"; import ExamplesMenu from "./ExamplesMenu.vue"; import CodeModal from "./CodeModal"; @@ -48,8 +42,6 @@ export default { components: { FileMenu, EditMenu, - LanguageMenu, - RunModal, ExamplesMenu, CodeModal }, diff --git a/src/components/NavigationBar/RunModal.vue b/src/components/NavigationBar/RunModal.vue deleted file mode 100644 index a19a8b63a..000000000 --- a/src/components/NavigationBar/RunModal.vue +++ /dev/null @@ -1,229 +0,0 @@ - - - - - diff --git a/src/examples/command-parsing.js b/src/examples/command-parsing.js index e72cbb73a..3950447c2 100644 --- a/src/examples/command-parsing.js +++ b/src/examples/command-parsing.js @@ -1,109 +1,112 @@ export default ` - - - arguments - command - - - - - Your bot token - - + + + arguments + command + + + + + Your bot token + + + + + + + arguments + + + + SPLIT + + + + + + + + - - - - arguments - - - - SPLIT - - - - - - - - + + + + command + + + + GET_REMOVE + FROM_START + + + arguments + + + + + 1 + + + + + + + + + EQ + + + command - - - - command - - - - GET_REMOVE - FROM_START - - - arguments - - - - - 1 - - - - - - - - - EQ - - - command - - - - - !say - - - - - - - - - You have written the following content after !say: - - - - - - - Salut! - - - - JOIN - - - arguments - - - - - - - - - - - + + + + !say + + + + + + + + + You have written the following content after !say: + + + + + + + + + JOIN + + + arguments - + + + + + + - + + + + + + TRUE - + - + + + - + + + + + `; \ No newline at end of file diff --git a/src/examples/ping-pong.js b/src/examples/ping-pong.js index 08645b360..169948547 100644 --- a/src/examples/ping-pong.js +++ b/src/examples/ping-pong.js @@ -1,39 +1,59 @@ export default ` - - - - - Your bot token - + + + + + Your bot token + + + + + + + + + EQ + + - - - - - - - EQ - - - - - - !ping - - - - - - - - - pong! - - - - - - - - + + + !ping + + + + + + + + + + + + + + + + + pong! + + + + + #33ff33 + + + + + + + TRUE + + + + + + + + `; \ No newline at end of file diff --git a/src/locales/en-US.json b/src/locales/en-US.json index be0355b4e..d4172b29b 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -1,32 +1,69 @@ { "BASE_BLOCKS": "Base blocks", "MESSAGE_RELATED_BLOCKS": "Blocks related to messages", - "REPLY": "reply %1", + "REPLY": "reply %1 embed %2 mention %3", + "EDITED_REPLY": "edited reply %1 embed %2 mention %3", + "SLASH_REPLY": "reply %1 embed %2 ephemeral %3", + "ON_THREAD_CREATE": "When thread is created", + "ON_THREAD_UNARCHIVE": "When thread is unarchived", + "RES_VALID_CHANNEL": "You must specify a valid channel", + "ON_THREAD_DELETE": "When thread is deleted", + "CHANNEL_OF_THREAD": "channel of thread %1", + "DIRECT_REPLY": "direct reply %1 embed %2 mention %3", "LOGIN": "Connect to Discord with the token %1", "LOGIN_TOOLTIP": "Connect your bot to Discord. To get your bot token, go to https://discord.com/developers/.", "ON_MESSAGE": "When a message is received", + "ON_SLASH": "When slash command is received", + "RES_MISSING_THREAD": "You must specify a valid thread!", + "CHANNEL_CATEGORY": "category of channel %1", + "THREAD_ARCHIVE": "%1 thread %2", + "ON_DIRECT": "When a direct message is received", + "DETECT_SLASH": "Detect slash commands", + "ON_THREAD_ARCHIVE": "When thread is archived", + "MESSAGE_THREAD": "message thread", "ON_CONNECTED": "When the bot is connected", + "ON_THREAD_MESSAGE": "When thread message is received", + "ON_EDITED": "When a message is edited", + "TOOLBOX_EDITED": "Edited", + "TOOLBOX_DIRECT": "Direct", "ON_CONNECTED_TOOLTIP": "Event emitted when your bot is connected to Discord.", "MESSAGE_ID": "message ID", "MESSAGE_CONTENT": "message content", "MESSAGE_AUTHOR": "message author", + "THREAD_REPLY": "thread reply %1 embed %2 mention %3", + "EDITED_AUTHOR": "edited message author", "MESSAGE_AUTHOR_RAW": "%1 of the message author", + "LABEL_THREAD_ARCHIVE": "Thread archive/unarchive", + "THREAD_REACTION": "add reaction %1 on thread message", + "DELETE_THREAD_MESSAGE": "delete thread message", + "THREAD_RAW": "%1 of the message thread", + "EDITED_AUTHOR_RAW": "%1 of the edited message author", "USERNAME": "username", + "THREAD_GUILD_RAW":"%1 of the thread message server", "NICKNAME": "nickname", + "THREAD_MESSAGE_AUTHOR_RAW": "%1 of thread message author", "GET_GUILD": "find server %1 using %2", "NAME": "name", "ADD_ROLE": "add role %1 to member %2", "REMOVE_ROLE": "remove role %1 from member %2", "BAN_MEMBER": "ban member %1", "KICK_MEMBER": "kick member %1", - "SEND_MEMBER": "send %1 to member %2", + "SEND_MEMBER": "send %1embed%2to member %3", + "DIRECT_CONTENT": "direct mesage content", "MESSAGE_GUILD": "message server", + "THREAD_MESSAGE_GUILD": "thread message server", + "EDITED_GUILD": "edited message server", + "EDITED_ID": "edited message ID", "MESSAGE_CHANNEL": "message channel", + "EDITED_MESSAGE_CHANNEL": "edited message channel", "BASIC_BLOCKS": "Basic blocks", "ADVANCED_BLOCKS": "Advanced blocks", "MENTIONED_MEMBER": "mentioned member", + "OLD_EDITED_MENTIONED_MEMBER": "old edited mentioned member", + "NEW_EDITED_MENTIONED_MEMBER": "new edited mentioned member", "ADMINISTRATOR": "Administrator", "DETECT_MESSAGES": "Detect messages", + "DETECT_EDITED": "Detect editing", "MESSAGE_ACTIONS": "Actions on the message", "RELATED_TO_MESSAGE_STRINGS": "Strings related to the message", "DELETE_MESSAGE": "delete the message", @@ -75,8 +112,13 @@ "PERM_CHANGE_NICKNAME": "change nickname", "PERM_MANAGE_NICKNAMES": "manage nicknames", "PERM_MANAGE_ROLES": "manage roles", + "SLASH_VALUE": "Get %1 option name %2", "PERM_MANAGE_WEBHOOKS": "manage webhooks", + "DIRECT_REACTION": "add reaction %1 to direct message", "PERM_MANAGE_EMOJIS": "manage emojis", + "DELETE_DIRECT": "delete direct message", + "DIRECT_BOT": "direct author is bot?", + "TAG": "tag", "JOINS_RELATED_BLOCKS": "Blocks related to member joins", "DETECT_JOINS": "Detect joins", "ON_MEMBER_JOIN": "When a member joins a server", @@ -86,12 +128,49 @@ "JOINING_MEMBER_RAW": "%1 of the joining member", "JOINING_GUILD": "joining member server", "TEMPORARILY": "Temporarily", + "THREAD_NAME": "name of thread %1", + "DELETED_THREAD": "deleted thread", + "THREAD_SERVER": "server of thread %1", + "RES_HAS_ROLE_MISSING_ROLE": "You must specify a valid role", + "THREAD_OTHER_LABEL": "Other thread stuff", + "RES_HAS_ROLE_MISSING_MEMBER": "You must specify a valid member", "HOURS": "hours", + "ROLE_EXIST": "role %1 exist?", "REASON": "reason", + "RES_MUST_BE_IN_ON_THREAD_DELETE":"This block may only be used in a \"When a thread is deleted\" event", + "DISCRIMINATOR": "discriminator", + "THREAD_CREATE_LABEL": "Detect creating thread", + "THREAD_DELETE_LABEL": "Detect deleting thread", + "MESSAGE_CREATE_THREAD": "start thread on message %7 with name%1 auto archive after%2%4then%6%3if not enoguh server boost level%8%5", + "CREATE_THREAD": "start thread in channel %1 with name %2 archive after %3 %7then%5%4if not enough server boost level%8%6", + "CREATED_THREAD": "started thread", + "THREAD_HOUR": "1 hour", + "THREAD_DAY": "1 day", + "THREAD_3DAY": "3 days", + "THREAD_WEEK": "1 week", + "HAS_ROLE": "member %2 has role %1", + "CREATED_THREAD_ON": "created thread", + "DIRECT_ID": "direct message ID", + "UNARCHIVED_THREAD": "(un)archived thread", + "DIRECT_AUTHOR_INFO": "Informations about direct message author", + "DIRECT_AUTHOR_RAW": "%1 of direct message author", "DURING_HOURS": "during", + "SLASH_AUTHOR": "slash command author", + "SLASH_CHANNEL": "slash command channel", + "SLASH_SERVER": "slash command server", + "SLASH_NAME": "slash command name", "WITH_REASON": "for the reason", + "THREAD_MESSAGE_CONTENT": "thread message content", + "RES_MUST_BE_IN_THREAD_START": "This block may only be used in a \"start thread\" block!", + "RES_MISSING_CHANNEL": "You must specify a valid channel!", + "RES_MUST_BE_IN_ON_THREAD_START": "This block may only be used in a \"When a thread is created\" event", + "RES_MUST_BE_IN_ON_UNARCHIVE_THREAD": "This block may only be used in a \"When a thread is (un)archived\" event", "RES_MUST_BE_IN_ON_MESSAGE": "This block may only be used in a \"When a message is received\" event", + "RES_MUST_BE_IN_ON_SLASH": "This block may only be used in a \"When slash command is received\" event", + "RES_MUST_BE_IN_ON_DIRECT": "This block may only be used in a \"When a direct message is received\" event", + "RES_MUST_BE_IN_ON_THREAD_MESSAGE": "This block may only be used in a \"When thread message is received\" event", "RES_MISSING_CONTENT": "You must specify a valid content to reply!", + "RES_MISSING_SLASH_NAME": "You must specify a valid slash value to get!", "RES_MISSING_MEMBER_HAS_PERMISSION": "You must specify a valid member to check permissions!", "RES_MUST_BE_IN_ON_MEMBER_JOIN": "This block may only be used in a \"When a member joins a server\" event", "RES_ADD_ROLE_MISSING_ROLE": "You must specify a valid name or role ID to add!", @@ -111,13 +190,19 @@ "RES_INCLUDES_TEXT": "You must specify a text to see if that includes something!", "RES_INCLUDES_INCLUDES": "You must specify a text to see if in the other text includes that!", "NEWLINE": "new line", + "CPU_MODEL": "CPU model", + "THREAD_MESSAGE_AUTHOR": "thread message author", + "THREAD_MESSAGE_ID": "thread message ID", "FIND_CHANNEL": "Find a channel", + "REPLY_REFERENCE": "reference reply %1 embed %2 if no reference %3%4", "SEND_CHANNEL_LABEL": "Send a message in the found channel", + "LABEL_THREAD_MESSAGE": "Thread messages", "GET_CHANNEL": "get the channel with %2 equal to %1", "RES_MISSING_CHANNEL_VALUE": "You must specify a valid channel name or ID!", "RES_SEND_CHANNEL_CONTENT": "You must specify a content to send!", "RES_SEND_CHANNEL_CHANNEL": "You must specify a channel in which to send the content!", - "SEND_CHANNEL": "send %1 in the channel %2", + "SEND_CHANNEL": "send %1embed%2in channel %3", + "SEND_THREAD": "send%1embed%2thread%3", "TOOLBOX_LOGIC": "Logic", "TOOLBOX_LOOPS": "Loops", "TOOLBOX_MATH": "Math", @@ -149,20 +234,28 @@ "RES_GET_ROLE_VALUE": "You must specify a valid name or role ID!", "RES_GET_SERVER_VALUE": "You must specify a valid server name or ID!", "FIND_ROLE": "Find a role", + "START_TYPING": "start typing%1 in channel %2", + "MEMBER_STATUS": "presence status of %1", "ROLE_ASSIGNMENT": "Roles assignment", "FIND_MEMBER": "Find a member", + "LOG": "log in console %1", "GET_MEMBER": "get member with %2 equal to %1 on server %3", "INIT_TOOLTIP": "Allows you to use Discord blocks!", + "MEMBER_IS_STREAMING": "member %1 is streaming", "JOINING_GUILD_RAW": "%1 of the server of the joining member", "LABEL_MEMBER_ACTIONS": "Actions on the member", "LABEL_MESSAGE_CONTEXT": "Message context", + "LABEL_EDITED_INTERACTION": "Interactions with message", "MESSAGE_CHANNEL_RAW": "%1 of the channel of the message", + "EDITED_CHANNEL_RAW": "%1 of the channel of edited message", "MESSAGE_GUILD_RAW": "%1 of the server of the message", + "EDITED_GUILD_RAW": "%1 of the server of the message", "RES_GET_MEMBER_SERVER": "You must specify a valid server on which the member is!", "RES_GET_MEMBER_VALUE": "You must specify a valid member ID or member name!", "TOOLBOX_MEMBERS": "Member", "MEMBER_INFORMATIONS": "Members informations", "RES_VALID_MEMBER": "You must specify a valid member !", + "DELETE_EDITED_MESSAGE": "delete edited message", "MEMBER_DISCRIMINATOR": "discriminator of member %1", "MEMBER_ID": "id of member %1", "MEMBER_TAG": "tag of member %1", @@ -196,6 +289,7 @@ "BOT_SERVER_COUNT": "bot server count", "TOOLBOX_E_JOINS": "Joins", "TOOLBOX_E_MESSAGES": "Messages", + "TOOLBOX_SLASH": "Slash", "TOOLBOX_E_REACTIONS": "Reactions", "TOOLBOX_DATABASE": "Database", "GET_DATA": "get %1 from the database", @@ -205,6 +299,8 @@ "DELETE_DATA": "delete %1 from database", "HAS_DATA": "%1 exists in database", "ADD_DATA": "add %1 to %2", + "NEW_CONTENT": "new message content", + "OLD_CONTENT": "old message content", "SUBTRACT_DATA": "subtract %1 from %2", "DETECT_LEAVES": "Detect leaves", "LEAVING_GUILD": "leaving member server", diff --git a/src/locales/en.js b/src/locales/en.js index 9a3b7c3de..b6335203c 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -11,6 +11,7 @@ export const applyBlocklyLocale = () => { export const websiteMessages = { untitled: "Untitled document", help: "Help", + slash: "Register slash commands", load: { error: "The uploaded file is corrupted and cannot be loaded by Scratch For Discord..." }, diff --git a/src/locales/fr-FR.json b/src/locales/fr-FR.json deleted file mode 100644 index 80a8031f4..000000000 --- a/src/locales/fr-FR.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "BASE_BLOCKS": "Blocks de base", - "REPLY": "répondre %1", - "MESSAGE_RELATED_BLOCKS": "Blocks relatifs aux messages", - "INIT_TOOLTIP": "Vous permet d'utiliser les blocks Discord!", - "LOGIN": "Connexion à Discord avec le token %1", - "LOGIN_TOOLTIP": "Connecte votre bot à Discord. Pour trouver le token de votre bot, rendez-vous sur https://discord.com/developers/.", - "ON_MESSAGE": "Quand un message est reçu", - "ON_CONNECTED": "Quand le bot est connecté", - "ON_CONNECTED_TOOLTIP": "Évènement émis lorsque votre bot est connecté à Discord.", - "MESSAGE_ID": "ID du message", - "MESSAGE_CONTENT": "contenu du message", - "MESSAGE_AUTHOR": "auteur du message", - "MESSAGE_AUTHOR_RAW": "%1 de l'auteur du message", - "USERNAME": "nom d'utilisateur", - "NICKNAME": "pseudo", - "GET_GUILD": "trouver le serveur %1 via %2", - "NAME": "nom", - "ADD_ROLE": "ajouter le rôle %1 au membre %2", - "REMOVE_ROLE": "enlever le rôle %1 au membre %2", - "BAN_MEMBER": "bannir le membre %1", - "KICK_MEMBER": "expulser le membre %1", - "SEND_MEMBER": "envoyer %1 au membre %2", - "MESSAGE_GUILD_RAW": "%1 du serveur du message", - "MESSAGE_CHANNEL_RAW": "%1 du salon du message", - "MESSAGE_CHANNEL": "salon du message", - "MESSAGE_GUILD": "serveur du message", - "BASIC_BLOCKS": "Blocks basics", - "ADVANCED_BLOCKS": "Blocks avancés", - "MENTIONED_MEMBER": "membre mentionné", - "ADMINISTRATOR": "Administrateur", - "DETECT_MESSAGES": "Détecter les messages", - "MESSAGE_ACTIONS": "Actions sur le message", - "RELATED_TO_MESSAGE_STRINGS": "Chaînes relatives au message", - "DELETE_MESSAGE": "supprimer le message", - "RES_ADD_REACTION_MISSING_REACTION": "Vous devez spécifier un émoji valide !", - "ADD_REACTION": "ajouter la réaction %1 au message", - "MESSAGE_EMBED": "Message Embed", - "COLOR": "couleur", - "TITLE": "titre", - "MESSAGE": "message", - "IMAGE": "image", - "FOOTER": "pied de page", - "THUMBNAIL": "miniature", - "PURGE": "dans le salon %1 supprimer %2 messages", - "RES_PURGE_AMOUNT": "Vous devez préciser un nombre valide de messages à supprimer !", - "RES_PURGE_CHANNEL": "Vous devez préciser un salon valide !", - "CHANNEL_MESSAGE_ACTIONS": "Actions sur les messages du salon", - "TOOLS": "Outils", - "CHECK_PERMISSIONS": "Vérifier les permissions d'un membre", - "MEMBER_HAS_PERMISSION": "le membre %1 a la permission %2", - "PERM_CREATE_INSTANT_INVITE": "créer une invitation instantanée", - "PERM_KICK_MEMBERS": "expulser des membres", - "PERM_BAN_MEMBERS": "bannir des membres", - "PERM_ADMINISTRATOR": "administrateur", - "PERM_MANAGE_CHANNELS": "gérer les salons", - "PERM_MANAGE_GUILD": "gérer le serveur", - "PERM_ADD_REACTIONS": "ajouter des réactions", - "PERM_VIEW_AUDIT_LOG": "voir les logs du serveur", - "PERM_PRIORITY_SPEAKER": "voix prioritaire", - "PERM_VIEW_CHANNEL": "voir le salon", - "PERM_READ_MESSAGES": "lire les messages", - "PERM_SEND_MESSAGES": "envoyer des messages", - "PERM_SEND_TTS_MESSAGES": "envoyer des messages TTS", - "PERM_MANAGE_MESSAGES": "gérer les messages", - "PERM_EMBED_LINKS": "intégrer des liens", - "PERM_ATTACH_FILES": "attacher des fichiers", - "PERM_READ_MESSAGE_HISTORY": "voir l'historique des messages", - "PERM_MENTION_EVERYONE": "mentionner @everyone", - "PERM_EXTERNAL_EMOJIS": "voir les émojis externes", - "PERM_USE_EXTERNAL_EMOJIS": "utiliser des émojis externes", - "PERM_CONNECT": "se connecter", - "PERM_SPEAK": "parler", - "PERM_MUTE_MEMBERS": "couper le micro des membres", - "PERM_DEAFEN_MEMBERS": "mettre en sourdine des membres", - "PERM_MOVE_MEMBERS": "déplacer des membres", - "PERM_USE_VAD": "utiliser la détection de la voix", - "PERM_CHANGE_NICKNAME": "changer de pseudo", - "PERM_MANAGE_NICKNAMES": "gérer les pseudos", - "PERM_MANAGE_ROLES": "gérer les rôles", - "PERM_MANAGE_WEBHOOKS": "gérer les webhooks", - "PERM_MANAGE_EMOJIS": "gérer les émojis", - "JOINS_RELATED_BLOCKS": "Blocks relatifs aux arrivées de membre", - "DETECT_JOINS": "Détecter les arrivées", - "ON_MEMBER_JOIN": "Quand un membre rejoint le serveur", - "JOINING_MEMBER_INFORMATIONS": "Informations sur l'arrivant", - "JOINING_MEMBER": "membre arrivant", - "JOINING_GUILD": "serveur du membre arrivant", - "RELATED_TO_JOIN_STRINGS": "Chaînes relatives à l'arrivée", - "JOINING_MEMBER_RAW": "%1 du membre arrivant", - "JOINING_GUILD_RAW": "%1 du serveur du membre arrivant", - "TEMPORARILY": "Temporairement", - "HOURS": "heures", - "REASON": "raison", - "DURING_HOURS": "durant", - "WITH_REASON": "pour la raison", - "RES_MUST_BE_IN_ON_MESSAGE": "Ce block ne peut être utilisé que dans un évènement \"Quand un message est reçu\"", - "RES_MISSING_CONTENT": "Vous devez préciser un contenu valide à répondre !", - "RES_MISSING_MEMBER_HAS_PERMISSION": "Vous devez préciser un membre valide à qui vérifier les permissions !", - "RES_MUST_BE_IN_ON_MEMBER_JOIN": "Ce block ne peut être utilisé que dans un évènement \"Quand un membre rejoint le serveur\"", - "RES_ADD_ROLE_MISSING_ROLE": "Vous devez préciser un nom ou un identifiant de rôle valide à ajouter !", - "RES_ADD_ROLE_MISSING_MEMBER": "Vous devez préciser un membre valide à qui ajouter le rôle !", - "RES_REMOVE_ROLE_MISSING_ROLE": "Vous devez préciser un nom ou un identifiant de rôle valide à enlever !", - "RES_REMOVE_ROLE_MISSING_MEMBER": "Vous devez préciser un membre valide à qui enlever le rôle !", - "RES_KICK_MEMBER_MISSING_MEMBER": "Vous devez préciser un membre valide à expulser !", - "RES_BAN_MEMBER_MISSING_MEMBER": "Vous devez préciser un membre valide à bannir !", - "RES_SEND_MEMBER_MISSING_MEMBER": "Vous devez préciser un membre valide à qui envoyer le message !", - "MANDATORY_BLOCKS": "Blocks obligatoires", - "STARTS_WITH": "%1 commence par %2", - "REPLACE": "dans le texte %1 remplacer %2 par %3", - "RES_REPLACE_STRING": "Vous devez préciser un texte à modifier !", - "RES_REPLACE_REPLACE": "Vous devez préciser ce qu'il faut remplacer dans le texte !", - "RES_REPLACE_WITH": "Vous devez préciser ce avec quoi remplacer dans le texte !", - "INCLUDES": "%1 contient %2", - "RES_INCLUDES_TEXT": "Vous devez préciser un texte dans lequel chercher !", - "RES_INCLUDES_INCLUDES": "Vous devez préciser un texte à rechercher !", - "NEWLINE": "nouvelle ligne", - "FIND_CHANNEL": "Trouver un salon", - "SEND_CHANNEL_LABEL": "Envoyer un message dans le salon trouvé", - "GET_CHANNEL": "obtenir le salon dont le %2 est %1", - "RES_MISSING_CHANNEL_VALUE": "Vous devez préciser un nom ou un identifiant de salon valide !", - "RES_SEND_CHANNEL_CONTENT": "Vous devez préciser un contenu à envoyer !", - "RES_SEND_CHANNEL_CHANNEL": "Vous devez préciser un salon dans lequel envoyer le contenu !", - "SEND_CHANNEL": "envoyer %1 dans le salon %2", - "TOOLBOX_LOGIC": "Logique", - "TOOLBOX_LOOPS": "Boucles", - "TOOLBOX_MATH": "Math", - "TOOLBOX_TEXT": "Texte", - "TOOLBOX_LISTS": "Listes", - "TOOLBOX_COLORS": "Couleurs", - "TOOLBOX_VARIABLES": "Variables", - "TOOLBOX_FUNCTIONS": "Fonctions", - "TOOLBOX_CHANNELS": "Salons", - "TOOLBOX_ACTIONS": "Actions", - "TOOLBOX_BASE": "Base", - "TOOLBOX_SERVER": "Serveurs", - "TOOLBOX_ROLES": "Rôles", - "TOOLBOX_MEMBERS": "Membres", - "FIND_SERVER": "Trouver un serveur", - "GET_SERVER": "obtenir le serveur dont le %2 est %1", - "RES_GET_SERVER_SERVER": "Vous devez préciser un nom ou un identifiant de serveur valide !", - "LABEL_SERVER_INFOS": "Informations sur le serveur", - "MEMBER_COUNT": "nombre de membres du serveur %1", - "RES_VALID_SERVER": "Vous devez préciser un serveur valide !", - "ICON_URL": "URL de l'icône du serveur %1", - "SERVER_NAME": "nom du serveur %1", - "SERVER_OWNER": "propriétaire du serveur %1", - "RES_SET_SERVER_NAME_SERVER": "Vous devez préciser un serveur valide à qui changer le nom !", - "RES_SET_SERVER_NAME_NEW_NICKNAME": "Vous devez préciser un nouveau nom valide pour le serveur !", - "LABEL_MODIFY_SERVER": "Modifier le serveur", - "SET_SERVER_NAME": "changer le nom du serveur %1 nouveau nom %2", - "GET_ROLE_SERVER": "sur le serveur", - "GET_ROLE": "obtenir le rôle dont le %2 est %1", - "RES_GET_ROLE_VALUE": "Vous devez préciser un nom ou un identifiant de rôle valide !", - "RES_GET_SERVER_VALUE": "Vous devez préciser un nom ou un identifiant de serveur valide !", - "FIND_ROLE": "Trouver un rôle", - "ROLE_ASSIGNMENT": "Affectation des rôles", - "RES_GET_MEMBER_VALUE": "Vous devez préciser un nom ou un identifiant de membre valide !", - "RES_GET_MEMBER_SERVER": "Vous devez préciser un serveur valide sur lequel chercher le membre !", - "MEMBER_INFORMATIONS": "Informations des membres", - "RES_VALID_MEMBER": "Vous devez préciser un membre valide !", - "MEMBER_DISCRIMINATOR": "discriminateur du membre %1", - "MEMBER_ID": "id du membre %1", - "MEMBER_TAG": "tag du membre %1", - "MEMBER_USERNAME": "pseudo du membre %1", - "MEMBER_IS_BOT": "le membre %1 est un robot", - "GET_MEMBER": "obtenir le membre dont le %2 est %1 sur le serveur %3", - "FIND_MEMBER": "Trouver un membre", - "LABEL_MEMBER_ACTIONS": "Actions sur le membre", - "LABEL_MESSAGE_CONTEXT": "Contexte du message", - "SET_MEMBER_NICKNAME": "changer le surnom du membre %1 nouveau surnom %2", - "RES_SET_MEMBER_NICKNAME_MEMBER": "Vous devez préciser un membre valide à qui changer le surnom !", - "RES_SET_MEMBER_NICKNAME_NEW_NICKNAME": "Vous devez préciser un nouveau surnom valide pour le membre !", - "SERVER_BOOST_COUNT": "nombre de boosts du serveur %1", - "SERVER_BOOST_LEVEL": "niveau de boost du serveur %1", - "SEND_WAIT_REPLY": "envoyer %1 dans le salon %2 et attendre une réponse du membre %3 pendant (minutes) %4 quand une réponse est reçue %5 si aucune réponse n'est reçue %6", - "RES_SEND_WAIT_REPLY_VALUE_PARENT": "Ce block ne peut être utilisé que dans un block \"Attendre une réponse\" !", - "SEND_WAIT_REPLY_VALUE": "réponse du membre", - "FORMS": "Formulaires", - "SEND_WAIT_REPLY_EXAMPLE": "Quel est votre prénom ?", - "REPLY_EXAMPLE": "Salut!", - "ON_REACT_ADDED": "Quand une réaction est ajoutée", - "REACT_RELATED_BLOCKS": "Blocks relatifs aux réactions", - "DETECT_REACT": "Détecter les réactions", - "REACT_INFORMATIONS": "Information sur la réaction ajoutée/enlevée", - "REACT_MESSAGE_ID": "ID du message", - "RES_MUST_BE_IN_ON_REACT": "Ce block ne peut être utilisé que dans un block \"réaction ajoutée\" ou \"réaction enlevée\" !", - "REACT_EMOJI": "émoji de la réaction", - "REACT_MEMBER": "membre réagissant", - "ON_REACT_REMOVED": "Quand une réaction est enlevée", - "BOT_PING": "ping du bot", - "BOT_INFORMATIONS": "Informations about the bot", - "BOT_ACTIONS": "Actions sur le bot", - "RES_MISSING_GAME": "Vous devez préciser un jeu pour le bot !", - "SET_BOT_GAME": "définir le jeu du bot à %1", - "BOT_SERVER_COUNT": "nombre de serveurs du bot", - "TOOLBOX_E_JOINS": "Arrivées", - "TOOLBOX_E_MESSAGES": "Messages", - "TOOLBOX_E_REACTIONS": "Réactions", - "TOOLBOX_DATABASE": "Base de données", - "GET_DATA": "obtenir %1 dans la base de données", - "LABEL_READ_DB": "Lire la base de données", - "LABEL_UPDATE_DB": "Modifier la base de données", - "SET_DATA": "définir %1 à %2 dans la base de données", - "DELETE_DATA": "supprimer %1 de la base de données", - "HAS_DATA": "%1 existe dans la base de données", - "ADD_DATA": "ajouter %1 à %2", - "SUBTRACT_DATA": "soustraire %1 à %2", - "DETECT_LEAVES": "Détecter les départs", - "LEAVING_GUILD": "serveur du membre partant", - "LEAVING_GUILD_RAW": "%1 du serveur du membre partant", - "LEAVING_MEMBER_INFORMATIONS": "Informations sur le membre", - "LEAVES_RELATED_BLOCKS": "Blocks relatifs aux départs de membre", - "ON_MEMBER_LEAVE": "Quand un membre part d'un serveur", - "RELATED_TO_LEAVE_STRINGS": "Chaînes relatives au départ", - "TOOLBOX_E_LEAVES": "Départs", - "RES_MUST_BE_IN_ON_MEMBER_LEAVE": "Ce block ne peut être utilisé que dans un évènement \"Quand un membre part d'un serveur\"", - "LEAVING_MEMBER_RAW": "%1 du membre partant", - "WAIT_SECONDS": "attendre %1 secondes", - "TOOLBOX_OTHER": "Autre", - "RUN_SAVE_OUTPUT": "faire %1 et sauvegarder le résultat dans %2", - "TOOLBOX_MESSAGES": "Messages", - "GET_MESSAGE": "obtenir le message dont l'ID est %1 dans le salon %2", - "RES_GET_MESSAGE_CHANNEL": "Vous devez préciser un salon valide sur lequel chercher le message!", - "RES_GET_MESSAGE_VALUE": "Vous devez préciser un identifiant de message valide!", - "FIND_MESSAGE": "Trouver le message", - "MESSAGE_INFORMATIONS": "Informations sur le message", - "CURRENT": "%1 actuelle", - "HOUR": "heure", - "MINUTE": "minute", - "MONTH": "mois", - "DAY_OF_WEEK": "jour de la semaine", - "SECOND": "seconde", - "DATE": "date", - "FOREVER": "répéter indéfiniement %1 faire %2", - "YES": "oui", - "NO": "non", - "CREATE_CHANNEL": "créer un salon avec comme nom %1 sur le serveur %2 de type %3", - "CHANNEL_ACTIONS": "Actions sur le salon", - "TEXT": "textuel", - "VOICE": "vocal", - "CATEGORY": "catégorie" -} diff --git a/src/locales/fr.js b/src/locales/fr.js deleted file mode 100644 index 86266b60f..000000000 --- a/src/locales/fr.js +++ /dev/null @@ -1,91 +0,0 @@ -import Blockly from "blockly"; - -import blocklyMessages from "./fr-FR.json"; - -export const applyBlocklyLocale = () => { - for(let key in blocklyMessages){ - Blockly.Msg[key] = blocklyMessages[key]; - } -}; - -export const websiteMessages = { - untitled: "Document sans titre", - help: "Aide", - load: { - error: "Le fichier téléversé est corrompu et ne peut pas être chargé par Scratch For Discord..." - }, - file: { - title: "Fichier", - javascript: "Exporter vers Javascript", - open: "Ouvrir un fichier...", - save: "Sauvegarder" - }, - edit: { - title: "Modifier", - undo: "Annuler", - redo: "Rétablir", - clear: "Nettoyer {blockCount} blocks", - cleanup: "Réorganiser les blocks", - cleardb: "Effacer la base de données" - }, - lang: { - title: "Langue" - }, - examples: { - title: "Exemples", - confirm: { - title: "Supprimer les blocks", - text: "Souhaitez-vous supprimer les blocks du projet actuel avant d'importer l'exemple ?", - cancel: "Annuler", - yes: "Oui", - no: "Non" - }, - loaded: "Exemple {example} importé avec succès !", - ping_pong: "Commande ping-pong", - command_parsing: "Traitement des commandes", - leveling: "Système d'XP et niveaux" - }, - download: { - title: "Télécharger votre bot", - content: { - title: "Comment lancer votre bot une fois le bot téléchargé ?", - unzipFile: "Dézippez le fichier obtenu.", - node: "Installez NPM et Node.js (cherchez des tutos sur google)", - start: "Tapez 'npm install' et 'npm start' dans votre terminal", - done: "Votre bot est lancé!" - }, - cancel: "Annuler", - confirm: "Télécharger" - }, - tour: { - skip: "Sauter la visite", - previous: "Précédent", - next: "Suivant", - finish: "Finir", - steps: { - load_examples: "Importer des exemples pour découvrir Scratch4Discord!", - run_test: "Testez le fonctionnement de votre bot ici!", - export_code: "Exportez votre code ici!" - } - }, - warnings: { - login_block: "Le block \"Connexion à Discord\" de la catégorie \"Base\" est obligatoire !" - }, - run_modal: { - title: "Appuyez sur démarrer pour tester votre bot!", - start: "Démarrer le bot", - stop: "Arrêter le bot", - invalid_token: "Impossible de se connecter à Discord... Peut-être que le token du bot n'est pas valide !", - error: "Impossible de se connecter à Discord... Réessayez plus tard!", - disabled: "⚠️ Cette fonction n'est disponible qu'avec l'application Scratch For Discord (obtenez la {here})", - here: "ici" - }, - code_modal: { - title: "Code JavaScript de votre bot" - } -}; - -export default { - applyBlocklyLocale, - websiteMessages -}; diff --git a/src/locales/pt-BR.json b/src/locales/pt-BR.json deleted file mode 100644 index c09fb18d0..000000000 --- a/src/locales/pt-BR.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "BASE_BLOCKS": "Blocos de base", - "MESSAGE_RELATED_BLOCKS": "Bloqueios relacionados a mensagens", - "REPLY": "responder %1", - "LOGIN": "Conecte-se ao Discord com o token %1", - "LOGIN_TOOLTIP": "Conecte seu bot ao Discord. Para obter seu token de bot, vá para https://discord.com/developers/.", - "ON_MESSAGE": "Quando uma mensagem é recebida", - "ON_CONNECTED": "Quando o bot está conectado", - "ON_CONNECTED_TOOLTIP": "Evento emitido quando seu bot está conectado ao Discord.", - "MESSAGE_ID": "message ID", - "MESSAGE_CONTENT": "conteudo da mensagem", - "MESSAGE_AUTHOR": "autor da mensagem", - "MESSAGE_AUTHOR_RAW": "%1 do autor da mensagem", - "USERNAME": "apelido", - "NICKNAME": "sobrenome", - "GET_GUILD": "encontre servidor %1 usando %2", - "NAME": "nome", - "REPLACE": "no texto %1 troque %2 com %3", - "RES_REPLACE_STRING": "Você precisa me ta um texto para troca!", - "RES_REPLACE_REPLACE": "Você precisa me fala oque você quer troca no texto!", - "RES_REPLACE_WITH": "Você precisa me fala com qual vai ser o novo valor!", - "ADD_ROLE": "adicione cargo %1 do membro %2", - "INCLUDES": "%1 tem %2", - "RES_INCLUDES_TEXT": "Você precisa me ta um texto para ver se tem algo nele!", - "RES_INCLUDES_INCLUDES": "Você precisa me ta um texto para ver se tem no outro texto!", - "BAN_MEMBER": "banir membro %1", - "KICK_MEMBER": "kicka membro %1", - "SEND_MEMBER": "send %1 to member %2", - "MESSAGE_GUILD": "servidor da mensagem", - "MESSAGE_CHANNEL": "canal da mensagem", - "BASIC_BLOCKS": "blocos basicos", - "ADVANCED_BLOCKS": "blocos avançados", - "MENTIONED_MEMBER": "membro mensianado", - "PURGE": "no canal %1 delete %2 memsagens", - "CHANNEL_MESSAGE_ACTIONS": "Ações nas mensagens do canal", - "RES_PURGE_AMOUNT": "Você precisa especifica a quantidade de mensagens para deleta!", - "RES_PURGE_CHANNEL": "Voce precisa especifica o canal!", - "FOOTER": "footer", - "THUMBNAIL": "thumbnail", - "ADMINISTRATOR": "Administrator", - "DETECT_MESSAGES": "Detectar mensagem", - "MESSAGE_ACTIONS": "Ações na mensagem", - "RELATED_TO_MESSAGE_STRINGS": "Strings relacionadas à mensagem", - "DELETE_MESSAGE": "deleta a mensagem", - "RES_ADD_REACTION_MISSING_REACTION": "você precisa adiciona um emoji valido !", - "ADD_REACTION": "adiciona reação %1 para a mensagem", - "MESSAGE_EMBED": "Message Embed", - "COLOR": "cor", - "TITLE": "titulo", - "MESSAGE": "mensagem", - "IMAGE": "image", - "TOOLS": "ferramentas", - "CHECK_PERMISSIONS": "Verifique as permissões dos membros", - "MEMBER_HAS_PERMISSION": "o membro %1 tem permissão %2", - "PERM_CREATE_INSTANT_INVITE": "criar convites instantâneos", - "PERM_KICK_MEMBERS": "kicka membros", - "PERM_BAN_MEMBERS": "banir membros", - "PERM_ADMINISTRATOR": "administrator", - "PERM_MANAGE_CHANNELS": "gerenciar canais", - "PERM_MANAGE_GUILD": "gerenciar servidores", - "PERM_ADD_REACTIONS": "adiciona reação", - "PERM_VIEW_AUDIT_LOG": "ver registros de auditoria", - "PERM_PRIORITY_SPEAKER": "Voz Prioritária", - "PERM_VIEW_CHANNEL": "ver canal", - "PERM_READ_MESSAGES": "ler mensagens", - "PERM_SEND_MESSAGES": "mandar mensagens", - "PERM_SEND_TTS_MESSAGES": "manda TTS mensagens", - "PERM_MANAGE_MESSAGES": "gerenciar mensagens", - "PERM_EMBED_LINKS": "embed links", - "PERM_ATTACH_FILES": "anexar arquivos", - "PERM_READ_MESSAGE_HISTORY": "ler histórico de mensagens", - "PERM_MENTION_EVERYONE": "mencionar @everyone", - "PERM_EXTERNAL_EMOJIS": "ver emojis externos", - "PERM_USE_EXTERNAL_EMOJIS": "usar emojis externos", - "PERM_CONNECT": "conectar", - "PERM_SPEAK": "falar", - "PERM_MUTE_MEMBERS": "mutar membros", - "PERM_DEAFEN_MEMBERS": "membros surdos", - "PERM_MOVE_MEMBERS": "mover membros", - "PERM_USE_VAD": "usar atividade de voz", - "PERM_CHANGE_NICKNAME": "troca sobrenome", - "PERM_MANAGE_NICKNAMES": "gerenciar sobrenomes", - "PERM_MANAGE_ROLES": "gerenciar cargos", - "PERM_MANAGE_WEBHOOKS": "gerenciar webhooks", - "PERM_MANAGE_EMOJIS": "Blocos relacionados a associações de membros", - "DETECT_JOINS": "Detectar entrada", - "ON_MEMBER_JOIN": "Quando um membro se junta a um servidor", - "JOINING_MEMBER_INFORMATIONS": "Informações sobre o membro", - "JOINING_MEMBER": "membro entrado", - "RELATED_TO_JOIN_STRINGS": "Strings relacionadas a entrada", - "JOINING_MEMBER_RAW": "%1 do membro que entrou", - "JOINING_GUILD": "servidor onde o membro entrou", - "TEMPORARILY": "Temporariamente", - "HOURS": "horas", - "REASON": "motivo", - "DURING_HOURS": "durante", - "WITH_REASON": "com o motivo", - "RES_MUST_BE_IN_ON_MESSAGE": "Este bloco só pode ser usado em um \"Quando uma mensagem é recebida\" evento", - "RES_MISSING_CONTENT": "Você deve especificar um conteúdo válido para responder!", - "RES_MISSING_MEMBER_HAS_PERMISSION": "Você deve especificar um membro válido para verificar as permissões!", - "RES_MUST_BE_IN_ON_MEMBER_JOIN": "Este bloco só pode ser usado em um \"Quando um membro se junta a um servidor\" evento", - "RES_ADD_ROLE_MISSING_ROLE": "Você deve especificar um nome ou ID de um cargo válido para adicionar!", - "RES_ADD_ROLE_MISSING_MEMBER": "você teve especifica um membro valido para adiciona o cargo nele!", - "RES_REMOVE_ROLE_MISSING_ROLE": "Você deve especificar um nome ou ID de um cargo válido para remove", - "RES_REMOVE_ROLE_MISSING_MEMBER": "você teve especifica um membro valido para remove o cargo nele!", - "RES_KICK_MEMBER_MISSING_MEMBER": "você teve especifica um membro valido para ser kickado!", - "RES_BAN_MEMBER_MISSING_MEMBER": "você teve especifica um membro valido para ser banido!", - "RES_SEND_MEMBER_MISSING_MEMBER": "You must specify a valid member to send the message to!", - "MANDATORY_BLOCKS": "Blocos obrigatorios", - "FIND_CHANNEL": "Encontre um canal", - "SEND_CHANNEL_LABEL": "Envie uma mensagem no canal encontrado", - "GET_CHANNEL": "pegue o salão com %2 igual a %1", - "RES_MISSING_CHANNEL_VALUE": "você teve especifica um nome ou id de um canal valido!", - "RES_SEND_CHANNEL_CONTENT": "você teve especifica um conteudo para manda!", - "RES_SEND_CHANNEL_CHANNEL": "Você deve especificar um canal para enviar o conteúdo!", - "SEND_CHANNEL": "envie %1 no canal %2", - "TOOLBOX_LOGIC": "Logica", - "TOOLBOX_LOOPS": "Loops", - "TOOLBOX_MATH": "Matematica", - "TOOLBOX_TEXT": "Texto", - "TOOLBOX_LISTS": "Listas", - "TOOLBOX_COLORS": "Cors", - "TOOLBOX_VARIABLES": "Variaveis", - "TOOLBOX_FUNCTIONS": "Funções", - "TOOLBOX_CHANNELS": "Canais", - "TOOLBOX_ACTIONS": "Ações", - "TOOLBOX_BASE": "Base", - "TOOLBOX_SERVER": "Servers", - "TOOLBOX_ROLES": "Cargos", - "FIND_SERVER": "Encontre um servidor", - "GET_SERVER": "encontre um servidor com %2 igual a %1", - "RES_GET_SERVER_SERVER": "você precisa especifica um nome ou id de um servidor valido!", - "LABEL_SERVER_INFOS": "Informações sobre o servidor", - "MEMBER_COUNT": "numero de membros no servidor %1", - "RES_VALID_SERVER": "você precisa coloca um servidor valido!", - "ICON_URL": "icone url do servidor %1", - "SERVER_NAME": "nome do servidor %1", - "SERVER_OWNER": "dono do servidor %1", - "RES_SET_SERVER_NAME_SERVER": "você precisa especifica um servidor valido!", - "RES_SET_SERVER_NAME_NEW_NICKNAME": "você precisa especifica um nome novo valido!", - "LABEL_MODIFY_SERVER": "Modifique o servidor", - "SET_SERVER_NAME": "troque o nome do servidor %1 nome novo %2", - "GET_ROLE_SERVER": "no servidor", - "GET_ROLE": "pegue o cargo com %2 igual a %1", - "RES_GET_ROLE_VALUE": "você precisa especifica um nome ou id de um cargo valido!", - "RES_GET_SERVER_VALUE": "você precisa especifica um nome ou id de um servidor valido!", - "FIND_ROLE": "Encontre um cargo", - "ROLE_ASSIGNMENT": "Atribuição de cargos", - "FIND_MEMBER": "Encontre um membro", - "GET_MEMBER": "encontre um membro com %2 igual a %1 no servidor %3", - "INIT_TOOLTIP": "Permite que você use blocos Discord!", - "JOINING_GUILD_RAW": "%1 do membro que entrou no servidor", - "LABEL_MEMBER_ACTIONS": "Ações no membro", - "LABEL_MESSAGE_CONTEXT": "Contexto da mensagem", - "MESSAGE_CHANNEL_RAW": "%1 do canal da mensagem", - "MESSAGE_GUILD_RAW": "%1 do servidor da mensagem", - "RES_GET_MEMBER_SERVER": "você precisa especifica um servidor valido onde o membro esta!", - "RES_GET_MEMBER_VALUE": "você precisa especifica um nome ou id de um membro valido!", - "TOOLBOX_MEMBERS": "Membro", - "MEMBER_INFORMATIONS": "Informações dos membros", - "RES_VALID_MEMBER": "Você deve especificar um membro válido!", - "MEMBER_DISCRIMINATOR": "discriminador de membro %1", - "MEMBER_ID": "id do membro %1", - "MEMBER_TAG": "tag do membro %1", - "MEMBER_USERNAME": "sobrenome do membro %1", - "MEMBER_IS_BOT": "membro %1 é um bot", - "SET_MEMBER_NICKNAME": "troque o apelido %1 novo apelido %2", - "RES_SET_MEMBER_NICKNAME_MEMBER": "Você deve especificar um membro válido para alterar o apelido", - "RES_SET_MEMBER_NICKNAME_NEW_NICKNAME": "Você deve especificar um novo apelido válido para o membro!", - "SERVER_BOOST_COUNT": "numero de impulsos no servidor %1", - "SERVER_BOOST_LEVEL": "nível de impulso do servidor %1", - "SEND_WAIT_REPLY": "envie %1 no canal %2 e espere por uma resposta do membro %3 durante (minutos) %4 quando uma resposta é recebida %5 se nenhuma responde vo recebida %6", - "RES_SEND_WAIT_REPLY_VALUE_PARENT": "Este bloco só pode ser usado em um bloco \"Aguardar uma resposta\"!", - "SEND_WAIT_REPLY_VALUE": "resposta do membro", - "FORMS": "Formulários", - "SEND_WAIT_REPLY_EXAMPLE": "Qual é o seu nome??", - "REPLY_EXAMPLE": "Hey!", - "ON_REACT_ADDED": "Quando uma reação é adicionada", - "REACT_RELATED_BLOCKS": "Blocos relacionados a reações", - "DETECT_REACT": "Eu estou escrevendo, estou escrevendo", - "REACT_INFORMATIONS": "Informações sobre a reação adicionada / removida", - "REACT_MESSAGE_ID": "ID da mensagem de reação", - "RES_MUST_BE_IN_ON_REACT": "Este bloco só pode ser usado em um bloco de \"reação adicionada\" ou em um bloco \"reação removida\"!", - "REACT_EMOJI": "emoji da reação", - "REACT_MEMBER": "membro que reaciu", - "ON_REACT_REMOVED": "Quando uma reação é removida", - "BOT_PING": "bot ping", - "BOT_INFORMATIONS": "Informação do bot", - "BOT_ACTIONS": "Ações no bot", - "RES_MISSING_GAME": "Você deve especificar um jogo para o bot!", - "SET_BOT_GAME": "definir o jogo de bot para %1", - "BOT_SERVER_COUNT": "contagem de servidores bot", - "TOOLBOX_E_JOINS": "Entradas", - "TOOLBOX_E_MESSAGES": "Mensagems", - "TOOLBOX_E_REACTIONS": "Reações", - "TOOLBOX_DATABASE": "Banco de dados", - "GET_DATA": "pegue %1 do banco de dados", - "LABEL_READ_DB": "banco de dados", - "LABEL_UPDATE_DB": "atualiza banco de dados", - "SET_DATA": "setar %1 para %2 no banco de dados", - "DELETE_DATA": "deletar %1 banco de dados", - "HAS_DATA": "%1 existe no banco de dados", - "ADD_DATA": "adiciona %1 para %2", - "SUBTRACT_DATA": "remover %1 do %2", - "DETECT_LEAVES": "Detectar licenças", - "LEAVING_GUILD": "deixando o servidor membro", - "LEAVING_GUILD_RAW": "%1 do servidor do membro que está saindo", - "LEAVING_MEMBER_INFORMATIONS": "Informações sobre o membro", - "LEAVES_RELATED_BLOCKS": "Bloqueios relacionados às saídas de membros", - "ON_MEMBER_LEAVE": "Quando um membro sai de um servidor", - "RELATED_TO_LEAVE_STRINGS": "Strings relacionados a saida", - "TOOLBOX_E_LEAVES": "Saidas", - "RES_MUST_BE_IN_ON_MEMBER_LEAVE": "Este bloco só pode ser usado em um evento \"Quando um membro deixa um servidor \"", - "LEAVING_MEMBER_RAW": "%1 do membro que saiu do servidor", - "WAIT_SECONDS": "espere %1 segundos", - "TOOLBOX_OTHER": "Outros", - "STARTS_WITH": "%1 começa com %2", - "RUN_SAVE_OUTPUT": "faça %1 e salve a saída em %2", - "TOOLBOX_MESSAGES": "mensagens", - "GET_MESSAGE": "obter mensagem com ID igual a %1 no canal %2", - "RES_GET_MESSAGE_CHANNEL": "Você deve especificar um canal válido no qual a mensagem é!", - "RES_GET_MESSAGE_VALUE": "Você deve especificar um ID de mensagem válido!", - "FIND_MESSAGE": "Encontre a mensagem", - "MESSAGE_INFORMATIONS": "Informações sobre a mensagem", - "CURRENT": "%1 atual", - "HOUR": "hora", - "MINUTE": "minuto", - "MONTH": "mês", - "DAY_OF_WEEK": "dia da semana", - "SECOND": "segundo", - "DATE": "data", - "FOREVER": "repita para sempre %1 faz %2", - "YES": "sim", - "NO": "não", - "CREATE_CHANNEL": "crie um canal com o nome %1 no servidor %2 do tipo %3", - "CHANNEL_ACTIONS": "Ações para o canal", - "TEXT": "texto", - "VOICE": "voz", - "CATEGORY": "categoria", - "NEWLINE": "linha nova", - "REMOVE_ROLE": "tira o cargo %1 do membro %2", - "JOINS_RELATED_BLOCKS": "Blocos relacionados a entrada de membros" -} diff --git a/src/locales/pt.js b/src/locales/pt.js deleted file mode 100644 index aba7198e9..000000000 --- a/src/locales/pt.js +++ /dev/null @@ -1,91 +0,0 @@ -import Blockly from "blockly"; - -import blocklyMessages from "./pt-BR.json"; - -export const applyBlocklyLocale = () => { - for(let key in blocklyMessages){ - Blockly.Msg[key] = blocklyMessages[key]; - } -}; - -export const websiteMessages = { - untitled: "Documento sem nome", - help: "Ajuda", - load: { - error: "O arquivo enviado está corrompido e não pode ser carregado pelo Scratch For Discord..." - }, - file: { - title: "Arquivo", - javascript: "Exporta para javascirpt", - open: "abrir arquivo...", - save: "Salva" - }, - edit: { - title: "Edita", - undo: "desfazer", - redo: "refazer", - clear: "deleta {blockCount} blocos", - cleanup: "limpa blocos", - cleardb: "limpa database" - }, - lang: { - title: "linguagem" - }, - examples: { - title: "Exemplos", - confirm: { - title: "Deleta os blocos atual?", - text: "Você gostaria de remover os blocos do projeto atual antes de importar o exemplo?", - cancel: "Cancela", - yes: "Sim", - no: "Não" - }, - loaded: "Exemplo {example} importando com sucesso!", - ping_pong: "comando ping-pong", - command_parsing: "handler de comandos", - leveling: "XP e sistema de níveis" - }, - download: { - title: "Instale o seu bot", - content: { - title: "Como iniciar o seu bot depois de baixado?", - unzipFile: "Descompacte o arquivo baixado.", - node: "Instale o NPM e o Node.js (pesquise tutoriais no Google)", - start: "Execute 'npm install' e 'npm start' em um terminal", - done: "Seu bot foi iniciado!" - }, - cancel: "Cancela", - confirm: "Instala" - }, - tour: { - skip: "Pular tour", - previous: "Anterior", - next: "Próximo", - finish: "Termina", - steps: { - load_examples: "Importe exemplos para descobrir Scratch4Discord!", - run_test: "Teste as funcionalidades do seu bot aqui!", - export_code: "Exporte seu código aqui!" - } - }, - warnings: { - login_block: "O bloco \"Conectar ao Discord\" na categoria \"Base\" é obrigatório." - }, - run_modal: { - title: "Clique em Iniciar para testar seu bot!", - start: "Inicie o bot", - stop: "Pare o bot", - invalid_token: "Unable to connect to Discord... Maybe the bot's token isn't valid!", - error: "Incapaz de conectar ao Discord ... Talvez o token do bot não seja válido!", - disabled: "⚠️ Este recurso está disponível apenas usando o aplicativo Scratch For Discord (pegue ele {here})", - here: "aqui" - }, - code_modal: { - title: "Código JavaScript do seu bot" - } -}; - -export default { - applyBlocklyLocale, - websiteMessages -}; diff --git a/src/main.js b/src/main.js index 6599b9e97..b76ee7dda 100755 --- a/src/main.js +++ b/src/main.js @@ -26,17 +26,11 @@ Vue.config.productionTip = false; Vue.config.ignoredElements = ["field","block","category","xml","mutation","value","sep"]; import blocklyLocaleEN from "blockly/msg/en"; -import blocklyLocaleFR from "blockly/msg/fr"; -import blocklyLocalePT from "blockly/msg/pt"; import customLocaleEN from './locales/en'; -import customLocaleFR from './locales/fr'; -import customLocalePT from './locales/pt'; const messages = { - en: customLocaleEN.websiteMessages, - fr: customLocaleFR.websiteMessages, - pt: customLocalePT.websiteMessages + en: customLocaleEN.websiteMessages }; const i18n = new Vuei18n({ @@ -95,24 +89,6 @@ Vue.mixin({ // Change website languages (navbar, etc...) this.$root.$i18n.locale = "en"; break; - case "fr": - // Change Blockly language for default blocks - Blockly.setLocale(blocklyLocaleFR); - // Change Blockly language for custom blocks - customLocaleFR.applyBlocklyLocale(); - // Change website languages (navbar, etc...) - this.$root.$i18n.locale = "fr"; - break; - case "pt": - // Change Blockly language for default blocks - Blockly.setLocale(blocklyLocalePT); - // Change Blockly language for custom blocks - customLocalePT.applyBlocklyLocale(); - // Change website languages (navbar, etc...) - this.$root.$i18n.locale = "pt"; - break; - default: - break; } }, getWorkspaceCode(){ @@ -121,6 +97,8 @@ Vue.mixin({ (async()=>{ const Discord = require("discord.js"); const Database = require("easy-json-database"); + const os = require("os"); + const process = require("process"); const devMode = typeof __E_IS_DEV !== "undefined" && __E_IS_DEV; const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const s4d = { @@ -137,7 +115,7 @@ Vue.mixin({ }; s4d.client = new s4d.Discord.Client({ intents: [Object.values(s4d.Discord.Intents.FLAGS).reduce((acc, p) => acc | p, 0)], - partials: ["REACTION"] + partials: ["REACTION", "CHANNEL"] }); ${Blockly.JavaScript.workspaceToCode(this.$store.state.workspace)} diff --git a/src/prompt.js b/src/prompt.js index 8ce7de381..78f44a738 100755 --- a/src/prompt.js +++ b/src/prompt.js @@ -39,6 +39,7 @@ Blockly.prompt = function(msg, defaultValue, callback) { }, showCancelButton: true, confirmButtonText: "Look up", + ADD_START_HATS: true, showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then(result => { diff --git a/src/toolbox.js b/src/toolbox.js index 5e0ad8433..f91c471c0 100644 --- a/src/toolbox.js +++ b/src/toolbox.js @@ -392,6 +392,7 @@ export default (Blockly) => { + @@ -399,6 +400,8 @@ export default (Blockly) => { + + @@ -436,6 +439,19 @@ export default (Blockly) => { + + + FALSE + + + + + {{ REPLY_EXAMPLE }} + + + + + {{ REPLY_EXAMPLE }} @@ -450,9 +466,155 @@ export default (Blockly) => { + + + + + + + + + + + + + + + + + + {{ REPLY_EXAMPLE }} + + + + + FALSE + + + + + + + 👍 + + + + + + + + + + + + + + + + + + + FALSE + + + + + {{ REPLY_EXAMPLE }} + + + + + + + + + + + + + + + + + + + + + + + + + + {{ REPLY_EXAMPLE }} + + + + + + + + 👍 + + + + @@ -501,7 +663,14 @@ export default (Blockly) => { - + + + + {{ REPLY_EXAMPLE }} + + + + @@ -528,6 +697,7 @@ export default (Blockly) => { + @@ -535,6 +705,8 @@ export default (Blockly) => { + + @@ -544,6 +716,8 @@ export default (Blockly) => { + +