From 0c937951ad19195c196e580b65a75aad0c1e5b9e Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 17 Oct 2024 19:23:38 +0200 Subject: [PATCH 1/7] Update discord.js in package.json to v14.16.3 This is the latest version at this point in time --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51304d0..37d27a2 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "server.js", "dependencies": { "@zuzak/owo": "^1.14.1", - "discord.js": "^13.6.0", + "discord.js": "^14.16.3", "dotenv": "^16.4.5", "express": "^4.21.1", "mysql": "^2.18.1", From c7fbf25251408b5ac363205003e70f270508b5aa Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 17 Oct 2024 20:07:35 +0200 Subject: [PATCH 2/7] Use new imports and intents --- server.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index 43bbb81..a4f7193 100644 --- a/server.js +++ b/server.js @@ -20,8 +20,8 @@ const createDatabaseTables = require('./server/createDatabaseTables'); const createLastfmTable = require('./server/createLastfmTable'); createLastfmTable(); checkAndConvertJSONToSQL(); -const Discord = require('discord.js'); -const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_PRESENCES] }); +const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); +const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent], partials: [Partials.Channel] }); const { globalPrefix, token, @@ -33,10 +33,10 @@ const { presenceText } = require('./data/config.json'); -client.settings = new Discord.Collection(); -client.commands = new Discord.Collection(); -client.serverPrefixes = new Discord.Collection(); -client.netmodules = new Discord.Collection(); +client.settings = new Collection(); +client.commands = new Collection(); +client.serverPrefixes = new Collection(); +client.netmodules = new Collection(); client.settings.set("presenceType", presenceType); From 278cde8e5d9ed40446ea230718d216bfa0c5a107 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 17 Oct 2024 20:34:45 +0200 Subject: [PATCH 3/7] Update userinfo embed to work with discord.js v14 --- commands/info/userinfo.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/commands/info/userinfo.js b/commands/info/userinfo.js index 09c079f..d2b4e6d 100644 --- a/commands/info/userinfo.js +++ b/commands/info/userinfo.js @@ -1,4 +1,4 @@ -const Discord = require('discord.js'); +const {EmbedBuilder} = require('discord.js'); const getCreationDate = require('../../util/getCreationDate.js'); const getJoinDate = require('../../util/getJoinDate.js'); const getNickname = require('../../util/getNickname.js'); @@ -49,22 +49,27 @@ module.exports = { if(discriminator === "0") discriminator = ""; let username = `**${user.user.username}#${user.user.discriminator}**${nickname}` - const embed = new Discord.MessageEmbed() + const embed = new EmbedBuilder() .setThumbnail(user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })) .setColor(roleColor) .setTimestamp() - .setAuthor(user.user.username, user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })) - .addField("Username", username) - .addField("Status", status, false) - if(isPresence) - embed.addField("Presence", user.presence.activities[0].name, false) - if(presenceDetails != 0) - embed.addField("Details", presenceDetails.toString(), false) - embed.addField("Creation date", getCreationDate(user), true) - embed.addField("Join date", getJoinDate(user, message.guild), true) - if(roles != ""){ - embed.addField("Roles", roles) - } + .setAuthor({name: user.user.username, iconURL: user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })}) + .addFields([ + { name: "Username", value: username, inline: false }, + { name: "Status", value: status, inline: true }, + ]); + if (isPresence) + embed.addFields([{name: "Presence", value: user.presence.activities[0].name, inline: false}]) + if (presenceDetails != 0) + embed.addFields([{name: "Details", value: presenceDetails.toString(), inline: false}]) + embed.addFields([{ name: "Details", value: presenceDetails.toString(), inline: false }]) + embed.addFields([ + { name: "Creation date", value: getCreationDate(user), inline: true }, + { name: "Join date", value: getJoinDate(user, message.guild), inline: true } + ]) + if (roles != "") { + embed.addFields({name: "Roles", value: roles, inline: false}) + } message.channel.send({embeds :[embed]}); } From 2005e6141634d58998ae9820702c34e4b3f1c786 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 17 Oct 2024 21:31:37 +0200 Subject: [PATCH 4/7] Add Intent bit for GuildMembers and GuildPresences Need this for parseMention to work --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index a4f7193..eacf2a5 100644 --- a/server.js +++ b/server.js @@ -21,7 +21,7 @@ const createLastfmTable = require('./server/createLastfmTable'); createLastfmTable(); checkAndConvertJSONToSQL(); const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); -const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent], partials: [Partials.Channel] }); +const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences], partials: [Partials.Channel] }); const { globalPrefix, token, From 90b6225a555534b23625e44dde2d9a30ba388955 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 22 Oct 2024 02:06:36 +0200 Subject: [PATCH 5/7] Fix Details showing up twice in userinfo --- commands/info/userinfo.js | 1 - 1 file changed, 1 deletion(-) diff --git a/commands/info/userinfo.js b/commands/info/userinfo.js index d2b4e6d..cf9f4f7 100644 --- a/commands/info/userinfo.js +++ b/commands/info/userinfo.js @@ -62,7 +62,6 @@ module.exports = { embed.addFields([{name: "Presence", value: user.presence.activities[0].name, inline: false}]) if (presenceDetails != 0) embed.addFields([{name: "Details", value: presenceDetails.toString(), inline: false}]) - embed.addFields([{ name: "Details", value: presenceDetails.toString(), inline: false }]) embed.addFields([ { name: "Creation date", value: getCreationDate(user), inline: true }, { name: "Join date", value: getJoinDate(user, message.guild), inline: true } From 58cfba27d08384fe37ddc7acab8dfd262571e704 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 22 Oct 2024 02:09:56 +0200 Subject: [PATCH 6/7] Fix alignment in userinfo --- commands/info/userinfo.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/info/userinfo.js b/commands/info/userinfo.js index cf9f4f7..47265f8 100644 --- a/commands/info/userinfo.js +++ b/commands/info/userinfo.js @@ -56,12 +56,15 @@ module.exports = { .setAuthor({name: user.user.username, iconURL: user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })}) .addFields([ { name: "Username", value: username, inline: false }, - { name: "Status", value: status, inline: true }, ]); if (isPresence) embed.addFields([{name: "Presence", value: user.presence.activities[0].name, inline: false}]) - if (presenceDetails != 0) + if (presenceDetails != 0){ embed.addFields([{name: "Details", value: presenceDetails.toString(), inline: false}]) + embed.addFields([{name: "Status", value: status, inline: true }]) + } + else + embed.addFields([{ name: "Status", value: status, inline: false }]) embed.addFields([ { name: "Creation date", value: getCreationDate(user), inline: true }, { name: "Join date", value: getJoinDate(user, message.guild), inline: true } From e112050e69b96b1eb3610978756ec195f4e34c9c Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 22 Oct 2024 02:19:42 +0200 Subject: [PATCH 7/7] Do not show discriminator if it is 0 --- commands/info/userinfo.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/info/userinfo.js b/commands/info/userinfo.js index 47265f8..9984f50 100644 --- a/commands/info/userinfo.js +++ b/commands/info/userinfo.js @@ -48,7 +48,9 @@ module.exports = { let discriminator = user.user.discriminator; if(discriminator === "0") discriminator = ""; - let username = `**${user.user.username}#${user.user.discriminator}**${nickname}` + else + discriminator = `#${discriminator}`; + let username = `**${user.user.username}${discriminator}**${nickname}`; const embed = new EmbedBuilder() .setThumbnail(user.user.avatarURL({ format: 'png', dynamic: true, size: 2048 })) .setColor(roleColor)