From 49e6eaed1169b181518d7bc82ee1edd067859101 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Sun, 27 Jun 2021 18:14:58 +0200 Subject: [PATCH] Rewrite createdate and joindate gets Update botinfo to work with new getCreationDate Update userinfo to work with new getCreationDate Update userinfo to work with new getJoinDate --- .gitignore | 3 ++- commands/botinfo.js | 8 +++----- commands/userinfo.js | 9 +++++---- util/creationJoinDates.js | 34 ---------------------------------- util/getCreationDate.js | 4 ++++ util/getJoinDate.js | 5 +++++ 6 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 util/creationJoinDates.js create mode 100644 util/getCreationDate.js create mode 100644 util/getJoinDate.js diff --git a/.gitignore b/.gitignore index 2525125..542f9db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /data/config.json /data/netmoduleWhitelist.json /data/serverPrefixes.json -node_modules/ \ No newline at end of file +node_modules/ +/commands/debug.js \ No newline at end of file diff --git a/commands/botinfo.js b/commands/botinfo.js index 11f5088..3b989cf 100644 --- a/commands/botinfo.js +++ b/commands/botinfo.js @@ -1,21 +1,19 @@ const Discord = require('discord.js'); -const { prefix } = require('../data/config.json'); -const creationJoinDates = require("../util/creationJoinDates") +const getCreationDate = require('../util/getCreationDate'); module.exports = { name: 'botinfo', description: 'Shows information about the bot', - execute({message, client}) { - let createJoin = creationJoinDates(client.user) + execute({message, client, prefix}) { const embed = new Discord.MessageEmbed() .setColor(15780145) .setTitle("Information about bot") .setTimestamp() .setAuthor(client.user.username, client.user.avatarURL({ dynamic: true, size: 4096 })) .addFields({ - name: "General info", value: `Name: ${client.user.username}\nPrefix: ${prefix}\nTotal Servers: ${client.guilds.toString().length}\nCreation Date: ${createJoin.creation}\nSource: [Click Here](https://github.com/SileNce5k/discord_bot)`, + name: "General info", value: `Name: ${client.user.username}\nPrefix: ${prefix}\nTotal Servers: ${client.guilds.toString().length}\nCreation Date: ${getCreationDate(client.user)}\nSource: [Click Here](https://github.com/SileNce5k/discord_bot)`, },) message.channel.send(embed) diff --git a/commands/userinfo.js b/commands/userinfo.js index 66949dd..cd3ea3d 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -1,6 +1,7 @@ const Discord = require('discord.js'); +const getCreationDate = require('../util/getCreationDate.js'); +const getJoinDate = require('../util/getJoinDate.js'); const parseMention = require("../util/parseMention.js") -const creationJoinDates = require("../util/creationJoinDates") module.exports = { name: 'userinfo', @@ -24,7 +25,7 @@ module.exports = { roleColor = user.roles.color.color; } - var createJoin = creationJoinDates(user.user) + const embed = new Discord.MessageEmbed() .setThumbnail(user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })) .setColor(roleColor) @@ -32,8 +33,8 @@ module.exports = { .setAuthor(user.user.username, user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })) .addField("Username", `**${user.user.username}#${user.user.discriminator}**${nickname}`) .addField("Presence", user.user.presence.activities[0].name) - //.addField("Joined", createJoin.joindate, true) - .addField("Creation date", createJoin.creation, true) + .addField("Joined", getJoinDate(user, message.guild)) + .addField("Creation date", getCreationDate(user), true) .addField("Join date", user.joinDate, true) message.channel.send(embed); diff --git a/util/creationJoinDates.js b/util/creationJoinDates.js deleted file mode 100644 index 8a4d38f..0000000 --- a/util/creationJoinDates.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = function (user) { - let creationMonth, creationDate, creationHours, creationMinutes, creationSeconds; - - if (user.createdAt.getUTCMonth().toString().length === 1) - creationMonth = "0" + (1+user.createdAt.getUTCMonth()) - else - creationMonth = (1+user.createdAt.getUTCMonth()) - - if (user.createdAt.getUTCDate().toString().length === 1) - creationDate = "0" + user.createdAt.getUTCDate() - else - creationDate = user.createdAt.getUTCDate() - - if (user.createdAt.getUTCHours().toString().length === 1) - creationHours = "0" + user.createdAt.getUTCHours() - else - creationHours = user.createdAt.getUTCHours() - - - if (user.createdAt.getUTCMinutes().toString().length === 1) - creationMinutes = "0" + user.createdAt.getUTCMinutes() - else - creationMinutes = user.createdAt.getUTCMinutes() - - - if (user.createdAt.getUTCSeconds().toString().length === 1) - creationSeconds = "0" + user.createdAt.getUTCSeconds() - else - creationSeconds = user.createdAt.getUTCSeconds() - - - let creation = `${user.createdAt.getUTCFullYear()}-${creationMonth}-${creationDate} ${creationHours}:${creationMinutes}:${creationSeconds}` - return { creation: creation } -} \ No newline at end of file diff --git a/util/getCreationDate.js b/util/getCreationDate.js new file mode 100644 index 0000000..de9e6a9 --- /dev/null +++ b/util/getCreationDate.js @@ -0,0 +1,4 @@ +module.exports = function(user){ + let date = user.createdAt; + return date.getUTCFullYear().toString()+"-"+date.getUTCMonth()+"-"+date.getUTCDate()+" "+date.getUTCHours()+":"+date.getUTCMinutes()+":"+date.getUTCSeconds(); +} \ No newline at end of file diff --git a/util/getJoinDate.js b/util/getJoinDate.js new file mode 100644 index 0000000..9ca5229 --- /dev/null +++ b/util/getJoinDate.js @@ -0,0 +1,5 @@ +module.exports = function(user, guild){ + const member = guild.member(user) + let date = member.joinedAt; + return date.getUTCFullYear().toString()+"-"+date.getUTCMonth()+"-"+date.getUTCDate()+" "+date.getUTCHours()+":"+date.getUTCMinutes()+":"+date.getUTCSeconds(); +} \ No newline at end of file