forked from Discordsmh/massdm
-
Notifications
You must be signed in to change notification settings - Fork 139
/
app.js
99 lines (77 loc) · 2.85 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*jshint esversion: 6 */
const Discord = require('discord.js');
const figlet = require('figlet');
const colors = require('colors');
const readline = require('readline');
const commando = require(`discord.js-commando`);
const config = require('./config.json');
const bot = new commando.Client({
commandPrefix:'mass!',
owner: config.id
});
const cmdsArray = [
"dmall <message>",
"dmrole <role> <message>"
];
bot.on("ready", () => {
clear();
console.log('______');
bot.user.setActivity('from GitHub', { url: "https://github.com/alexlyee/massdm", type: 'PLAYING' })
.then(presence => console.log(`Activity set to ${presence.game ? presence.game.name : 'none'}`))
.catch(console.error);
});
bot.on("error", (error) => {
bot.login(config.token);
});
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
bot.registry.registerGroup('dms', 'help');
bot.registry.registerDefaults();
bot.registry.registerCommandsIn(__dirname + "/commands");
if (process.env.TESTING) process.exit();
try {
if (process.env.BOT_TOKEN) bot.login(process.env.BOT_TOKEN);
else bot.login(config.token);
}
catch (e) {
console.log(e);
console.log("Failed to login to Discord!");
}
function clear() {
console.clear();
console.log(figlet.textSync("MassDM v3.4.0b").green); // just in case it wasn't obvious, this is a beta
console.log("\n\nMass DM bot for Discord. \n Sends DMs to selected members of guild.\n Forked and improved by Alex.");
console.log("\n Don't forget to apply the proper permissions in Discord. Use https://github.com/alexlyee/massdm/issues to report issues. Suport server: https://discord.gg/mMWQaDx");
console.log("\n After someone by the name of \"6669\" double-crossed me, \n(assuring me that I would be paid for working on the project, but once I did most of the work and proved it was fixed, blocked me) \n I will be abandoning this project, please do not contact me to report bugs. I am aware that there are some. ");
console.log(`\nRandom send time set @ 0.01-${config.wait}s`);
console.log(` Type ${config.prefix}help in a chat.\n\n`);
}
/************ NOTES */
/*
The only values that are not truthy in JavaScript are the following (a.k.a. falsy values):
null
undefined
0
"" (the empty string)
false
NaN
*/
/*
.jshintrc
{
"esversion": 6
}
*/
/*
https://stackoverflow.com/questions/14274293/show-current-state-of-jenkins-build-on-github-repo
https://docs.travis-ci.com/user/tutorial/ https://travis-ci.org/github/alexlyee/massdm/jobs/689535155
https://app.snyk.io/org/alexlyee
https://inch-ci.org/github/alexlyee/massdm?branch=master
https://hits.dwyl.com/
https://david-dm.org/?success
https://github.com/dwyl/goodparts#why
https://shields.io/
https://github.com/badges/shields/blob/master/README.md
https://github.com/dwyl/learn-tdd
*/