Skip to content

Commit

Permalink
Add new emojis and improve message formatting in user context commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Neodevils committed Jan 22, 2025
1 parent 176cf54 commit 5d53b5c
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 39 deletions.
12 changes: 9 additions & 3 deletions src/commands/contextMenu/messageTranslate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
emoji_danger,
emoji_info,
emoji_translate,
emoji_swap,
emoji_globe,
} from "../../shortcuts/emojis.js";
import { defaultPermissionErrorForBot } from "../../shortcuts/permissionErrors.js";

Expand Down Expand Up @@ -62,7 +64,6 @@ export default {
if (!message.content)
return interaction.editReply({
content: `${emoji_info} This message seems to hold no content—nothing to translate across the threads of time.`,
flags: MessageFlags.Ephemeral,
});

const locale = !["zh-CN", "zh-TW"].includes(interaction.locale)
Expand All @@ -75,12 +76,17 @@ export default {
);

await interaction.editReply({
content: `# ${emoji_translate} Translation\n### Original Message\n${message.content}\n\n### Translated Message (${locale})\n${translated.text}\n\n-# Time sure does wonders, doesn’t it?`,
content: `# ${emoji_translate} Translation\n-# ————————————————————————————\n### ${emoji_globe} Original Message\n${message.content}\n\n### ${emoji_swap} Translated Message (${locale})\n${translated.text}\n\n-# I sent it on below if you need to copy the message.`,
});

return interaction.followUp({
content: `${translated.text}`,
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.log(error);
await interaction.editReply({
content: `${emoji_danger} Oh no! A temporal anomaly occurred while translating. Let’s try again later, shall we?`,
flags: MessageFlags.Ephemeral,
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/contextMenu/userAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {

const embed = new EmbedBuilder()
.setDescription(
`# ${emoji_avatar} Hey there! You're checking out @${user.username}'s profile picture. Pretty cool, right?`
`# ${emoji_avatar} Hey there!\nYou're checking out @${user.username}'s profile picture. Pretty cool, right?`
)
.setImage(avatar)
.setColor(EMBED_COLOR);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/contextMenu/userBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
} else {
const embed = new EmbedBuilder()
.setDescription(
`# ${emoji_banner} Hey there! You're checking out ${resolved.tag}'s banner. Pretty neat, right?`
`# ${emoji_banner} Hey there!\nYou're checking out @${resolved.username}'s banner. Pretty neat, right?`
)
.setImage(imageURI)
.setColor(EMBED_COLOR);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/staffs/createGiveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
bold,
MessageFlags,
userMention,
ApplicationCommandType,
ApplicationIntegrationType,
InteractionContextType,
underline,
} from "discord.js";
import {
timezoneChecking,
Expand Down Expand Up @@ -387,7 +387,7 @@ export default {
giveawayName
)}\nGiveaway's winner ${bold(
"will be shown"
)} The winner will be revealed when the giveaway reaches the ${underline(
)} when the giveaway reaches the ${underline(
"happening"
)} point in the timeline. How exciting, right?
\n-# Here is the invite link: ${inviteLink}`,
Expand Down
119 changes: 89 additions & 30 deletions src/commands/staffs/punishment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
time,
userMention,
MessageFlags,
ApplicationCommandType,
ApplicationIntegrationType,
InteractionContextType,
} from "discord.js";
Expand Down Expand Up @@ -275,7 +274,7 @@ export default {
.setRequired(false)
),
execute: async ({ client, interaction }) => {
await interaction.deferReply({ ephemeral: true });
await interaction.deferReply({ flags: MessageFlags.Ephemeral });

const target = interaction.options.getUser("target");
let reason = interaction.options.getString("reason");
Expand Down Expand Up @@ -353,9 +352,7 @@ export default {
await channel.send({
embeds: [
new EmbedBuilder()
.setTitle({
name: `${emoji_timeout} Timed-out`,
})
.setTitle(`${emoji_timeout} Timed-out`)
.setThumbnail(
target.displayAvatarURL({
format: "png",
Expand Down Expand Up @@ -407,7 +404,28 @@ export default {
});
}

if (duration <= 40320) {
const currentTime = new Date();
if (
guildMember.communicationDisabledUntil &&
guildMember.communicationDisabledUntil > currentTime
) {
await guildMember
.disableCommunicationUntil(
expiryTime,
`${reason} Moderated by ${author.username}.`
)
.catch(console.error);

await interaction.editReply({
content: `## ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
expiryTime,
"R"
)}\n> "${reason}" reason.\n\nNow they have ${checkWarnings(
guild.id,
target.id
)} warnings.`,
});
} else {
if (warnings == 1) {
duration = 60;
} else if (warnings == 2) {
Expand All @@ -424,7 +442,7 @@ export default {
.catch(console.error);

return interaction.editReply({
content: `# ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
content: `## ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
expiryTime,
"R"
)}\n> "${reason}" reason.\n\n-# Now they have **${checkWarnings(
Expand All @@ -433,28 +451,31 @@ export default {
)}** warnings.`,
flags: MessageFlags.Ephemeral,
});
} else {
return interaction.editReply({
content: `${emoji_info} I cannot timeout more than 28 days. Can you?`,
});
}
} else {
if (duration <= 40320) {
if (warnings == 1) {
duration = 60;
} else if (warnings == 2) {
duration = 1440; // 1 day
} else if (warnings >= 3) {
duration = 10080; // 1 week
}

const currentTime = new Date();
if (
guildMember.communicationDisabledUntil &&
guildMember.communicationDisabledUntil > currentTime
) {
await guildMember
.disableCommunicationUntil(
expiryTime,
`${reason} Moderated by ${author.username}.`
)
.catch(console.error);

await interaction.editReply({
content: `## ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
expiryTime,
"R"
)}\n> "${reason}" reason.\n\nNow they have ${checkWarnings(
guild.id,
target.id
)} warnings.\n\n> _${emoji_important} Logs channel has not been settled. Please use </setup logs:1223975368138952826> command._`,
flags: MessageFlags.Ephemeral,
});

try {
await guildMember.send({
content: `## ${emoji_timeout} You have been timeouted.`,
Expand All @@ -476,15 +497,30 @@ export default {
],
});
} catch (error) {
console.error(`Could not send a DM to user:`, error);
console.error(`Could not send a DM to ${target.name}.`);
return interaction.followUp({
content: `Could not send a DM to ${target}.`,
content: `${emoji_info} Could not send a DM to ${target}.`,
flags: MessageFlags.Ephemeral,
});
}
} else {
if (warnings == 1) {
duration = 60;
} else if (warnings == 2) {
duration = 1440; // 1 day
} else if (warnings >= 3) {
duration = 10080; // 1 week
}

return interaction.editReply({
content: ` # ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
await guildMember
.disableCommunicationUntil(
expiryTime,
`${reason} Moderated by ${author.username}.`
)
.catch(console.error);

await interaction.editReply({
content: `## ${emoji_timeout} Time-outed\n> **Target:** ${target}\n> **Duration:** ${time(
expiryTime,
"R"
)}\n> "${reason}" reason.\n\nNow they have ${checkWarnings(
Expand All @@ -493,18 +529,41 @@ export default {
)} warnings.\n\n> _${emoji_important} Logs channel has not been settled. Please use </setup logs:1223975368138952826> command._`,
flags: MessageFlags.Ephemeral,
});
} else {
return interaction.editReply({
content: `${emoji_info} I cannot timeout more than 28 days. Can you?`,
flags: MessageFlags.Ephemeral,
});

try {
await guildMember.send({
content: `## ${emoji_timeout} You have been timeouted.`,
embeds: [
new EmbedBuilder()
.setFields(
{
name: "Duration",
value: `${time(expiryTime, "R")}`,
},
{
name: "Reason",
value: `${reason}`,
inline: true,
}
)
.setThumbnail(guild.iconURL())
.setTimestamp(),
],
});
} catch (error) {
console.error(`Could not send a DM to ${target.name}.`);
return interaction.followUp({
content: `${emoji_info} Could not send a DM to ${target}.`,
flags: MessageFlags.Ephemeral,
});
}
}
}
} catch (err) {
console.log(err);

return interaction.editReply({
content: `${emoji_danger} Something went wrong, please contact with Developer.`,
content: `${emoji_danger} Are we sure they are not timeouted already?\n-# If you think something is not right, please contact with **@neodevils**.`,
flags: MessageFlags.Ephemeral,
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/commands/staffs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,8 @@ export default {
await interaction.deferReply({ flags: MessageFlags.Ephemeral });

const logginChannel = interaction.options.getChannel("channel");
const logEvent = interaction.options.getString("event");

setupLoggingChannel(guild.id, logginChannel.id, logEvent.name);
setupLoggingChannel(guild.id, logginChannel.id);

await logginChannel.send({
content: `${emoji_info} Successfully setup the loggin channel.`,
Expand Down
2 changes: 2 additions & 0 deletions src/shortcuts/emojis.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export const emoji_timeout = "<:timeout:1331654473008939070>";
export const emoji_up = "<:up:1331654045869539359>";
export const emoji_safety = "<:safety:1331654372744233040>";
export const emoji_doorEnter = "<:door_enter:1331678912866156595>";
export const emoji_swap = "<:swap:1331704952833179780>";
export const emoji_globe = "<:globe:1331705467839320074>";

0 comments on commit 5d53b5c

Please sign in to comment.