Skip to content

Commit

Permalink
🔀 Merge develop branch for 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Apr 15, 2020
2 parents f9acacd + c3a16a7 commit 123cf51
Show file tree
Hide file tree
Showing 44 changed files with 1,243 additions and 552 deletions.
12 changes: 6 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="app">
<NavBarComponent></NavBarComponent>
<NavBarComponent id="navSpace"></NavBarComponent>
<BlocklyComponent id="blocklySpace" :options="options"></BlocklyComponent>
<v-tour name="start-tour" :steps="vueTourOptions.steps" :options="vueTourOptions"></v-tour>
</div>
Expand All @@ -12,15 +12,16 @@ import Blockly from "blockly";
import NavBarComponent from "./components/NavigationBar/NavigationBar.vue";
import BlocklyComponent from "./components/BlocklyComponent.vue";
import toolbox from "./toolbox";
Blockly.Tooltip.HOVER_MS = 100;
// Load blocks
import "./blocks/discord/actions/";
import "./blocks/discord/base/";
import "./blocks/discord/joins/";
import "./blocks/discord/message/";
import "./blocks/discord/channels/";
import "./blocks/discord/servers/";
import "./blocks/discord/roles/";
import "./blocks/discord/members/";
import "./blocks/text/";
import "./prompt";
Expand Down Expand Up @@ -57,8 +58,7 @@ export default {
maxScale: 3,
minScale: 0.3,
scaleSpeed: 1.2
},
toolbox
}
},
vueTourOptions: {
labels: {
Expand Down
204 changes: 0 additions & 204 deletions src/blocks/discord/actions/_text_join.test.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/blocks/discord/actions/index.js

This file was deleted.

59 changes: 59 additions & 0 deletions src/blocks/discord/channels/get_channel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as Blockly from "blockly/core";
import { registerRestrictions } from "../../../restrictions";

const blockName = "s4d_get_channel";

const blockData = {
"message0": "%{BKY_GET_CHANNEL}",
"args0": [
{
"type": "input_value",
"name": "VALUE",
"check": "String"
},
{
"type": "field_dropdown",
"name": "SEARCH_TYPE",
"options": [
[
"%{BKY_NAME}",
"NAME"
],
[
"id",
"ID"
]
]
}
],
"colour": "#a55b80",
"output": "Channel",
"tooltip": "",
"helpUrl": ""
};

Blockly.Blocks[blockName] = {
init: function() {
this.jsonInit(blockData);
}
};

Blockly.JavaScript[blockName] = function(block){
const value = Blockly.JavaScript.valueToCode(block, "VALUE", Blockly.JavaScript.ORDER_ATOMIC);
const searchType = block.getFieldValue("SEARCH_TYPE");
if(searchType === "NAME"){
return [ `s4d.client.channels.cache.find((channel) => channel.name === ${value}`, Blockly.JavaScript.ORDER_NONE ];
} else {
return [ `s4d.client.channels.cache.get(${value})`, Blockly.JavaScript.ORDER_NONE ];
}
};

registerRestrictions(blockName, [
{
type: "notempty",
message: "RES_MISSING_CHANNEL_VALUE",
types: [
"VALUE"
]
}
]);
2 changes: 2 additions & 0 deletions src/blocks/discord/channels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./get_channel";
import "./send_channel";
66 changes: 66 additions & 0 deletions src/blocks/discord/channels/send_channel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import * as Blockly from "blockly/core";
import { registerRestrictions } from "../../../restrictions";

const blockName = "s4d_send_channel";

const blockData = {
"message0": "%{BKY_SEND_CHANNEL}",
"args0": [
{
"type": "input_value",
"name": "CONTENT",
"check": [ "MessageEmbed", "String", "Number" ]
},
{
"type": "input_value",
"name": "CHANNEL",
"check": "Channel"
},
],
"colour": "#4C97FF",
"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 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_[0];
if(contentType === "MessageEmbed"){
const code = `${channel}.send({ embed: ${content} });\n`;
return code;
} else {
const code = `${channel}.send(String(${content}));\n`;
return code;
}
} else {
const code = `${channel}.send(String(${content}));\n`;
return code;
}
};

registerRestrictions(blockName, [
{
type: "notempty",
message: "RES_SEND_CHANNEL_CONTENT",
types: [
"CONTENT"
]
},
{
type: "notempty",
message: "RES_SEND_CHANNEL_CHANNEL",
types: [
"CHANNEL"
]
}
]);
1 change: 1 addition & 0 deletions src/blocks/discord/joins/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./joining_guild";
import "./joining_guild_raw";
import "./joining_member";
import "./joining_member_raw";
import "./on_member_join";
Loading

0 comments on commit 123cf51

Please sign in to comment.