Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test preview #455

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.16.1
v16.10.0
1 change: 1 addition & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run="npm run start"
29,134 changes: 29,134 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@blockly/block-test": "^1.1.5",
"@blockly/continuous-toolbox": "^1.0.18",
"@blockly/field-grid-dropdown": "^1.0.25",
"@blockly/field-slider": "^2.1.29",
"@blockly/theme-dark": "^2.0.6",
"@blockly/theme-modern": "^2.1.10",
"@blockly/workspace-backpack": "^1.0.9",
"@fortawesome/fontawesome-svg-core": "^1.2.34",
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@fortawesome/vue-fontawesome": "^2.0.2",
"blockly": "^4.20201217.0",
"blockly": "^6.20210701.0",
"bootstrap": "^4.6.0",
"bootstrap-vue": "^2.21.2",
"discord-buttons": "^2.4.1",
"easy-json-database-browser": "^2.1.0",
"js-beautify": "^1.13.5",
"jszip": "^3.6.0",
"moment": "^2.29.1",
"sweetalert2": "^10.15.5",
"vue": "^2.6.12",
"vue-i18n": "^8.24.0",
Expand Down Expand Up @@ -62,5 +70,20 @@
"browserslist": [
"> 1%",
"last 2 versions"
]
],
"description": "🐱 Make your Discord bot using Scratch blocks! [Scratch For Discord](https://scratch-for-discord.netlify.com) is an advanced fork of [discord-blocks](https://discordblocks.leondrolio.com/). Thanks to [7coil](https://github.com/7coil) for their great work!",
"main": "babel.config.js",
"directories": {
"example": "examples"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mrredo-and-josetrindade1/scratch-for-discord.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/mrredo-and-josetrindade1/scratch-for-discord/issues"
},
"homepage": "https://github.com/mrredo-and-josetrindade1/scratch-for-discord#readme"
}
14 changes: 12 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>scratch.png">
<link rel="icon" href="https://raw.githubusercontent.com/josetrindade1/scratch-for-discord/djs13/public/scratch.png">
<title>Scratch For Discord - Make your own bot using blocks</title>
<meta name="description" content="Make your own discord bot in 5 minutes using blocks with no coding required. Try your bot online and export it on your computer or server." />
<meta name="keywords" content="discord, bot, no-coding, scratch, blocks" />
<meta name="author" content="Androz2091" />
<meta name="author" content="Androz2091" />
<meta name="theme-color" content="#f6bc34" />
<meta name="google-site-verification" content="cpALYx5PHSXOgLtp-1pxqyELC6zIekO0RDQnWmFvhXI" />
<style>
.blocklyTreeSeparator {
border-bottom: solid #343434 1px;
height: 0;
margin: 5px 0;
}
.bt {
border-bottom: solid #343434 1px;
height: 0;
margin: 5px 0;
}
::-webkit-scrollbar {
width: 1px;
height: 1px;
Expand Down
47 changes: 44 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,67 @@ import Blockly from "blockly";
import NavBarComponent from "./components/NavigationBar/NavigationBar.vue";
import BlocklyComponent from "./components/BlocklyComponent.vue";



Blockly.Tooltip.HOVER_MS = 100;

// Load blocks

import "./blocks/discord/base/";
import "./blocks/discord/message-event/";
import "./blocks/discord/join-event/";
import "./blocks/discord/leave-event/";
import "./blocks/discord/reaction-event/";
import "./blocks/discord/bot-event";

import "./blocks/discord/channels/";
import "./blocks/discord/servers/";
import "./blocks/discord/roles/";
import "./blocks/discord/members/";
import "./blocks/discord/deleted/";
import "./blocks/discord/discord-button/";
import "./blocks/discord/webhook/";
import "./blocks/discord/embed/";
import "./blocks/discord/discord-menu/";
import "./blocks/discord/music/";
import "./blocks/discord/discord-canvas/welcome/";
import "./blocks/discord/discord-canvas/goodbye/";
import "./blocks/discord/discord-canvas/rankcard/";

import "./blocks/discord/mmenu/";
import "./blocks/discord/mbuttons/";
import "./blocks/discord/membed/";
import "./blocks/discord/m-register-menus/";
import "./blocks/discord/mslash/";
import "./blocks/discord/wmise/";
import "./blocks/mongodb/";

import "./blocks/jsonrequest";
import "./blocks/database/";
import "./blocks/text/";
import "./blocks/loops/";
import "./blocks/other/";
import "./prompt";
//events
//channel
import "./blocks/events/channel/channelCreate/";
import "./blocks/events/channel/channelUpdate/";
import "./blocks/events/channel/channelDelete/";
//emoji
import "./blocks/events/emoji/emojiCreate/";
import "./blocks/events/emoji/emojiUpdate/";
import "./blocks/events/emoji/emojiDelete/";
//member
import "./blocks/events/member/join-event/";
import "./blocks/events/member/leave-event/";
import "./blocks/events/member/guildBanAdd/";
import "./blocks/events/member/guildBanRemove/";
//role
import "./blocks/events/role/roleCreate/";
import "./blocks/events/role/roleUpdate/";
import "./blocks/events/role/roleDelete/";
//sticker
import "./blocks/events/sticker/stickerCreate/";
import "./blocks/events/sticker/stickerUpdate/";
import "./blocks/events/sticker/stickerDelete/";

import Theme from '@blockly/theme-modern';

Expand Down Expand Up @@ -136,4 +177,4 @@ export default {
.testopa {
opacity: 0.1;
}
</style>
</style>
51 changes: 51 additions & 0 deletions src/blocks/discord/base/bot_amout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as Blockly from "blockly/core";

const blockName = "s4d_bot_amount";

const blockData = {
"message0": "%{BKY_BOT_AMOUNT}",
"args0": [
{
"type": "field_dropdown",
"name": "T",
"options": [
[
"%{BKY_SERVERS}",
"servers"
],
[
"%{BKY_USERS}",
"users"
],
[
"%{BKY_CHANNELS}",
"channels"
]
]
},
],
"colour": "#4C97FF",
"output":"String",
"inputsInline": true,
"tooltip": "",
"helpUrl": ""
};

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

Blockly.JavaScript[blockName] = function(block){
const t = block.getFieldValue("T");
let code = ""
if(t === "servers"){
code = "s4d.client.guilds.cache.size"
}else if(t === "channels"){
code = "s4d.client.channels.cache.size"
}else if(t === "users"){
code = "s4d.client.users.cache.size"
}
return [code, Blockly.JavaScript.ORDER_NONE ];
};
29 changes: 29 additions & 0 deletions src/blocks/discord/base/get_bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as Blockly from "blockly/core";

const blockName = "s4d_get_bot";

const blockData = {
"message0": "%{BKY_GET_BOT}",
"args0": [
{
"type": "input_value",
"name": "SERVER",
"check": "Server"
}
],
"colour": "#5b67a5",
"output": "Member",
"tooltip": "",
"helpUrl": ""
};

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

Blockly.JavaScript[blockName] = function(block){
const server = Blockly.JavaScript.valueToCode(block, "SERVER", Blockly.JavaScript.ORDER_ATOMIC);
return [ `${server}.members.cache.find((m) => m.id === s4d.client.user.id)`, Blockly.JavaScript.ORDER_NONE ];
};
4 changes: 4 additions & 0 deletions src/blocks/discord/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import "./bot_server_count";
import "./login";
import "./on_connected";
import "./set_bot_game";
import "./get_bot";
import "./s4d_bot_shutdown";
import "./set_bot_stream";
import "./bot_amout";
24 changes: 24 additions & 0 deletions src/blocks/discord/base/s4d_bot_shutdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as Blockly from "blockly/core";


const blockName = "s4d_bot_shutdown";

const blockData = {
"message0": "Shutdown the bot",
"colour": "#4C97FF",
"previousStatement": null,
"nextStatement": null,
"tooltip": "Litterally shutdowns the bot",
"helpUrl": ""
};

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

Blockly.JavaScript[blockName] = function(){
const code = `s4d.client.destroy();\n`;
return code;
};
53 changes: 50 additions & 3 deletions src/blocks/discord/base/set_bot_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,55 @@ const blockData = {
"name": "GAME",
"check": [ "Number", "String" ]
},
{
"type": "field_dropdown",
"name": "TYPE",
"options": [
[
"%{BKY_LISTENING}",
"LISTENING"
],
[
"%{BKY_WATCHING}",
"WATCHING"
],
[
"%{BKY_COMPETING}",
"COMPETING"
],
[
"%{BKY_PLAYING}",
"PLAYING"
]
]
},
{
"type": "field_dropdown",
"name": "OIFD",
"options": [
[
"%{BKY_ONLINE}",
"online"
],
[
"%{BKY_OFFLINE}",
"offline"
],
[
"%{BKY_IDLE}",
"idle"
],
[
"%{BKY_DND}",
"dnd"
]
]
},
],
"colour": "#4C97FF",
"previousStatement": null,
"nextStatement": null,
"inputsInline": true,
"tooltip": "",
"helpUrl": ""
};
Expand All @@ -26,11 +71,13 @@ Blockly.Blocks[blockName] = {
};

Blockly.JavaScript[blockName] = function(block){
const type = block.getFieldValue("TYPE");
const game = Blockly.JavaScript.valueToCode(block, "GAME", Blockly.JavaScript.ORDER_ATOMIC);
const code = `s4d.client.user.setActivity(String(${game}));\n`;
const OIFD = block.getFieldValue("OIFD");
const code = `s4d.client.user.setPresence({status: "${OIFD}",activities:[{name:${game},type:"${type}"}]}); \n`;
return code;
};

registerRestrictions(blockName, [
{
type: "notempty",
Expand All @@ -39,4 +86,4 @@ registerRestrictions(blockName, [
"GAME"
]
}
]);
]);
38 changes: 38 additions & 0 deletions src/blocks/discord/base/set_bot_stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as Blockly from "blockly/core";
import { registerRestrictions } from "../../../restrictions";

const blockName = "s4d_set_bot_stream";

const blockData = {
"message0": "%{BKY_SET_BOT_STREAM}",
"args0": [{
"type": "input_value",
"name": "URL",
"check": ["Number", "String"]
}, ],
"colour": "#4C97FF",
"previousStatement": null,
"nextStatement": null,
"tooltip": "",
"helpUrl": ""
};

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

Blockly.JavaScript[blockName] = function(block) {
const url = Blockly.JavaScript.valueToCode(block, "URL", Blockly.JavaScript.ORDER_ATOMIC);
const code = `s4d.client.user.setActivity("with depression", { \n type: "STREAMING", \n url: ${url}});\n`;
return code;
};

registerRestrictions(blockName, [{
type: "notempty",
message: "RES_MISSING_URL",
types: [
"URL"
]
}]);
Loading