feat: verbose verify command

This commit is contained in:
TresAbhi committed 2023-05-06 22:39:51 +00:00
1 parent ace4a24ba9
commit c0dd0ed82c
1 file changed
+72 -42
+72 -42
View File
@@ -36,56 +36,86 @@ export default {
const clan = clanData[account.account_id].clan; const clan = clanData[account.account_id].clan;
const clanTag = clan === null ? '' : ` [${clan!.tag}]`; const clanTag = clan === null ? '' : ` [${clan!.tag}]`;
if (interaction.member && interaction.guild) { if (
!interaction.guild?.members.me?.permissions.has('ManageNicknames')
) {
interaction.editReply({
embeds: [
new EmbedBuilder()
.setColor(NEGATIVE_COLOR)
.setTitle(
`${markdownEscape(
interaction.user.username,
)} failed to verify`,
)
.setDescription(
"I don't have the permission to change your nickname.",
),
],
});
console.warn(
`${interaction.user.username} failed to verify because of no nickname permission.`,
);
return;
}
if (interaction.member) {
const member = interaction.guild?.members.cache.get( const member = interaction.guild?.members.cache.get(
interaction.member?.user.id, interaction.member?.user.id,
); );
member if (member) {
?.setNickname(`${name}${clanTag}`) await member?.setNickname(`${name}${clanTag}`);
.then(async () => {
if (interaction.guildId === discord.guild_id) { if (interaction.guildId === discord.guild_id) {
await member.roles.remove(discord.verify_role); if (
await member.roles.add(discord.peasant_role); !interaction.guild.members.me.permissions.has('ManageRoles')
) {
await interaction.editReply({
embeds: [
new EmbedBuilder()
.setColor(NEGATIVE_COLOR)
.setTitle(
`${markdownEscape(
interaction.user.username,
)} failed to verify`,
)
.setDescription(
"I don't have the permission to change your manage roles.",
),
],
});
console.warn(
`${interaction.user.username} failed to verify because of no manage roles permission.`,
);
return;
} }
await interaction.editReply({ await member.roles.remove(discord.verify_role);
embeds: [ await member.roles.add(discord.peasant_role);
new EmbedBuilder() }
.setColor(POSITIVE_COLOR)
.setTitle(`${interaction.user.username} is verified`)
.setDescription(
`The user is now verified as ${markdownEscape(
name,
)}${markdownEscape(clanTag)}`,
),
],
});
console.log( await interaction.editReply({
`${interaction.user.username} verified as ${name}${clanTag}`, embeds: [
); new EmbedBuilder()
}) .setColor(POSITIVE_COLOR)
.catch(async () => { .setTitle(`${interaction.user.username} is verified`)
await interaction.editReply({ .setDescription(
embeds: [ `The user is now verified as ${markdownEscape(
new EmbedBuilder() name,
.setColor(NEGATIVE_COLOR) )}${markdownEscape(clanTag)}`,
.setTitle( ),
`${markdownEscape( ],
interaction.user.username,
)} failed to verify`,
)
.setDescription(
'I may not have the permission to change your nickname.',
),
],
});
console.warn(
`${interaction.user.username} failed to verify as ${name}${clanTag}`,
);
}); });
console.log(
`${interaction.user.username} verified as ${name}${clanTag}`,
);
}
} }
}, },
); );