diff --git a/Bane.js b/Bane.js index d9b3185..1ccd8f7 100644 --- a/Bane.js +++ b/Bane.js @@ -52,8 +52,10 @@ bot.on("ready", () => { // when bot is ready } else { setTimeout(function() { // in a 2,5 second timeout console.log(`Başladı! Şu an ${bot.guilds.size} adet sunucuya (ve ${bot.channels.filter(c => c.type === "text").size} yazı kanalına) hizmet veriyorum.\nGün içindeki bağlanma sayısı: ${connectionCount}`); // print that the bot is ready with total stats - bot.user.setStatus("online").then(u => { - u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + bot.user.setStatus("online").then(async u => { + await u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + }).catch(e => { + console.error(`Err in setStatus, ${e}`); }); // set status as online, with the game }, 2500); } @@ -130,15 +132,19 @@ bot.on("message", message => { // on message bot.on("guildCreate", guild => { // when bot joins to a guild console.log(`Yeni bir sunucuya katıldım!\n Ad: ${guild.name}\n ID: ${guild.id}\n\n Sahibi:\n Tag: ${guild.owner.user.tag}\n ID: ${guild.owner.user.id}\n`); // print what the guild is and who owns it - bot.user.setStatus("online").then(u => { - u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + bot.user.setStatus("online").then(async u => { + await u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + }).catch(e => { + console.error(`Err in setStatus, ${e}`); }); // set status as online, with the game }); bot.on("guildDelete", guild => { // when bot leaves or deletes a guild console.log(`Bir sunucudan ayrıldım!\n Ad: ${guild.name}\n ID: ${guild.id}\n\n Sahibi:\n Tag: ${guild.owner.user.tag}\n ID: ${guild.owner.user.id}\n`); // print what the guild was and who owned it - bot.user.setStatus("online").then(u => { - u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + bot.user.setStatus("online").then(async u => { + await u.setGame(`${startGame} | ${bot.guilds.size} guild(s)`); + }).catch(e => { + console.error(`Err in setStatus, ${e}`); }); // set status as online, with the game }); diff --git a/Komutlar.js b/Komutlar.js index d3725cb..283574d 100644 --- a/Komutlar.js +++ b/Komutlar.js @@ -81,17 +81,18 @@ function secondsToHms(d) { return ((h > 0 ? h + ":" + (m < 10 ? "0" : "") : "") + m + ":" + (s < 10 ? "0" : "") + s); }; -function msToTime(duration) { - var milliseconds = parseInt((duration % 1000) / 100), - seconds = parseInt((duration / 1000) % 60), - minutes = parseInt((duration / (1000 * 60)) % 60), - hours = parseInt((duration / (1000 * 60 * 60)) % 24); - - hours = (hours < 10) ? "0" + hours : hours; - minutes = (minutes < 10) ? "0" + minutes : minutes; - seconds = (seconds < 10) ? "0" + seconds : seconds; +Number.prototype.toTime = function(isSec) { + var ms = isSec ? this * 1e3 : this, + lm = ~(4 * !!isSec), /* limit fraction */ + fmt = new Date(ms).toISOString().slice(11, lm); + + if (ms >= 8.64e7) { /* >= 24 hours */ + var parts = fmt.split(/:(?=\d{2}:)/); + parts[0] -= -24 * (ms / 8.64e7 | 0); + return parts.join(':'); + } - return hours + ":" + minutes + ":" + seconds + "." + milliseconds; + return fmt; }; function sendToHastebin(data) { @@ -207,7 +208,7 @@ exports.commands = { .array() // makes the collection to an array .slice((messages.length - amount)); // removes the unwanted messages - if (!messagesSec.length) return []; // if there are no messages to delete, make an empty array + if (!messagesSec.length || messagesSec.length <= 0) return []; // if there are no messages to delete, make an empty array if (messagesSec.length === 1) { // if there is only one message return [await messages.last().delete().catch(e => { @@ -727,6 +728,15 @@ exports.commands = { }); } var config = require(jsonFolder + "config.json"); + if (!config.google_api_key) { + return bot.fetchApplication().then(app => { + bot.users.get(app.owner.id).send("Google API Key is Missing!").catch(e => { + console.error("Err in command: " + e); + }); + }).catch(e => { + console.error("Err in command: " + e); + }); + } var params = { auth: config.google_api_key, shortUrl: cachedUnshort @@ -777,6 +787,15 @@ exports.commands = { }); } var config = require(jsonFolder + "config.json"); + if (!config.google_api_key) { + return bot.fetchApplication().then(app => { + bot.users.get(app.owner.id).send("Google API Key is Missing!").catch(e => { + console.error("Err in command: " + e); + }); + }).catch(e => { + console.error("Err in command: " + e); + }); + } var params = { auth: config.google_api_key, resource: { @@ -1176,6 +1195,7 @@ exports.commands = { const Discord = require("discord.js"); var timezone = new Date(); timezone = timezone.toString().match(/GMT\+?\-?\d*/)[0]; + var guildMembersCounts = bot.guilds.map(g => g.members.size).reduce((a, b) => a + b, 0); message.channel.send({ embed: { color: get_random_decimal_color(), @@ -1185,16 +1205,20 @@ exports.commands = { }, fields: [{ name: 'Uptime (HH:MM:SS.mmm)', - value: `** ** **Operating System**: ${msToTime(opsys.uptime() * 1000)}\n **Process**: ${msToTime(process.uptime() * 1000)}\n **User**: ${msToTime((bot.uptime))}` + value: `** ** **Operating System**: ${(opsys.uptime() * 1000).toTime()}\n **Process**: ${(process.uptime() * 1000).toTime()}\n **User**: ${bot.uptime.toTime()}` }, { - name: 'Extra', + name: 'System Info', value: `** ** **Node Version**: ${process.versions.node}\n **Discord.js version**: v${Discord.version}\n **Memory usage**: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB\n\n Running on a ${opsys.cpus().length} core server with ${opsys.platform()} and ${Math.floor(opsys.totalmem() / 1024 / 1024)} MB RAM on board.\n` + }, + { + name: 'Bot\'s State', + value: `** ** **Guild(s)**: ${bot.guilds.size}\n **Cached Members**: ${bot.users.size}\n **Total Member Count**: ${guildMembersCounts}` } ], timestamp: new Date(), footer: { - icon_url: bot.user.avatarURL, + icon_url: bot.users.get("120267401672523776").displayAvatarURL, text: `Developed by linuxgemini#3568.` } } @@ -1267,10 +1291,10 @@ exports.commands = { .setTimestamp(new Date()) .setFooter(`Information requested by ${message.author.tag}`, message.author.displayAvatarURL); message.channel.send({embed: returningEmbed}).catch(e => { - console.error(e); + console.error("Err in command: " + e); }); }).catch(e => { - console.error(e); + console.error("Err in command: " + e); }); } else { const returningEmbed = new Discord.RichEmbed() @@ -1289,7 +1313,7 @@ exports.commands = { .setTimestamp(new Date()) .setFooter(`Information requested by ${message.author.tag}`, message.author.displayAvatarURL); message.channel.send({embed: returningEmbed}).catch(e => { - console.error(e); + console.error("Err in command: " + e); }); } } diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file