-
Notifications
You must be signed in to change notification settings - Fork 0
/
exports.js
68 lines (61 loc) · 1.97 KB
/
exports.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
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildIntegrations,
// GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
// Intents.FLAGS.GUILD_BANS,
// Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
// Intents.FLAGS.GUILD_WEBHOOKS,
// Intents.FLAGS.GUILD_INVITES,
// Intents.FLAGS.GUILD_PRESENCES,
// Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
// Intents.FLAGS.GUILD_MESSAGE_TYPING,
// Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
// Intents.FLAGS.DIRECT_MESSAGE_TYPING,
// Intents.FLAGS.GUILD_SCHEDULED_EVENTS,
],
ws: { properties: { browser: "Discord iOS" } },
partials: [
// Partials.Message,
Partials.Channel,
// Partials.Reaction
],
});
const Datastore = require('nedb');
const db1 = new Datastore({ filename: './tmmachines.db', autoload: true });
const db2 = new Datastore({ filename: './tmvictimlist.db', autoload: true });
const db3 = new Datastore({ filename: './tmmisc.db', autoload: true });
var recentBlock = [];
exports.client = client;
exports.tmmachines = db1;
exports.tmvictimlist = db2;
exports.misc = db3;
exports.recentBlock = recentBlock;
// Function blocks //
function splitLines(input, limit) {
const lines = (typeof input === 'string' || input instanceof String) ? input.split('\n') : input instanceof Array ? input : undefined;
if (!lines) return;
const arr = []; let part = '';
lines.forEach(line => {
const tmpPart = (part + '\n' + line).trim();
if (tmpPart.length > limit) {
if (part.length > 0) {
arr.push(part);
part = line;
} else {
part.substring(0, limit - 3) + "...";
part = part.substring(limit - 2);
}
} else {
part = tmpPart;
}
});
if (part !== '') arr.push(part);
return arr;
}
exports.splitLines = splitLines;