updated profile and centralized functions
This commit is contained in:
@@ -1,54 +1,51 @@
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildAchievementsEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileAchievements",
|
||||
name: "profileAchievements",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
0
|
||||
);
|
||||
const result = await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
0,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileAchievementsLeft",
|
||||
"profileAchievementsRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"achievements",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,54 +1,53 @@
|
||||
// buttons/profile/achievementsLeft.js
|
||||
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildAchievementsEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileAchievementsLeft",
|
||||
name: "profileAchievementsLeft",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
context.page - 1
|
||||
);
|
||||
const result = await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
session.page - 1,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileAchievementsLeft",
|
||||
"profileAchievementsRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"achievements",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,54 +1,53 @@
|
||||
// buttons/profile/achievementsRight.js
|
||||
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildAchievementsEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileAchievementsRight",
|
||||
name: "profileAchievementsRight",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
context.page + 1
|
||||
);
|
||||
const result = await buildAchievementsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
session.page + 1,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileAchievementsLeft",
|
||||
"profileAchievementsRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"achievements",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
+34
-37
@@ -1,54 +1,51 @@
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildBadgesEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileBadges",
|
||||
name: "profileBadges",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
0
|
||||
);
|
||||
const result = await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
0,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileBadgesLeft",
|
||||
"profileBadgesRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"badges",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,54 +1,53 @@
|
||||
// buttons/profile/badgesLeft.js
|
||||
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildBadgesEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileBadgesLeft",
|
||||
name: "profileBadgesLeft",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
context.page - 1
|
||||
);
|
||||
const result = await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
session.page - 1,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileBadgesLeft",
|
||||
"profileBadgesRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"badges",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,54 +1,53 @@
|
||||
// buttons/profile/badgesRight.js
|
||||
|
||||
const {
|
||||
requireProfileOwner,
|
||||
buildBadgesEmbed,
|
||||
buildProfileButtons,
|
||||
getProfileContextFromFooter,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
buildProfilePaginationButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileBadgesRight",
|
||||
name: "profileBadgesRight",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId,
|
||||
context.page + 1
|
||||
);
|
||||
const result = await buildBadgesEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
session.page + 1,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
const pageContext =
|
||||
getProfileContextFromFooter(
|
||||
embed.data.footer?.text
|
||||
const components = [
|
||||
...buildProfileButtons()
|
||||
];
|
||||
|
||||
if (result.pageCount > 1) {
|
||||
components.push(
|
||||
buildProfilePaginationButtons(
|
||||
"profileBadgesLeft",
|
||||
"profileBadgesRight",
|
||||
result.page,
|
||||
result.pageCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"badges",
|
||||
pageContext?.page ?? 0,
|
||||
pageContext?.pageCount ?? 1
|
||||
)
|
||||
embeds: [result.embed],
|
||||
components
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
+20
-33
@@ -1,47 +1,34 @@
|
||||
const {
|
||||
buildStatsEmbed,
|
||||
buildProfileButtons,
|
||||
requireProfileOwner
|
||||
} = require(
|
||||
"../../utils/profileSystem"
|
||||
);
|
||||
requireProfileOwner,
|
||||
buildProfileStatsEmbed,
|
||||
buildProfileButtons
|
||||
} = require("../../utils/profileSystem");
|
||||
|
||||
module.exports = {
|
||||
name:
|
||||
"profileStats",
|
||||
name: "profileStats",
|
||||
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
const context =
|
||||
await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
async execute(interaction) {
|
||||
const session = await requireProfileOwner(
|
||||
interaction
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user =
|
||||
await interaction.client.users.fetch(
|
||||
context.profileUserId
|
||||
);
|
||||
const user = await interaction.client.users.fetch(
|
||||
session.profileUserId
|
||||
);
|
||||
|
||||
const embed =
|
||||
await buildStatsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
context.sessionOwnerId
|
||||
);
|
||||
const embed = await buildProfileStatsEmbed(
|
||||
interaction.guildId,
|
||||
user,
|
||||
session.sessionOwnerId
|
||||
);
|
||||
|
||||
return interaction.update({
|
||||
embeds: [embed],
|
||||
components:
|
||||
buildProfileButtons(
|
||||
"stats",
|
||||
0,
|
||||
1
|
||||
)
|
||||
components: buildProfileButtons()
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user