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
This commit is contained in:
SileNce5k 2021-06-27 18:14:58 +02:00
parent 0d5502bc92
commit 49e6eaed11
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
6 changed files with 19 additions and 44 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
/data/netmoduleWhitelist.json
/data/serverPrefixes.json
node_modules/
/commands/debug.js

View file

@ -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)

View file

@ -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);

View file

@ -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 }
}

4
util/getCreationDate.js Normal file
View file

@ -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();
}

5
util/getJoinDate.js Normal file
View file

@ -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();
}