Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bd-js2-0

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bd-js2-0 - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

commands/ping.js

8

.config/configstore/update-notifier-npm.json
{
"optOut": false,
"lastUpdateCheck": 1585654292417
"lastUpdateCheck": 1585830032178,
"update": {
"latest": "6.14.4",
"current": "6.4.1",
"type": "minor",
"name": "npm"
}
}

2

.config/configstore/update-notifier-pnpm.json
{
"optOut": false,
"lastUpdateCheck": 1585653715034
"lastUpdateCheck": 1585829309418
}

@@ -1,44 +0,57 @@

const get = async (func, client, message, text, args) => {
let inside = text.split("getMessage[")[func.getMsg].split("]")[0]
let fields = inside.split(";")
let channelID = fields[0]
let messageID = fields[1]
let option = fields[2]
let channel = message.guild.channels.get(channelID)
if (!channel) return message.channel.send(`❌ Invalid channel ID in \`$getMessage[${inside}]\`!`)
let msg = await channel.fetchMessage(messageID).catch(e => {})
if (!msg) return message.channel.send(`❌ Message not found!`)
let ops = [msg.author.displayAvatarURL, msg.author.tag, msg.content, msg.author.id, msg.author.username]
let options = ["{avatar}", "{tag}", "{content}", "{user}", "{username}"]
if (!options.some(x => x === option)) return message.channel.send(`❌ Invalid option in \`$getMessage[${inside}]\`!`)
let pos = options.indexOf(option)
let r = ops[pos]
text.split(`getMessage[${inside}]`).map((x, y) => {
if (y == 0) {} else {
text = text.replace(`getMessage[${inside}]`, r)
func.getMsg--
}
})
const getMessage = async (text, code, message) => {
let r = text.split("$getMessage[").length - 1;
let inside = code.split("$getMessage[")[r].split("]")[0];
let fields = inside.split(";");
let channelID = fields[0];
let messageID = fields[1];
let option = fields[2];
let channel = message.client.channels.get(channelID);
if (!channel)
return message.channel.send(
`❌ Invalid channel ID in \`$getMessage[${inside}]\``
);
let msg = await channel.fetchMessage(messageID).catch(err => {});
if (!msg)
return message.channel.send(
`❌ Invalid message ID in \`$getMessage[${inside}]\``
);
let options = {
content: msg.content,
user: msg.author.id,
username: msg.author.username,
tag: msg.author.tag,
avatar: msg.author.displayAvatarURL
};
if (options[option] === undefined)
return message.channel.send(
`❌ Invalid option type in \`$getMessage[${inside}]\``
);
let n = options[option];
text.split(`$getMessage[${inside}]`).map(x => {
if (text.includes(`$getMessage[${inside}]`)) {
text = text.replace(`$getMessage[${inside}]`, n);
code = code.replace(`$getMessage[${inside}]`, n);
}
});
return {
func: func.getMsg,
text: text
}
}
text: text,
code: code
};
};
module.exports = get
module.exports = getMessage;

@@ -1,22 +0,35 @@

const only = (client, message, text, args) => {
const onlyIfMessageContains = (text, code, message) => {
let inside = text.split("onlyIfMessageContains[")[1].split("]")[0]
if (text.split("$onlyIfMessageContains[").length >= 3) return message.channel.send(`❌ Unexpected function.`)
let words = inside.split(";")
let inside = code.split("$onlyIfMessageContains[")[1].split("]")[0]
let error = words.pop()
let fields = inside.split(";")
let msg = words.shift()
let error = fields.pop()
if (!words.some(x => msg.includes(x))) {
if (error) return message.channel.send(error)
return
let msg = fields.shift()
if (!fields.some(x => msg.includes(x))) {
if (error) {
if (error.includes("$n")) {
error.split("$n").map(x => {
error = error.replace("$n", "\n")
})
}
return message.channel.send(error)
}
}
text = text.replace(`onlyIfMessageContains[${inside}]`, "")
code = code.replace(`$onlyIfMessageContains[${inside}]`, "")
text = text.replace(`$onlyIfMessageContains[${inside}]`, "")
return text
}
return {
code: code,
text: text
}
}
module.exports = only
module.exports = onlyIfMessageContains

@@ -1,2 +0,2 @@

const api = require('./interpreter.js')
const api = require('./script.js')

@@ -3,0 +3,0 @@ module.exports = api

@@ -1,136 +0,321 @@

const Discord = require('discord.js')
const client = new Discord.Client()
const fs = require('fs')
const interpreter = async (client, message, code, args, channel, name) => {
let lines = code.split("\n");
client.spaceCommands = new Discord.Collection()
client.commands = new Discord.Collection()
client.vars = {}
for (let line = 0; line < lines.length; line++) {
let text = lines[line];
class interpreter {
constructor(options) {
if (!options.token) return console.error(`Options.token is undefined!`)
else if (!options.prefix) return console.error(`Options.prefix is undefined!`)
this.prefix = options.prefix
client.login(options.token)
client.on("ready", () => {
console.log(`${client.user.tag} is ready`)
})
}
Command(options) {
if (!options.name) return console.error(`Options.name is undefined!`)
else if (!options.code) return console.error(`Options.code is undefined!`)
client.commands.set(options.name, options)
}
MessageEvent() {
client.on("message", async message => {
if (message.author.bot || message.channel.type === "dm") return
let functions = lines[line].split("$");
for (let i = functions.length - 1; i > 0; i--) {
if (code && functions[i].startsWith("ping") && text.includes("$ping") && code.includes("$ping")) {
text.split("$ping").map(x => {
if (text.includes("$ping")) {
text = text.replace(`$ping`, client.ping.toFixed(0))
code = code.replace(`$ping`, client.ping.toFixed(0))
}
})
}
if (client.spaceCommands.size) {
if (code && functions[i].startsWith("status[") && text.includes("$status[") && code.includes("$status[")) {
let m = require('./constructors/status.js')(functions, i, text, code, message)
client.spaceCommands.map(async command => {
client.embed = new Discord.RichEmbed()
let args = message.content.slice(0).trim().split(/ +/g)
let y = args.shift().toLowerCase()
let cmd = command.name
command = command.code
text = m.text
code = m.code
}
command = await require('./loader.js').execute(command, message, client, args, cmd)
if (code && functions[i].startsWith("replaceText[") && text.includes("$replaceText[") && code.includes("$replaceText[")) {
let m = require('./constructors/replaceText.js')(text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("cooldown[") && text.includes("$cooldown[") && code.includes("$cooldown[")) {
let m = await require('./constructors/cooldown.js')(text, code, name, message)
text = m.text
code = m.code
}
if (command && command.length && typeof command === "string" && client.embed.title === undefined) message.channel.send(command)
else if (command === undefined && client.embed.title !== undefined) message.channel.send(client.embed)
else if (typeof command === "string" && command.length) message.channel.send(command, client.embed)
})
if (code && functions[i].startsWith("getMessage[") && text.includes("$getMessage[") && code.includes("$getMessage[")) {
let m = await require('./constructors/getMessage.js')(text, code, message)
text = m.text
code = m.code
}
client.embed = new Discord.RichEmbed()
let prefix = ""
if (code && functions[i].startsWith("messageID") && text.includes("$messageID") && code.includes("$messageID")) {
let m = require('./constructors/messageID.js')(text, code, message)
text = m.text
code = m.code
}
this.prefix.map(x => {
if (message.content.startsWith(x)) prefix = x
})
if (code && functions[i].startsWith("nickname[") && text.includes("$nickname[") && code.includes("$nickname[")) {
let m = require('./constructors/nickname.js')(functions, i, text, code, message)
code = m.code
text = m.text
}
if (!prefix) return
if (code && functions[i].startsWith("setServerVar[") && text.includes("$setServerVar[") && code.includes("$setServerVar[")) {
let m = require('./constructors/setServerVar.js')(client, text, code, message)
text = m.text
code = m.code
}
let args = message.content.slice(prefix.length).trim().split(/ +/g)
let x = args.shift().toLowerCase()
if (code && functions[i].startsWith("useChannel[") && text.includes("$useChannel[") && code.includes("$useChannel[")) {
let m = require('./constructors/useChannel.js')(client, text, code, message, channel)
text = m.text
code = m.code
channel = m.channel
}
if (!x || !message.content.startsWith(prefix)) return
if (code && functions[i].startsWith("onlyPerms[") && text.includes("$onlyPerms[") && code.includes("$onlyPerms[")) {
let m = require('./constructors/onlyPerms.js')(text, code, message)
text = m.text
code = m.code
}
let command = client.commands.get(x) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(x))
if (code && functions[i].startsWith("channelSendMessage[") && text.includes("$channelSendMessage[") && code.includes("$channelSendMessage[")) {
let m = require('./constructors/channelSendMessage.js')(client, text, code, message)
text = m.text
code = m.code
}
if (!command) return //console.log(`Command ${x} not found.`, client.commands)
if (code && functions[i].startsWith("getServerVar[") && text.includes("$getServerVar[") && code.includes("$getServerVar[")) {
let m = await require('./constructors/getServerVar.js')(client, text, code, message)
text = m.text
code = m.code
}
let cmd = command.name
if (code && functions[i].startsWith("setUserVar[") && text.includes("$setUserVar[") && code.includes("$setUserVar[")) {
let m = require('./constructors/setUserVar.js')(client, text, code, message)
text = m.text
code = m.code
}
command = command.code
if (code && functions[i].startsWith("getUserVar[") && text.includes("$getUserVar[") && code.includes("$getUserVar[") && text.includes("$getUserVar[")) {
let m = await require('./constructors/getUserVar.js')(client, text, code, message)
text = m.text
code = m.code
}
command = await require('./loader.js').execute(command, message, client, args, cmd)
if (code && functions[i].startsWith("onlyIfMessageContains[") && code.includes("$onlyIfMessageContains[")) {
let m = require('./constructors/onlyIfMessageContains.js')(text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("membersCount[") && text.includes("$membersCount[") && code.includes("$membersCount[")) {
let m = require('./constructors/membersCount.js')(functions, i, text, code, message)
text = m.text
code = m.code
}
if (typeof command === "string" && command.length && client.embed.title === undefined) message.channel.send(command)
else if (command === undefined && client.embed.title !== undefined) message.channel.send(client.embed)
else if (typeof command === "string" && command.length) message.channel.send(command, client.embed)
})
}
Variables(object) {
if (typeof object !== "object") return console.error(`Invalid object received in Variables.`)
client.vars = object
if (code && functions[i].startsWith("serverCount") && text.includes("$serverCount") && code.includes("$serverCount")) {
let m = require('./constructors/serverCount.js')(client, text, code)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("allMembersCount") && text.includes("$allMembersCount") && code.includes("$allMembersCount")) {
let m = require('./constructors/allMembersCount.js')(client, text, code)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("userAvatar[") && text.includes("$userAvatar[") && code.includes("$userAvatar[")) {
let m = require('./constructors/userAvatar.js')(functions, i, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("footer[") && code.includes("$footer[")) {
let m = require('./constructors/footer.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("image[") && code.includes("$image[")) {
let m = require('./constructors/image.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("color[") && code.includes("$color[")) {
let m = require('./constructors/color.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("thumbnail[") && code.includes("$thumbnail[")) {
let m = require('./constructors/thumbnail.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("title[") && code.includes("$title[")) {
let m = require('./constructors/title.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("description[") && code.includes("$description[")) {
let m = require('./constructors/description.js')(client, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("mentioned[") && text.includes("$mentioned[") && code.includes("$mentioned[")) {
let m = require('./constructors/mentioned.js')(text, code, message)
code = m.code
text = m.text
}
if (code && functions[i].startsWith("channelID[") && text.includes("$channelID[") && code.includes("$channelID[")) {
let m = require('./constructors/channelID.js')(functions, i, text, code, message)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("onlyIf[") && code.includes("$onlyIf[")) {
let m = require('./constructors/onlyIf.js')(text, code, message)
code = m.code
text = m.text
}
if (code && functions[i].startsWith("randomText[") && text.includes("$randomText[") && code.includes("$randomText[")) {
let m = require('./constructors/randomText.js')(text, code, message)
code = m.code
text = m.text
}
if (code && functions[i].startsWith("random[") && text.includes("$random[") && code.includes("$random[")) {
let m = require('./constructors/random.js')(text, code, message)
code = m.code
text = m.text
}
if (code && functions[i].startsWith("sum[") && text.includes("$sum[") && code.includes("$sum[")) {
let m = require('./constructors/sum.js')(text, code)
text = m.text
code = m.code
}
if (code && functions[i].startsWith("authorID")) {
text.split("$authorID").map(x => {
if (text.includes("$authorID")) {
code = code.replace("$authorID", message.author.id)
text = text.replace("$authorID", message.author.id)
}
})
}
if (code && functions[i].startsWith("username[") && text.includes("$username[") && code.includes("$username[")) {
if (functions[i].split("username[")[1].split("")[0] === "]") {
code = code.replace("$username[]", message.author.username);
text = text.replace("$username[]", message.author.username)
} else {
let id = code.split("$username[")[1].split("]")[0];
let user = client.users.get(id);
if (!user) return message.channel.send(`❌ Invalid user ID in \`$username[${id}]\``);
text.split(`$username[${id}]`).map(x => {
if (text.includes(`$username[${id}]`)) {
text = text.replace(`$username[${id}]`, user.username)
code = code.replace(`$username[${id}]`, user.username)
}
})
}
}
if (code && functions[i].startsWith("message[") && text.includes("$message[") && code.includes("$message[")) {
if (functions[i].split("message[")[1].split("")[0] === "]") {
text.split("$message[]").map((x, y) => {
if (text.includes("$message[]")) {
code = code.replace("$message[]", args.join(" "));
text = text.replace("$message[]", args.join(" "))
}
})
} else {
let r = text.split("$message[").length - 1
let number = code.split("$message[")[r].split("]")[0]
if (isNaN(number)) return message.channel.send(`❌ Invalid number in \`$message[${number}]\``);
let n = Number(number) - 1;
text.split(`$message[${number}]`).map(x => {
if (text.includes(`$message[${number}]`)) {
text = text.replace(`$message[${number}]`, args[n] ? args[n] : "")
code = code.replace(`$message[${number}]`, args[n] ? args[n] : "")
}
})
}
}
}
}
SpaceCommand(object) {
if (!object.code) return console.error(`Options.code is not defined!`)
if (!object.name) return console.error(`Options.name is undefined!`)
if (code && typeof code === "string") {
code.split("$n").map(x => {
code = code.replace("$n", "\n")
})
client.spaceCommands.set(object.name, object)
}
Status(options, time) {
if (typeof options !== "object") return console.error("Options.status is not a valid object")
Object.entries(client.embed).map(x => {
if (x[1]) {
if (x[0] === "footer") {
client.embed[x[0]].text = client.embed[x[0]].text.replace("$n", "\n")
} else if (typeof x[1] === "string") {
x[1].split("$n").map(y => {
client.embed[x[0]] = client.embed[x[0]].replace("$n", "\n")
})
}
}
})
if (!time) time = 12000
let statuses = []
Object.entries(options).map(x => {
statuses.push(x[1])
})
let y = 0
setInterval(() => {
if (y >= statuses.length) y = 0
client.user.setActivity(statuses[y].description, { type: statuses[y].type })
y++
}, time)
return {
code: code,
channel: channel
}
}
LoadCommands(options) {
if (!options.path) return console.error("Options.path is undefined!")
let folder = fs.readdirSync(options.path)
for (const commands of folder) {
const command = require(options.path + commands)
if (command.name) client.commands.set(command.name, command)
}
}
}
};
module.exports = interpreter
module.exports = interpreter;

@@ -6,4 +6,4 @@ {

"name": "bd-js2-0",
"version": "0.2.4",
"description": "Version 2.0 of BDjavascript! Much better than the older one.",
"version": "0.3.0",
"description": "Version 3.0 of BDjavascript! Much better than the older one.",
"main": "index.js",

@@ -10,0 +10,0 @@ "scripts": {

@@ -1,9 +0,14 @@

const script = require("./interpreter.js");
const script = require("./script.js");
const bd = new script({
token: "Njc0MzM2MjcxNDYzODc0NTgw.Xnn0_w.LmE0ae3VQPQ_FhRNEO6RVloD1Ds", //"Njc0MzM2MjcxNDYzODc0NTgw.Xnkvzg.pU3BzS8MXyCddbsOWA3CgvepdeY", //"Njc0MzM2MjcxNDYzODc0NTgw.XnkBlQ.aw2x0kxdBtFElUrZ8FZTHJ4KbIA", //"NjkwNjAyNDkyNDk2NzA3NjU0.Xnj84Q.seIY-OHxAAYhgvWdWY4Ar3EFft0", //"NjkwNjAyNDkyNDk2NzA3NjU0.Xni8wg.N6EnSTxk1dp-C84L2xslXX1KGuE", //"NjkwNjAyNDkyNDk2NzA3NjU0.XnYogQ.p60oGo3a327NIavQD0oNI0F06qU",
prefix: ["?", "!"]
token: "Njc0MzM2MjcxNDYzODc0NTgw.XoTCTw.5CPHeIv5m36XqNBavpajP_bG8KM", //"Njc0MzM2MjcxNDYzODc0NTgw.XoPhaA.XPDViq-NPirEIakXmAKZyKi3jN0", //"Njc0MzM2MjcxNDYzODc0NTgw.Xnn0_w.LmE0ae3VQPQ_FhRNEO6RVloD1Ds", //"Njc0MzM2MjcxNDYzODc0NTgw.Xnkvzg.pU3BzS8MXyCddbsOWA3CgvepdeY", //"Njc0MzM2MjcxNDYzODc0NTgw.XnkBlQ.aw2x0kxdBtFElUrZ8FZTHJ4KbIA", //"NjkwNjAyNDkyNDk2NzA3NjU0.Xnj84Q.seIY-OHxAAYhgvWdWY4Ar3EFft0", //"NjkwNjAyNDkyNDk2NzA3NjU0.Xni8wg.N6EnSTxk1dp-C84L2xslXX1KGuE", //"NjkwNjAyNDkyNDk2NzA3NjU0.XnYogQ.p60oGo3a327NIavQD0oNI0F06qU",
prefix: ["=", "!"]
});
bd.Command({
name: "replace",
code: `$status[$mentioned[1;yes]]`
})
bd.Command({
name: "get",

@@ -21,18 +26,101 @@ aliases: ["content"],

bd.Command({
name: `test`,
code: `
$onlyIf[$mentioned[1]!=0;Mention someone!]
$color[00bb2d]
$description[Here's $username[$mentioned[1]] avatar:]
$image[$userAvatar[$mentioned[1]]]
$title[Wow:]
$footer[That's op!$nRequested by $username[]]
$thumbnail[$userAvatar[]]
`
})
bd.Command({
name: "count",
code: `
$onlyIfMessageContains[$message[1];offline;online;idle;dnd;Include a status type of the following:\`$ndnd | online | idle | offline\`]
$serverCount servers
$allMembersCount users
$membersCount[] users on this guild
$membersCount[$message[1]] with status set as $message[1]
$useChannel[$message[2]]
`
})
bd.Command({
name: "message",
code: `
$cooldown[10s;You can use this command again in {time}.]
$onlyIf['$message[1]'!='';Put a message ID!]
$color[00bb2d]
$title[By $getMessage[$channelID[];$message[1];tag]:]
$description[$getMessage[$channelID[];$message[1];content]]
$thumbnail[$getMessage[$channelID[];$message[1];avatar]]
$footer[ID: $getMessage[$channelID[];$message[1];user]]
`
})
bd.MessageEvent();
/*bd.SpaceCommand({
bd.Status({
0: {
type: "WATCHING",
description: "You."
},
1: {
type: "PLAYING",
description: "new interpreter."
}
}, 15000)
bd.Variables({
level: 1,
text: "hi",
sigh: 5,
exp2: 5,
exp: 0,
enabled: 1
})
bd.LoadCommands({ automatic: true })
/*
bd.SpaceCommand({
name: "Auto-Levelling",
code:
`
$onlyIf[$getServerVar[enabled]==1;]
$setUserVar[exp;$sum[$getUserVar[exp];$random[1;20]]]
$onlyIf[Number($getUserVar[exp])>=Number($getUserVar[exp2]);$getUserVar[exp]/$getUserVar[exp2]]
$setUserVar[level;$sum[$getUserVar[level];1]] **🎉 Congratulations <@$authorID>,
You have reached Level \`$getUserVar[level]\`
$setUserVar[exp2;$sum[$getUserVar[exp2];5]]
$setUserVar[exp;0]`
});*/
/*
bd.SpaceCommand({
name: "spccmd1",
code: `$onlyIfMessageContains[$message;coins;Err]`
})*/
code: //``$onlyIfMessageContains[$message;coins;Err]`
})
bd.SpaceCommand({
name: "Auto-Levelling",
code:
"$onlyIf[$getServerVar[enabled]==1;] $onlyIf[$getUserVar[exp]>$getUserVar[exp2];] $setUserVar[level;$sum[$getUserVar[level];1]] **🎉 Congratulations <@$authorID>,\nYou have reached Level `$sum[$getUserVar[level];1]` $setUserVar[exp2;$sum[$getUserVar[exp2];5]] $setUserVar[exp2;0]"
});
bd.Variables({
level: 1
level:
enabled: 1,
exp2: 5,
exp0: 1
});
/*bd.SpaceCommand({
bd.SpaceCommand({
code: "<@$authorID>",
name: "meh"
})*/
})
bd.LoadCommands({ path: "./commands/" });

@@ -51,2 +139,2 @@

code: "Successfully kicked the user. $kick[$mentioned[1];for being gay.]"
})
})*/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc