bd-javascript
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,3 +6,3 @@ { | ||
"name": "bd-javascript", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "BDjavascript, like BDscript of Discord Bot Designer.", | ||
@@ -9,0 +9,0 @@ "main": "server.js", |
@@ -16,3 +16,13 @@ ****USE THIS FOR REQUIRING THE FUNCTIONS****: | ||
$numberSeparator, | ||
$richEmbed | ||
$richEmbed, | ||
$guildID, | ||
$roleID, | ||
$dm, | ||
$cooldown, | ||
$takeRole, | ||
$giveRole, | ||
$setServerVar, | ||
$getServerVar, | ||
$isNumber, | ||
$isString, | ||
$embed, | ||
@@ -19,0 +29,0 @@ $send, |
@@ -14,2 +14,10 @@ //const Discord = require('discord.js') | ||
exports.$getServerVar = async(variable, guildid) => { | ||
const Discord = require('discord.js') | ||
const db = require('quick.db') | ||
let item = await db.fetch(`${variable}_${guildid}`) | ||
if (item === null) item = 0 | ||
return item | ||
} | ||
exports.$username = (message, mention) => { | ||
@@ -22,4 +30,4 @@ let name | ||
exports.$message = (message, number) => { | ||
let args = message.content.slice(0).trim().split(/ +/g) | ||
exports.$message = (prefix, message, number) => { | ||
let args = message.content.slice(prefix.length).trim().split(/ +/g) | ||
let argument = args.join(" ") | ||
@@ -30,2 +38,8 @@ if (!number) return argument | ||
exports.$takeRole = (message, userID, roleID) => { | ||
const Discord = require('discord.js') | ||
let member = message.guild.members.get(userID) | ||
let role = message.guild.roles.find(roleID) | ||
member.removeRole(roleID) | ||
} | ||
//exports.$argsCheck = (message, condition, errorMessage) => { | ||
@@ -38,8 +52,34 @@ // let args = message.content.slice(0).trim().split(/ +/g) | ||
exports.$dm = (message, dm, userID) => { | ||
let user = message.guild.members.get(userID).user | ||
user.send(dm) | ||
} | ||
exports.$guildID = (message, guildid) => { | ||
const Discord = require('discord.js') | ||
return message.guild.id | ||
} | ||
exports.$onlyIfMessageContains = (message, stringIncludes, errorMessage) => { | ||
if (!message.content.includes(stringIncludes)) { | ||
return message.channel.send(stringIncludes) | ||
for (let i = 0;i < stringIncludes.length;i++) { | ||
if (!message.content.includes(!stringIncludes[i])) { | ||
message.channel.send(errorMessage) | ||
throw "Condition returned False" | ||
} | ||
} | ||
} | ||
exports.$roleID = (message, rolename) => { | ||
const Discord = require('discord.js') | ||
let role = message.guild.roles.find("name", rolename) | ||
return role.id | ||
} | ||
exports.$giveRole = (message, userID, roleID) => { | ||
const Discord = require('discord.js') | ||
let member = message.guild.members.get(userID) | ||
let role = message.guild.roles.find(roleID) | ||
member.addRole(role) | ||
} | ||
exports.$embedError = (color, title, description, message) => { | ||
@@ -59,3 +99,6 @@ const Discord = require('discord.js') | ||
exports.$mentioned = (message) => { | ||
if (message.mentions.users.size < 1) throw "â User ID is undefined!\nâ User not found!" | ||
if (message.mentions.users.size < 1) { | ||
message.channel.send("â User not found!") | ||
throw "â User ID is undefined!\nâ User not found!" | ||
} | ||
return message.mentions.users.first().id | ||
@@ -137,2 +180,36 @@ } | ||
} | ||
exports.$isNumber = (message, number, errorMessage) => { | ||
if (!Number(number)) { | ||
message.channel.send(errorMessage) | ||
throw "Condition returned False" | ||
} | ||
} | ||
exports.$isString = (message, string, errorMessage) => { | ||
if (Number(string)) { | ||
message.channel.send(errorMessage) | ||
throw "Condition returned False" | ||
} | ||
} | ||
exports.$setServerVar = (variable, value, guildid) => { | ||
const db = require('quick.db') | ||
db.set(`${variable}_${guildid}`, value) | ||
} | ||
exports.$cooldown = async(message, command, user, time, errorMessage) => { | ||
const db = require('quick.db') | ||
const Discord = require('discord.js') | ||
let arr = time | ||
let key = await db.fetch(`${command}_${user}`) | ||
let cd = arr - (Date.now() - key) | ||
if (cd === null || cd < 1) cd = 0 | ||
if (!cd == 0) { | ||
message.channel.send(errorMessage) | ||
throw "Cooldown returned False" | ||
} else { | ||
db.set(`${command}_${user}`, Date.now()) | ||
} | ||
} | ||
//client.on("message", async message => { | ||
@@ -144,2 +221,2 @@ // if (message.author.bot) return | ||
// } else if (message.content.startsWith("embed")) { | ||
// // $embed("RANDOM", "nothing", `${$random(1, 5)} and ${$replaceText($replaceText("hello", "hello", "bye"), "bye", "hello")}`, message) | ||
// // $embed("RANDOM", "nothing", `${$random(1, 5)} and ${$replaceText($replaceText("hello", "hello", "bye"), "bye", "hello")}`, message) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34734
288
42