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

new block #255

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["javascript"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"js-beautify": "^1.13.5",
"jszip": "^3.8.0",
"localforage": "^1.10.0",
"node": "^16.10.0",
"node": "20",
"npm": "^8.11.0",
"promises": "^0.2.5",
"sass-loader": "^10",
Expand Down
3 changes: 2 additions & 1 deletion src/blocks/Monaco/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ import "./memberswithrole"
import "./robloxbuy"
import "./timeoutuntil"
import "./timeoutuntiltimestamp"
import "./slowmo"
import "./slowmo"
import "./permissionsaddarray"
66 changes: 66 additions & 0 deletions src/blocks/Monaco/permissionsaddarray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import * as Blockly from "blockly/core";

const blockName = "monaco_edit_permissions";


const blockData = {
"message0": "in channel %1 %2 permissions to member/role with id %3 %4",
"args0": [
{
"type": "input_value",
"name": "channel",
"check": "Channel"
},
{
"type": "field_dropdown",
"name": "action",
"options": [
[
"allow",
"allow"
],
[
"deny",
"deny"
]
]
},
{
"type": "input_value",
"name": "member",
"check": "String"
},
{
"type": "input_statement",
"name": "then"
}
],
"colour": "#4C97FF",
"previousStatement": null,
"nextStatement": null,
"tooltip": "Edit more than one permission of a role/member.",
"helpUrl": ""
};

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

Blockly.JavaScript['monaco_edit_permissions'] = function(block) {
var value_channel = Blockly.JavaScript.valueToCode(block, 'channel', Blockly.JavaScript.ORDER_ATOMIC);
var value_action = block.getFieldValue('action');
var value_member = Blockly.JavaScript.valueToCode(block, 'member', Blockly.JavaScript.ORDER_ATOMIC);
var statements = Blockly.JavaScript.statementToCode(block, 'then');
// TODO: Assemble JavaScript into code variable.
var guilder = `s4d.clients.channels.cache.get('${value_channel}').edit(
{
permissionOverwrites:
id: '${value_member}',
${value_action}: [
${statements}
]
})`;
return guilder;
};
115 changes: 37 additions & 78 deletions src/blocks/discord/channels/set_perms_parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,82 +10,41 @@ const blockData = {
"type": "field_dropdown",
"name": "SEARCH",
"options": [
[
"View channel",
"VIEW_CHANNEL"
],
[
"Manage channel",
"MANAGE_CHANNEL"
],
[
"Manage webhooks",
"MANAGE_WEBHOOKS"
],
[
"Manage permissions",
"MANAGE_PERMISSIONS"
],
[
"Create invite",
"CREATE_INSTANT_INVITE"
],
[
"Send messages",
"SEND_MESSAGES"
],
[
"Embed links",
"EMBED_LINKS"
],
[
"Attach files",
"ATTACH_FILES"
],
[
"Add reactions",
"ADD_REACTIONS"
],
[
"Send Messages",
"USE_EXTERNAL_EMOJIS"
],
[
"Mention everyone",
"MENTION_EVERYONE"
],
[
"Manage messages",
"MANAGE_MESSAGES "
],
[
"Read message history",
"READ_MESSAGE_HISTORY"
],
[
"Atach files",
"ATTACH_FILES"
],
[
"Read message history",
"READ_MESSAGE_HISTORY"
],
[
"Use external emojis",
"USE_EXTERNAL_EMOJIS"
],
[
"View server insights",
"VIEW_GUILD_INSIGHTS"
],
[
"Use slash commands",
"USE_SLASH_COMMANDS"
],
[
"Send TTS messages",
"SEND_TTS_MESSAGES"
],
["CREATE_INSTANT_INVITE", "CREATE_INSTANT_INVITE"],
["MANAGE_CHANNELS", "MANAGE_CHANNELS"],
["ADD_REACTIONS", "ADD_REACTIONS"],
["PRIORITY_SPEAKER", "PRIORITY_SPEAKER"],
["STREAM", "STREAM"],
["VIEW_CHANNEL", "VIEW_CHANNEL"],
["SEND_MESSAGES", "SEND_MESSAGES"],
["SEND_TTS_MESSAGES","SEND_TTS_MESSAGES"],
["MANAGE_MESSAGES", "MANAGE_MESSAGES"],
["EMBED_LINKS", "EMBED_LINKS"],
["ATTACH_FILES", "ATTACH_FILES"],
["READ_MESSAGE_HISTORY", "READ_MESSAGE_HISTORY"],
["MENTION_EVERYONE", "MENTION_EVERYONE"],
["USE_EXTERNAL_EMOJIS", "USE_EXTERNAL_EMOJIS"],
["CONNECT", "CONNECT"],
["SPEAK", "SPEAK"],
["MUTE_MEMBERS", "MUTE_MEMBERS"],
["DEAFEN_MEMBERS", "DEAFEN_MEMBERS"],
["MOVE_MEMBERS", "MOVE_MEMBERS"],
["USE_VAD", "USE_VAD"],
["MANAGE_ROLES", "MANAGE_ROLES"],
["MANAGE_WEBHOOKS", "MANAGE_WEBHOOKS"],
["USE_APPLICATION_COMMANDS", "USE_APPLICATION_COMMANDS"],
["REQUEST_TO_SPEAK", "REQUEST_TO_SPEAK"],
["MANAGE_EVENTS", "MANAGE_EVENTS"],
["MANAGE_THREADS", "MANAGE_THREADS"],
["CREATE_PUBLIC_THREADS", "CREATE_PUBLIC_THREADS"],
["CREATE_PRIVATE_THREADS", "CREATE_PRIVATE_THREADS"],
["USE_EXTERNAL_STICKERS", "USE_EXTERNAL_STICKERS"],
["SEND_MESSAGES_IN_THREADS", "SEND_MESSAGES_IN_THREADS"],
["USE_EMBEDDED_ACTIVITIES", "USE_EMBEDDED_ACTIVITIES"],
["USE_SOUNDBOARD", "USE_SOUNDBOARD"],
["CREATE_EVENTS", "CREATE_EVENTS"],
["USE_EXTERNAL_SOUNDS", "USE_EXTERNAL_SOUNDS"],
["SEND_VOICE_MESSAGES", "SEND_VOICE_MESSAGES"]
]
}
],
Expand All @@ -104,7 +63,7 @@ Blockly.Blocks[blockName] = {

Blockly.JavaScript[blockName] = function(block){
const searchType = block.getFieldValue("SEARCH");
const code = `['${searchType}'],`
const code = `Permissions.FLAGS.${searchType},`
return code;

};
};
1 change: 1 addition & 0 deletions src/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@ export default (favorites) => {
<block type="monaco_toggle_follow_channel"/>
<block type="renamec"/>
<block type="channel_perms"/>
<block type="monaco_edit_permissions"/>
<block type="set_perms_parent"/>
<block type="frost_slowmode">
<value name="CHANNEL">
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7147,10 +7147,10 @@ node-releases@^1.1.71:
resolved "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz"
integrity sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==

node@^16.10.0:
version "16.10.0"
resolved "https://registry.npmjs.org/node/-/node-16.10.0.tgz"
integrity sha512-SXcqz3j4AOFMPPsd0bXDpQY95Xm8mnJ7PbBhJKEvp+aPYoVH38QAHha59EAuRaiASaSLWt5sP0oDCMzzaSmEAA==
node@20:
version "20.11.1"
resolved "https://registry.yarnpkg.com/node/-/node-20.11.1.tgz#41822e4cc4439a525b776ae7619279204ba00610"
integrity sha512-Xn8PkfFD6TYj/zqL2iK6ENtpEWvEymEHTycYdZydZNkzdqXwopqQKG+Yz+8xDsAJO15Db7VFNzRPVpYk0cbBJg==
dependencies:
node-bin-setup "^1.0.0"

Expand Down
Loading