Skip to content

Commit

Permalink
feat(translate): translate Network messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 authored Oct 2, 2023
1 parent eef50d2 commit 03a349a
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 168 deletions.
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@prisma/client": "^5.3.1",
"@sentry/node": "^7.72.0",
"@top-gg/sdk": "^3.1.6",
"@translate-tools/core": "^1.0.0",
"common-tags": "^1.8.2",
"discord-arts": "^0.4.0",
"discord.js": "^14.13.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Apps/editMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {

if (!await topgg.hasVoted(interaction.user.id) && !checkIfStaff(interaction.user.id)) {
await interaction.reply({
content: `${emojis.normal.no} You must [vote](<https://top.gg/bot/${interaction.client.user.id}/vote>) to use this command.`,
content: `${emojis.normal.no} You must [vote](<https://top.gg/bot/769921109209907241/vote>) to use this command.`,
ephemeral: true,
});
return;
Expand Down
150 changes: 147 additions & 3 deletions src/Commands/Apps/messageInfo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ActionRowBuilder, ApplicationCommandType, AttachmentBuilder, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, EmbedBuilder, MessageContextMenuCommandInteraction } from 'discord.js';
import { ActionRowBuilder, ApplicationCommandType, AttachmentBuilder, ButtonBuilder, ButtonStyle, ComponentType, ContextMenuCommandBuilder, EmbedBuilder, GuildTextBasedChannel, MessageContextMenuCommandInteraction, ModalBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
import { constants, getDb } from '../../Utils/utils';
import { stripIndents } from 'common-tags';
import { profileImage } from 'discord-arts';
import emojis from '../../Utils/JSON/emoji.json';
import { captureException } from '@sentry/node';
import logger from '../../Utils/logger';

export default {
description: 'Get information about this message, user and server it was sent from!',
Expand Down Expand Up @@ -66,9 +68,16 @@ export default {
.setStyle(ButtonStyle.Secondary),
);

const reportButton = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId('report')
.setLabel('Report')
.setStyle(ButtonStyle.Danger),
);

const replyMsg = await interaction.reply({
embeds: [embed],
components: [buttons],
components: [buttons, reportButton],
ephemeral: true,
});

Expand Down Expand Up @@ -163,15 +172,150 @@ export default {
// generate the profile card
if (!customCard) customCard = new AttachmentBuilder(await profileImage(author.id), { name: 'customCard.png' });

await interaction.editReply({
await i.editReply({
embeds: [userEmbed],
files: [customCard],
components: [newButtons],
});
}


else if (i.customId === 'messageInfo') {
await i.update({ embeds: [embed], components: [buttons], files: [] });
}


else if (i.customId === 'report') {
if (networkMessage.authorId === i.user.id) {
i.reply({ content: 'You cannot report yourself!', ephemeral: true });
return;
}

const reportsChannel = await i.client.channels.fetch(constants.channel.reports) as GuildTextBasedChannel;
const reportedUser = await i.client.users.fetch(networkMessage.authorId);

// network channelId in chatbot hq
const cbhqJumpMsg = networkMessage.channelAndMessageIds.find((x) => x.channelId === '821607665687330816');

const confirmEmbed = new EmbedBuilder()
.setTitle('Report Type')
.setDescription('Thank you for submitting a report. In order for our staff team to investigate, please specify the reason for your report. If you are reporting a server or bug, please use the /support report command instead.')
.setFooter({ text: 'Submitting false reports will result in a warning.' })
.setColor(constants.colors.interchatBlue);

const typeSelect = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
new StringSelectMenuBuilder()
.setCustomId('type')
.setPlaceholder('Choose a report type.')
.setMaxValues(2)
.addOptions([
new StringSelectMenuOptionBuilder()
.setLabel('Harassment')
.setDescription('Verbal or written abuse or threats.')
.setValue('Harassment'),
new StringSelectMenuOptionBuilder()
.setLabel('Bullying')
.setDescription('Repeated aggressive behavior that is intended to harm, intimidate, or control another person.')
.setValue('Bullying'),
new StringSelectMenuOptionBuilder()
.setLabel('Toxicity')
.setDescription('Hate speech, discrimination, or offensive language.')
.setValue('Toxicity'),
new StringSelectMenuOptionBuilder()
.setLabel('Spamming')
.setDescription('Repeated unwanted messages or links in chat.')
.setValue('Spamming'),
new StringSelectMenuOptionBuilder()
.setLabel('Scamming')
.setDescription('Fraud or deceitful behavior.')
.setValue('Scamming'),
new StringSelectMenuOptionBuilder()
.setLabel('Impersonation')
.setDescription('Pretending to be someone else.')
.setValue('Impersonation'),
new StringSelectMenuOptionBuilder()
.setLabel('NSFW Content')
.setDescription('Inappropriate or offensive content.')
.setValue('NSFW'),
]),
);

const message = await i.reply({
embeds: [confirmEmbed],
components: [typeSelect],
ephemeral: true,
});

const selectCollector = message.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
idle: 60_000,
});

selectCollector.on('collect', async (selInterac) => {
const selections = selInterac.values;

const modal = new ModalBuilder()
.setCustomId(i.id)
.setTitle('Report')
.addComponents(
new ActionRowBuilder<TextInputBuilder>().addComponents(
new TextInputBuilder()
.setRequired(false)
.setCustomId('reason')
.setStyle(TextInputStyle.Paragraph)
.setLabel('Additional Details (OPTIONAL)')
.setMaxLength(2000),
),
);

await selInterac.showModal(modal);

selInterac.awaitModalSubmit({ time: 60_000 * 5 })
.then(async (modalSubmit) => {
const reason = modalSubmit.fields.getTextInputValue('reason');

const reportEmbed = new EmbedBuilder()
.setTitle('User Reported')
.setDescription(`A new user report for \`@${reportedUser.username}\` (${reportedUser.id}) was submitted.\n\n**Reported For:** ${selections.join(', ')}`)
.setColor(constants.colors.interchatBlue)
.setTimestamp()
.setFooter({
text: `Reported By: ${modalSubmit.user.username} | ${modalSubmit.user.id}.`,
iconURL: modalSubmit.user.avatarURL() || modalSubmit.user.defaultAvatarURL,
});

if (reason) reportEmbed.addFields({ name: 'Additional Details', value: reason });

const jumpButton = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setLabel('Jump')
.setURL(`https://discord.com/channels/${constants.guilds.cbhq}/${cbhqJumpMsg?.channelId}/${cbhqJumpMsg?.messageId}`)
.setStyle(ButtonStyle.Link),
);

await reportsChannel?.send({
embeds: [reportEmbed],
components: [jumpButton],
});
modalSubmit.reply({
content: `${emojis.normal.yes} Your report has been successfully submitted! Join the support server to check the status of your report.`,
ephemeral: true,
});
})
.catch((e) => {
if (!e.message.includes('with reason: time')) {
logger.error(e);
captureException(e);

i.followUp({
content: `${emojis.normal.no} An error occored while making the report.`,
ephemeral: true,
});
}
return null;
});
});
}
});
},
};
Loading

0 comments on commit 03a349a

Please sign in to comment.