Comparing version 0.1.0 to 0.1.1
61
index.js
@@ -1,10 +0,63 @@ | ||
let config = {} | ||
const Discord = require('discord.js'); | ||
const discord_client = new Discord.Client(); | ||
let user_config = {} | ||
let discordLoggedIn = false; | ||
exports.configure = function(file) { | ||
config = require(file); | ||
try { | ||
user_config = require(file); | ||
template_config = require("./simplert.cfg.json") | ||
user_keys = getAllKeys(user_config) | ||
template_keys = getAllKeys(template_config) | ||
if(user_keys.join() !== template_keys.join()) throw "Your simplert config file is not up to date, use the generate command to get the most up to date version" | ||
} catch(e) { | ||
if(e.code === "MODULE_NOT_FOUND") { | ||
throw new Error("Could not file specified. Make sure file path is correct.") | ||
} else { | ||
throw new Error(e) | ||
} | ||
} | ||
} | ||
exports.discord = function() { | ||
console.log(config.test) | ||
exports.discord = function(message, send_to = user_config.discord.send_to) { | ||
return new Promise((resolve, reject) => { | ||
let error; | ||
if(!user_config.discord.enabled) error = "Discord alert is not enabled. You need to enable it in your simplert config file" | ||
else if(!message) error = ".discord() requires at least 1 argument. Pass it a message to send to Discord" | ||
else if(!send_to) error = "You need to specify a Discord channel either in your simplert config file or passed into .discord()" | ||
if(error) reject(new Error(error)) | ||
if(!discordLoggedIn) { | ||
discordLoggedIn = true | ||
discord_client.login(user_config.discord.token).catch(error => { | ||
reject(error) | ||
}); | ||
} | ||
discord_client.on('ready', () => { | ||
const channel = discord_client.channels.find(channel => channel.name === send_to); | ||
discord_client.channels.get(channel.id).send(message); | ||
resolve(); | ||
}); | ||
}) | ||
} | ||
function getAllKeys(data) { | ||
const parent_keys = Object.keys(data); | ||
let child_keys = [] | ||
for(pkey of parent_keys) child_keys = child_keys.concat(Object.keys(data[pkey])) | ||
return parent_keys.concat(child_keys).sort() | ||
} | ||
{ | ||
"name": "simplert", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Simple way to send alerts via Slack, Email, Discord, SMS, etc.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"scripts": {}, | ||
"bin": { | ||
"generate-config": "./bin/generate-config.js" | ||
}, | ||
"author": "Nicholas Dangles", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"dependencies": { | ||
"discord.js": "^11.5.1" | ||
} | ||
} |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
2863
6
68
2
1
3
+ Addeddiscord.js@^11.5.1
+ Added@discordjs/uws@10.149.0(transitive)
+ Addedasync-limiter@1.0.1(transitive)
+ Addeddiscord.js@11.6.4(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedprism-media@0.0.4(transitive)
+ Addedsnekfetch@3.6.4(transitive)
+ Addedtweetnacl@1.0.3(transitive)
+ Addedws@6.2.3(transitive)