5.0.0 dev v3 channel / data collection tests
This commit is contained in:
7 files changed
+301
-99
No files matched your search
@@ -8,6 +8,7 @@ const path = require("path");
|
||||
const fs = require('fs');
|
||||
const { Readable } = require('stream');
|
||||
const { finished } = require('stream/promises');
|
||||
const readline = require('readline');
|
||||
|
||||
class DayzArmbands extends Client {
|
||||
|
||||
@@ -102,6 +103,19 @@ class DayzArmbands extends Client {
|
||||
const stream = fs.createWriteStream('./logs/server-logs.ADM');
|
||||
const { body } = await fetch(res.data.token.url);
|
||||
await finished(Readable.fromWeb(body).pipe(stream));
|
||||
|
||||
const fileStream = fs.createReadStream('./logs/server-logs.ADM');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
crlfDelay: Infinity
|
||||
});
|
||||
let lines = [];
|
||||
for await (const line of rl) { lines.push(line); }
|
||||
|
||||
const channel = this.channels.cache.get('993272430342721597');
|
||||
|
||||
channel.send({ content: lines[lines.length-1] });
|
||||
}
|
||||
|
||||
async connectMongo(mongoURI, dbo) {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let bankSchema = mongoose.Schema({
|
||||
banking: {
|
||||
userID: String,
|
||||
guilds: {}
|
||||
}
|
||||
});
|
||||
|
||||
bankSchema.methods.createBank = function (userID, guildID, startingBalance, cash) {
|
||||
this.banking.userID = userID;
|
||||
this.banking.guilds = {};
|
||||
this.banking.guilds[guildID] = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: cash,
|
||||
}
|
||||
};;
|
||||
};
|
||||
|
||||
/*
|
||||
This function is to add a new guild specific bank to an already existing
|
||||
bank document
|
||||
or
|
||||
can be used to reset a data back to default
|
||||
*/
|
||||
function addBank(guilds, guildID, userID, client, startingBalance) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":userID}, {$set: {"banking.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Bank: mongoose.model('Bank', bankSchema),
|
||||
addBank: addBank,
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let userSchema = mongoose.Schema({
|
||||
user: {
|
||||
userID: String,
|
||||
guilds: {}
|
||||
},
|
||||
});
|
||||
|
||||
userSchema.methods.createUser = function (userID, guildID, startingBalance, cash) {
|
||||
this.user.userID = userID;
|
||||
this.user.guilds = {};
|
||||
this.user.guilds[guildID] = {
|
||||
bankAccount: {
|
||||
balance: startingBalance,
|
||||
cash: cash,
|
||||
},
|
||||
faction: "",
|
||||
gamertag: ""
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
This function is to add a new guild specific user to an already existing
|
||||
user document
|
||||
or
|
||||
can be used to reset a data back to default
|
||||
*/
|
||||
function addUser(guilds, guildID, userID, client, startingBalance) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
bankAccount: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("users").updateOne({"user.userID":userID}, {$set: {"user.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
User: mongoose.model('User', userSchema),
|
||||
addUser: addUser,
|
||||
};
|
||||
Reference in new issue
Block a user