mirror of
https://github.com/arthur-pbty/New-discord-bot-coins.git
synced 2026-06-25 14:16:10 +02:00
add many fonction & add &me command
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const db = require("./setDatabase.js");
|
||||
|
||||
module.exports = async function createAccount(guildId, userId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.run(
|
||||
`INSERT INTO users (guildId, userId) VALUES (?, ?)`,
|
||||
[guildId, userId],
|
||||
function(err) {
|
||||
if (err) reject(err);
|
||||
db.get(
|
||||
`SELECT * FROM users WHERE guildId = ? AND userId = ?`,
|
||||
[guildId, userId],
|
||||
function(err, row) {
|
||||
if (err) reject(err);
|
||||
resolve(row);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
module.exports = function formatDate(timestamp) {
|
||||
const currentDate = new Date();
|
||||
const targetDate = new Date(timestamp);
|
||||
|
||||
const diffTime = Math.abs(targetDate - currentDate);
|
||||
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
|
||||
const diffHours = Math.floor((diffTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
const diffMinutes = Math.floor((diffTime % (1000 * 60 * 60)) / (1000 * 60));
|
||||
|
||||
let result = "";
|
||||
if (diffDays > 0) {
|
||||
result += `${diffDays} jour${diffDays > 1 ? "s" : ""}, `;
|
||||
}
|
||||
if (diffHours > 0) {
|
||||
result += `${diffHours} heure${diffHours > 1 ? "s" : ""} et `;
|
||||
}
|
||||
result += `${diffMinutes} minute${diffMinutes > 1 ? "s" : ""}`;
|
||||
|
||||
return result;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
module.exports = function formatValue(value) {
|
||||
let number = parseFloat(value);
|
||||
if (number >= 1000000000) {
|
||||
return (number / 1000000000).toFixed(2) + "B";
|
||||
} else if (number >= 1000000) {
|
||||
return (number / 1000000).toFixed(2) + "M";
|
||||
} else if (number >= 1000) {
|
||||
return (number / 1000).toFixed(2) + "K";
|
||||
} else {
|
||||
return number.toString();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
const db = require("./setDatabase");
|
||||
|
||||
module.exports = async function getEmbedColor(serverId, memberId) {
|
||||
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 === "yellow") {
|
||||
embedColor = "#FFFF00";
|
||||
} else if (embedColor === "red") {
|
||||
embedColor = "#FF0000";
|
||||
} else if (embedColor === "orange") {
|
||||
embedColor = "#FFA500";
|
||||
} 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;
|
||||
};
|
||||
@@ -15,4 +15,18 @@ db.run(`CREATE TABLE IF NOT EXISTS prefix (
|
||||
PRIMARY KEY (guildId)
|
||||
)`);
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS users (
|
||||
guildId TEXT,
|
||||
userId TEXT,
|
||||
pocket INTEGER DEFAULT 0,
|
||||
bank INTEGER DEFAULT 0,
|
||||
reputation INTEGER DEFAULT 0,
|
||||
level INTERGER DEFAULT 0,
|
||||
xp INTERGER DEFAULT 0,
|
||||
antiRob INTEGER DEFAULT 0,
|
||||
lastRob INTEGER DEFAULT 0,
|
||||
embed TEXT DEFAULT yellow,
|
||||
PRIMARY KEY (guildId, userId)
|
||||
)`);
|
||||
|
||||
module.exports = db;
|
||||
|
||||
Reference in New Issue
Block a user