mirror of
https://github.com/arthur-pbty/bot-discord-coins.git
synced 2026-06-03 23:36:29 +02:00
format all file
This commit is contained in:
+85
-85
@@ -1,85 +1,85 @@
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
let db = new sqlite3.Database('./db.sqlite');
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS config (
|
||||
guildId TEXT,
|
||||
name TEXT,
|
||||
value TEXT,
|
||||
PRIMARY KEY (guildId, name)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS users (
|
||||
guildId TEXT,
|
||||
userId TEXT,
|
||||
pocket INTEGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
reputation INTEGER DEFAULT 0,
|
||||
lvl INTERGER DEFAULT 0,
|
||||
xp INTERGER DEFAULT 0,
|
||||
objet INTERGER DEFAULT 0,
|
||||
key INTERGER DEFAULT 0,
|
||||
buyer BOOLEAN DEFAULT FALSE,
|
||||
owner BOOLEAN DEFAULT FALSE,
|
||||
whitelist BOOLEAN DEFAULT FALSE,
|
||||
blacklist BOOLEAN DEFAULT FALSE,
|
||||
antiRob INTEGER DEFAULT 0,
|
||||
lastRob INTEGER DEFAULT 0,
|
||||
lastRecolt INTEGER DEFAULT 0,
|
||||
lastWork INTEGER DEFAULT 0,
|
||||
lastDaily INTEGER DEFAULT 0,
|
||||
lastRep INTERGER DEFAULT 0,
|
||||
lastTrep INTERGER DEFAULT 0,
|
||||
lastArep INTERGER DEFAULT 0,
|
||||
lastHack INTERGER DEFAULT 0,
|
||||
lastKill INTERGER DEFAULT 0,
|
||||
lastBraquage INTERGER DEFAULT 0,
|
||||
job TEXT,
|
||||
teamId TEXT,
|
||||
teamRole TEXT,
|
||||
teamDroper INTERGER DEFAULT 0,
|
||||
embed TEXT,
|
||||
PRIMARY KEY (guildId, userId)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS teams (
|
||||
guildId TEXT,
|
||||
id TEXT,
|
||||
name TEXT,
|
||||
description TEXT,
|
||||
icon TEXT,
|
||||
banner TEXT,
|
||||
reputation INTERGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
location INTERGER DEFAULT 0,
|
||||
level INTEGER DEFAULT 1,
|
||||
padlock INTEGER DEFAULT 5,
|
||||
soldiers INTEGER DEFAULT 0,
|
||||
woundedSoldiers INTEGER DEFAULT 0,
|
||||
campLevel INTEGER DEFAULT 1,
|
||||
turrets INTEGER DEFAULT 0,
|
||||
alliancesId TEXT,
|
||||
PRIMARY KEY (guildId, id)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS alliances (
|
||||
guildId TEXT,
|
||||
id TEXT,
|
||||
creator TEXT,
|
||||
name TEXT,
|
||||
description TEXT,
|
||||
icon TEXT,
|
||||
banner TEXT,
|
||||
reputation INTERGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (guildId, id)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS rolePermission (
|
||||
guildId TEXT,
|
||||
roleId TEXT,
|
||||
permission INTEGER,
|
||||
PRIMARY KEY (guildId, permission)
|
||||
)`);
|
||||
|
||||
module.exports = db;
|
||||
const sqlite3 = require("sqlite3").verbose();
|
||||
|
||||
let db = new sqlite3.Database("./db.sqlite");
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS config (
|
||||
guildId TEXT,
|
||||
name TEXT,
|
||||
value TEXT,
|
||||
PRIMARY KEY (guildId, name)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS users (
|
||||
guildId TEXT,
|
||||
userId TEXT,
|
||||
pocket INTEGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
reputation INTEGER DEFAULT 0,
|
||||
lvl INTERGER DEFAULT 0,
|
||||
xp INTERGER DEFAULT 0,
|
||||
objet INTERGER DEFAULT 0,
|
||||
key INTERGER DEFAULT 0,
|
||||
buyer BOOLEAN DEFAULT FALSE,
|
||||
owner BOOLEAN DEFAULT FALSE,
|
||||
whitelist BOOLEAN DEFAULT FALSE,
|
||||
blacklist BOOLEAN DEFAULT FALSE,
|
||||
antiRob INTEGER DEFAULT 0,
|
||||
lastRob INTEGER DEFAULT 0,
|
||||
lastRecolt INTEGER DEFAULT 0,
|
||||
lastWork INTEGER DEFAULT 0,
|
||||
lastDaily INTEGER DEFAULT 0,
|
||||
lastRep INTERGER DEFAULT 0,
|
||||
lastTrep INTERGER DEFAULT 0,
|
||||
lastArep INTERGER DEFAULT 0,
|
||||
lastHack INTERGER DEFAULT 0,
|
||||
lastKill INTERGER DEFAULT 0,
|
||||
lastBraquage INTERGER DEFAULT 0,
|
||||
job TEXT,
|
||||
teamId TEXT,
|
||||
teamRole TEXT,
|
||||
teamDroper INTERGER DEFAULT 0,
|
||||
embed TEXT,
|
||||
PRIMARY KEY (guildId, userId)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS teams (
|
||||
guildId TEXT,
|
||||
id TEXT,
|
||||
name TEXT,
|
||||
description TEXT,
|
||||
icon TEXT,
|
||||
banner TEXT,
|
||||
reputation INTERGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
location INTERGER DEFAULT 0,
|
||||
level INTEGER DEFAULT 1,
|
||||
padlock INTEGER DEFAULT 5,
|
||||
soldiers INTEGER DEFAULT 0,
|
||||
woundedSoldiers INTEGER DEFAULT 0,
|
||||
campLevel INTEGER DEFAULT 1,
|
||||
turrets INTEGER DEFAULT 0,
|
||||
alliancesId TEXT,
|
||||
PRIMARY KEY (guildId, id)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS alliances (
|
||||
guildId TEXT,
|
||||
id TEXT,
|
||||
creator TEXT,
|
||||
name TEXT,
|
||||
description TEXT,
|
||||
icon TEXT,
|
||||
banner TEXT,
|
||||
reputation INTERGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (guildId, id)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS rolePermission (
|
||||
guildId TEXT,
|
||||
roleId TEXT,
|
||||
permission INTEGER,
|
||||
PRIMARY KEY (guildId, permission)
|
||||
)`);
|
||||
|
||||
module.exports = db;
|
||||
|
||||
+51
-37
@@ -1,37 +1,51 @@
|
||||
const db = require('./database.js');
|
||||
|
||||
module.exports = async function embedColor(memberId, serverId) {
|
||||
const user = await new Promise((resolve, reject) => {
|
||||
db.get(`SELECT * FROM users WHERE guildId = ? AND userId = ?`, [serverId, memberId], (err, row) => {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
});
|
||||
});
|
||||
let embedColor = user.embed;
|
||||
if (embedColor === 'random') {
|
||||
const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'brown', 'black', 'white'];
|
||||
embedColor = colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
if (!embedColor) {
|
||||
embedColor = '#FFD700';
|
||||
} else if (embedColor === 'red') {
|
||||
embedColor = '#FF0000';
|
||||
} else if (embedColor === 'orange') {
|
||||
embedColor = '#FFA500';
|
||||
} else if (embedColor === 'yellow') {
|
||||
embedColor = '#FFFF00';
|
||||
} else if (embedColor === 'green') {
|
||||
embedColor = '#008000';
|
||||
} else if (embedColor === 'blue') {
|
||||
embedColor = '#0000FF';
|
||||
} else if (embedColor === 'purple') {
|
||||
embedColor = '#800080';
|
||||
} else if (embedColor === 'brown') {
|
||||
embedColor = '#A52A2A';
|
||||
} else if (embedColor === 'black') {
|
||||
embedColor = '#000000';
|
||||
} else if (embedColor === 'white') {
|
||||
embedColor = '#FFFFFF';
|
||||
}
|
||||
return embedColor;
|
||||
}
|
||||
const db = require("./database.js");
|
||||
|
||||
module.exports = async function embedColor(memberId, serverId) {
|
||||
const user = await new Promise((resolve, reject) => {
|
||||
db.get(
|
||||
`SELECT * FROM users WHERE guildId = ? AND userId = ?`,
|
||||
[serverId, memberId],
|
||||
(err, row) => {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
},
|
||||
);
|
||||
});
|
||||
let embedColor = user.embed;
|
||||
if (embedColor === "random") {
|
||||
const colors = [
|
||||
"red",
|
||||
"orange",
|
||||
"yellow",
|
||||
"green",
|
||||
"blue",
|
||||
"purple",
|
||||
"brown",
|
||||
"black",
|
||||
"white",
|
||||
];
|
||||
embedColor = colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
if (!embedColor) {
|
||||
embedColor = "#FFD700";
|
||||
} else if (embedColor === "red") {
|
||||
embedColor = "#FF0000";
|
||||
} else if (embedColor === "orange") {
|
||||
embedColor = "#FFA500";
|
||||
} else if (embedColor === "yellow") {
|
||||
embedColor = "#FFFF00";
|
||||
} else if (embedColor === "green") {
|
||||
embedColor = "#008000";
|
||||
} else if (embedColor === "blue") {
|
||||
embedColor = "#0000FF";
|
||||
} else if (embedColor === "purple") {
|
||||
embedColor = "#800080";
|
||||
} else if (embedColor === "brown") {
|
||||
embedColor = "#A52A2A";
|
||||
} else if (embedColor === "black") {
|
||||
embedColor = "#000000";
|
||||
} else if (embedColor === "white") {
|
||||
embedColor = "#FFFFFF";
|
||||
}
|
||||
return embedColor;
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
const db = require('./database.js');
|
||||
const db = require("./database.js");
|
||||
|
||||
module.exports = async function getPermissionLevel(serverId, user) {
|
||||
const roles = user.roles.cache.map(role => role.id);
|
||||
const roles = user.roles.cache.map((role) => role.id);
|
||||
|
||||
const perms = await new Promise((resolve, reject) => {
|
||||
db.all(`SELECT * FROM rolePermission WHERE guildId = ? AND roleId IN (${roles.map(() => '?').join(',')})`, [serverId, ...roles], (err, rows) => {
|
||||
if (err) reject(err);
|
||||
resolve(rows);
|
||||
});
|
||||
db.all(
|
||||
`SELECT * FROM rolePermission WHERE guildId = ? AND roleId IN (${roles.map(() => "?").join(",")})`,
|
||||
[serverId, ...roles],
|
||||
(err, rows) => {
|
||||
if (err) reject(err);
|
||||
resolve(rows);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const highestPermission = Math.max(...perms.map(perm => perm.permission));
|
||||
|
||||
const highestPermission = Math.max(...perms.map((perm) => perm.permission));
|
||||
return highestPermission;
|
||||
}
|
||||
};
|
||||
|
||||
+11
-7
@@ -1,12 +1,16 @@
|
||||
const db = require('./database.js');
|
||||
const db = require("./database.js");
|
||||
|
||||
module.exports = async function getPrefix(serverId) {
|
||||
const prefix = await new Promise((resolve, reject) => {
|
||||
db.get(`SELECT * FROM config WHERE guildId = ? AND name = ?`, [serverId, 'prefix'], (err, row) => {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
});
|
||||
db.get(
|
||||
`SELECT * FROM config WHERE guildId = ? AND name = ?`,
|
||||
[serverId, "prefix"],
|
||||
(err, row) => {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
return prefix ? prefix.value : '&';
|
||||
}
|
||||
return prefix ? prefix.value : "&";
|
||||
};
|
||||
|
||||
+35
-35
@@ -1,35 +1,35 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function loadCommands(client, dir) {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
count += loadCommands(client, path.join(dir, file));
|
||||
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
try {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const command = require(filePath);
|
||||
const fileName = file.replace(/\.js|\.ts/g, '');
|
||||
if (!command.name) command.name = fileName;
|
||||
if (!command.category) {
|
||||
const parentDir = path.basename(path.dirname(filePath));
|
||||
command.category = parentDir === 'commands' ? 'other' : parentDir;
|
||||
}
|
||||
if (!command.permission) command.permission = 0;
|
||||
client.commands.set(fileName, command);
|
||||
if (command.aliases) {
|
||||
command.aliases.forEach((alias) => {
|
||||
client.commands.set(alias, command);
|
||||
});
|
||||
}
|
||||
count++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to load file: ${filePath}`);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = function loadCommands(client, dir) {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
count += loadCommands(client, path.join(dir, file));
|
||||
} else if (file.endsWith(".js") || file.endsWith(".ts")) {
|
||||
try {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const command = require(filePath);
|
||||
const fileName = file.replace(/\.js|\.ts/g, "");
|
||||
if (!command.name) command.name = fileName;
|
||||
if (!command.category) {
|
||||
const parentDir = path.basename(path.dirname(filePath));
|
||||
command.category = parentDir === "commands" ? "other" : parentDir;
|
||||
}
|
||||
if (!command.permission) command.permission = 0;
|
||||
client.commands.set(fileName, command);
|
||||
if (command.aliases) {
|
||||
command.aliases.forEach((alias) => {
|
||||
client.commands.set(alias, command);
|
||||
});
|
||||
}
|
||||
count++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to load file: ${filePath}`);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function loadEvents(client, dir) {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
loadEvents(client, path.join(dir, file));
|
||||
} else if (file.endsWith('.js') || file.endsWith('.ts')) {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const event = require(filePath);
|
||||
if (typeof event.execute === 'function') {
|
||||
client.on(event.name, (...args) => event.execute(...args, client)); // Specify the type of 'args' as an array of any type
|
||||
count++;
|
||||
} else {
|
||||
console.error(`Event ${event.name} does not have an execute method.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports = function loadEvents(client, dir) {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
loadEvents(client, path.join(dir, file));
|
||||
} else if (file.endsWith(".js") || file.endsWith(".ts")) {
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const event = require(filePath);
|
||||
if (typeof event.execute === "function") {
|
||||
client.on(event.name, (...args) => event.execute(...args, client)); // Specify the type of 'args' as an array of any type
|
||||
count++;
|
||||
} else {
|
||||
console.error(`Event ${event.name} does not have an execute method.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user