snapshot rollout phase 1
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const {
|
||||
SlashCommandBuilder,
|
||||
PermissionFlagsBits,
|
||||
MessageFlags,
|
||||
EmbedBuilder
|
||||
} = require("discord.js");
|
||||
@@ -13,6 +12,13 @@ const {
|
||||
"../../utils/profileMaintenance"
|
||||
);
|
||||
|
||||
const {
|
||||
requireAdminAccess
|
||||
} = require(
|
||||
"../../utils/permissions"
|
||||
);
|
||||
|
||||
|
||||
module.exports = {
|
||||
data:
|
||||
new SlashCommandBuilder()
|
||||
@@ -22,9 +28,6 @@ module.exports = {
|
||||
.setDescription(
|
||||
"Administrative profile maintenance tools"
|
||||
)
|
||||
.setDefaultMemberPermissions(
|
||||
PermissionFlagsBits.Administrator
|
||||
)
|
||||
.addSubcommand(
|
||||
subcommand =>
|
||||
subcommand
|
||||
@@ -69,14 +72,32 @@ module.exports = {
|
||||
async execute(
|
||||
interaction
|
||||
) {
|
||||
/*
|
||||
* Allows:
|
||||
*
|
||||
* - Discord Administrators
|
||||
* - BOT_AUTHOR_ID from .env
|
||||
*/
|
||||
|
||||
if (
|
||||
!await requireAdminAccess(
|
||||
interaction
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const subcommand =
|
||||
interaction.options.getSubcommand();
|
||||
|
||||
|
||||
await interaction.deferReply({
|
||||
flags:
|
||||
MessageFlags.Ephemeral
|
||||
});
|
||||
|
||||
|
||||
if (
|
||||
subcommand ===
|
||||
"reconcile"
|
||||
@@ -86,21 +107,26 @@ module.exports = {
|
||||
"user"
|
||||
);
|
||||
|
||||
|
||||
const dryRun =
|
||||
interaction.options.getBoolean(
|
||||
"dry-run"
|
||||
) ?? false;
|
||||
|
||||
|
||||
if (user) {
|
||||
const result =
|
||||
await reconcileUserAchievements({
|
||||
guildId:
|
||||
interaction.guildId,
|
||||
|
||||
userId:
|
||||
user.id,
|
||||
|
||||
dryRun
|
||||
});
|
||||
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -114,24 +140,30 @@ module.exports = {
|
||||
{
|
||||
name:
|
||||
"New unlocks",
|
||||
|
||||
value:
|
||||
`**${result.unlocked}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Definitions checked",
|
||||
|
||||
value:
|
||||
`**${result.checked}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Event-only skipped",
|
||||
|
||||
value:
|
||||
`**${result.skippedEventOnly}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
}
|
||||
@@ -140,13 +172,16 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const summary =
|
||||
await reconcileAllAchievements({
|
||||
guildId:
|
||||
interaction.guildId,
|
||||
|
||||
dryRun
|
||||
});
|
||||
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
@@ -160,24 +195,30 @@ module.exports = {
|
||||
{
|
||||
name:
|
||||
"Users",
|
||||
|
||||
value:
|
||||
`**${summary.users}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"New unlocks",
|
||||
|
||||
value:
|
||||
`**${summary.unlocked}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Event-only checks skipped",
|
||||
|
||||
value:
|
||||
`**${summary.skippedEventOnly}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
}
|
||||
@@ -186,15 +227,23 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const audit =
|
||||
await auditProfileData(
|
||||
interaction.guildId
|
||||
);
|
||||
|
||||
|
||||
const issuePreview =
|
||||
audit.issues
|
||||
.slice(0, 10)
|
||||
.join("\n");
|
||||
.slice(
|
||||
0,
|
||||
10
|
||||
)
|
||||
.join(
|
||||
"\n"
|
||||
);
|
||||
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
@@ -206,48 +255,60 @@ module.exports = {
|
||||
{
|
||||
name:
|
||||
"Stats documents",
|
||||
|
||||
value:
|
||||
`**${audit.statDocuments}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Achievement documents",
|
||||
|
||||
value:
|
||||
`**${audit.achievementDocuments}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Active achievements",
|
||||
|
||||
value:
|
||||
`**${audit.activeAchievements}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Global badges",
|
||||
|
||||
value:
|
||||
`**${audit.badgeDocuments}** (${audit.claimedBadges} claimed)`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Orphan achievement docs",
|
||||
|
||||
value:
|
||||
`**${audit.orphanAchievementDocs}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
},
|
||||
{
|
||||
name:
|
||||
"Issues",
|
||||
|
||||
value:
|
||||
`**${audit.issueCount}**`,
|
||||
|
||||
inline:
|
||||
true
|
||||
}
|
||||
@@ -260,4 +321,4 @@ module.exports = {
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user