Fix line endings
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { deferInteraction, logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'add-knowledgebase-item-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction) {
|
||||
if (!interaction.guild) return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Must be ran in guild.' });
|
||||
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const name = interaction.fields.getTextInputValue('name');
|
||||
const content = interaction.fields.getTextInputValue('content');
|
||||
|
||||
if (content.length > 2000) return interaction.editReply('Content cannot be over 2000 characters long.');
|
||||
|
||||
const existingItem = await Database.getFromKnowledgebaseByName(interaction.guild.id, name);
|
||||
|
||||
if (existingItem) return interaction.editReply(`Knowledgebase item ${name} already exists!`);
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Knowledgebase Item Added',
|
||||
description: null,
|
||||
color: 0x00FF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
value: name,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Content',
|
||||
value: content,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.addToKnowledgebase(interaction.guild.id, name, content);
|
||||
|
||||
return interaction.editReply(`Entry \`${name}\` added to knowledgebase.`);
|
||||
}
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { deferInteraction, logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'add-knowledgebase-item-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction) {
|
||||
if (!interaction.guild) return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Must be ran in guild.' });
|
||||
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const name = interaction.fields.getTextInputValue('name');
|
||||
const content = interaction.fields.getTextInputValue('content');
|
||||
|
||||
if (content.length > 2000) return interaction.editReply('Content cannot be over 2000 characters long.');
|
||||
|
||||
const existingItem = await Database.getFromKnowledgebaseByName(interaction.guild.id, name);
|
||||
|
||||
if (existingItem) return interaction.editReply(`Knowledgebase item ${name} already exists!`);
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Knowledgebase Item Added',
|
||||
description: null,
|
||||
color: 0x00FF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
value: name,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Content',
|
||||
value: content,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.addToKnowledgebase(interaction.guild.id, name, content);
|
||||
|
||||
return interaction.editReply(`Entry \`${name}\` added to knowledgebase.`);
|
||||
}
|
||||
};
|
||||
@@ -1,40 +1,40 @@
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'add-note-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, id: string) {
|
||||
const message = interaction.fields.getTextInputValue('note-message');
|
||||
|
||||
const user = await client.users.fetch(id);
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Note Added',
|
||||
description: null,
|
||||
color: 0x00FF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'Moderator',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${id}>\n${user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Note',
|
||||
value: message,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.putNote(id, message, interaction.user.id);
|
||||
|
||||
interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Note added' });
|
||||
}
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'add-note-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, id: string) {
|
||||
const message = interaction.fields.getTextInputValue('note-message');
|
||||
|
||||
const user = await client.users.fetch(id);
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Note Added',
|
||||
description: null,
|
||||
color: 0x00FF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'Moderator',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${id}>\n${user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Note',
|
||||
value: message,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.putNote(id, message, interaction.user.id);
|
||||
|
||||
interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Note added' });
|
||||
}
|
||||
};
|
||||
@@ -1,54 +1,54 @@
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { deferInteraction, logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'edit-knowledgebase-item-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, idString: string) {
|
||||
if (!interaction.guild) return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Must be ran in guild.' });
|
||||
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const id = parseInt(idString);
|
||||
const content = interaction.fields.getTextInputValue('content');
|
||||
|
||||
const existingItem = await Database.getFromKnowledgebase(id);
|
||||
|
||||
if (!existingItem) return interaction.editReply('Knowledgebase item not found.');
|
||||
|
||||
if (content.length > 2000) return interaction.editReply('Content cannot be over 2000 characters long.');
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Knowledgebase Item Edited',
|
||||
description: null,
|
||||
color: 0xFFFF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
value: existingItem.name,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Old Content',
|
||||
value: existingItem.content,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'New Content',
|
||||
value: content,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.editKnowledgebaseItem(id, content);
|
||||
|
||||
return interaction.editReply(`Edited knowledgebase entry \`${existingItem.name}\`.`);
|
||||
}
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { deferInteraction, logCustomEvent } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'edit-knowledgebase-item-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, idString: string) {
|
||||
if (!interaction.guild) return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Must be ran in guild.' });
|
||||
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const id = parseInt(idString);
|
||||
const content = interaction.fields.getTextInputValue('content');
|
||||
|
||||
const existingItem = await Database.getFromKnowledgebase(id);
|
||||
|
||||
if (!existingItem) return interaction.editReply('Knowledgebase item not found.');
|
||||
|
||||
if (content.length > 2000) return interaction.editReply('Content cannot be over 2000 characters long.');
|
||||
|
||||
logCustomEvent(interaction.guild!, {
|
||||
title: 'Knowledgebase Item Edited',
|
||||
description: null,
|
||||
color: 0xFFFF00,
|
||||
timestamp: new Date(),
|
||||
fields: [
|
||||
{
|
||||
name: 'User',
|
||||
value: `<@${interaction.user.id}>\n${interaction.user.username}`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
value: existingItem.name,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Old Content',
|
||||
value: existingItem.content,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'New Content',
|
||||
value: content,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await Database.editKnowledgebaseItem(id, content);
|
||||
|
||||
return interaction.editReply(`Edited knowledgebase entry \`${existingItem.name}\`.`);
|
||||
}
|
||||
};
|
||||
@@ -1,31 +1,31 @@
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
const warning = '\n\n\nLeaving this thread without acknowledgement may result in punishment. Staff will close the thread when they deem your response acceptable.';
|
||||
|
||||
export default {
|
||||
name: 'open-mod-ticket',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, userId: string) {
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(userId);
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(guild.id);
|
||||
|
||||
if (!guildSettings || !guildSettings.private_help_channel_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a developer.' });
|
||||
|
||||
const title = interaction.fields.getTextInputValue('title') ? interaction.fields.getTextInputValue('title') : `Mod Ticket For ${member.displayName}`;
|
||||
const reason = interaction.fields.getTextInputValue('initial-message') + warning;
|
||||
const autoJoin = interaction.fields.getStringSelectValues('auto-join-thread')[0] == 'yes';
|
||||
|
||||
const membersToAdd = [userId];
|
||||
|
||||
if (autoJoin) membersToAdd.push(interaction.user.id);
|
||||
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, null, reason, title, membersToAdd);
|
||||
|
||||
if (thread) interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Mod ticket created: ${thread}.${!autoJoin ? "You've selected not to auto join the thread. You will not be notified of messages sent there. You will have to check the thread periodically for user response." : ''}` });
|
||||
else interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a developer.' });
|
||||
}
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
const warning = '\n\n\nLeaving this thread without acknowledgement may result in punishment. Staff will close the thread when they deem your response acceptable.';
|
||||
|
||||
export default {
|
||||
name: 'open-mod-ticket',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, userId: string) {
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(userId);
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(guild.id);
|
||||
|
||||
if (!guildSettings || !guildSettings.private_help_channel_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a developer.' });
|
||||
|
||||
const title = interaction.fields.getTextInputValue('title') ? interaction.fields.getTextInputValue('title') : `Mod Ticket For ${member.displayName}`;
|
||||
const reason = interaction.fields.getTextInputValue('initial-message') + warning;
|
||||
const autoJoin = interaction.fields.getStringSelectValues('auto-join-thread')[0] == 'yes';
|
||||
|
||||
const membersToAdd = [userId];
|
||||
|
||||
if (autoJoin) membersToAdd.push(interaction.user.id);
|
||||
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, null, reason, title, membersToAdd);
|
||||
|
||||
if (thread) interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Mod ticket created: ${thread}.${!autoJoin ? "You've selected not to auto join the thread. You will not be notified of messages sent there. You will have to check the thread periodically for user response." : ''}` });
|
||||
else interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a developer.' });
|
||||
}
|
||||
};
|
||||
@@ -1,23 +1,23 @@
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'open-ticket-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction) {
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(interaction.user.id);
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(guild.id);
|
||||
|
||||
if (!guildSettings || !guildSettings.private_help_role_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a staff member.' });
|
||||
|
||||
const reason = interaction.fields.getTextInputValue('ticket-message');
|
||||
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, member, reason);
|
||||
|
||||
if (thread) interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Your ticket has been created: ${thread}` });
|
||||
else interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a staff member.' });
|
||||
}
|
||||
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'open-ticket-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction) {
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(interaction.user.id);
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(guild.id);
|
||||
|
||||
if (!guildSettings || !guildSettings.private_help_role_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a staff member.' });
|
||||
|
||||
const reason = interaction.fields.getTextInputValue('ticket-message');
|
||||
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, member, reason);
|
||||
|
||||
if (thread) interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Your ticket has been created: ${thread}` });
|
||||
else interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a staff member.' });
|
||||
}
|
||||
};
|
||||
+117
-117
@@ -1,118 +1,118 @@
|
||||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder, GuildTextBasedChannel, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { canOpenPrivateHelpTicket, createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'report-message',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, channelId: string, messageId: string) {
|
||||
await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
|
||||
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(interaction.user.id);
|
||||
const reportedMessageChannel = await guild.channels.fetch(channelId) as GuildTextBasedChannel;
|
||||
const reportedMessage = await reportedMessageChannel?.messages.fetch(messageId);
|
||||
|
||||
const additionalInfo = interaction.fields.getTextInputValue('additional-info');
|
||||
const createPrivateHelpTicket = interaction.fields.getStringSelectValues('create-private-help-ticket')[0] == 'yes';
|
||||
|
||||
if (!reportedMessageChannel || !reportedMessage)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to submit report. Please report this to a staff member.' });
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(interaction.guildId!);
|
||||
|
||||
if (!guildSettings || !guildSettings.moderator_channel_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Report channel missing. Unable to submit report.' });
|
||||
|
||||
const reportsChannel = await interaction.guild!.channels.fetch(guildSettings.moderator_channel_id);
|
||||
|
||||
if (!reportsChannel || !reportsChannel.isSendable())
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Report channel missing. Unable to submit report.' });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('New Message Report!')
|
||||
.setColor(0xFF0000)
|
||||
.addFields(
|
||||
{
|
||||
name: 'Message',
|
||||
value: reportedMessage.url,
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
name: 'Message Author',
|
||||
value: reportedMessage.author.toString(),
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
name: 'Reporter',
|
||||
value: member.toString(),
|
||||
inline: false
|
||||
});
|
||||
|
||||
if (additionalInfo) {
|
||||
embed.addFields(
|
||||
{
|
||||
name: 'Additional Information',
|
||||
value: additionalInfo,
|
||||
inline: false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let replyContent = "Thanks for making a report! I've notified the moderators who can take further action.";
|
||||
|
||||
const wantsTicketButCantOpen = createPrivateHelpTicket && !await canOpenPrivateHelpTicket(member.id);
|
||||
|
||||
if (wantsTicketButCantOpen) {
|
||||
embed.addFields(
|
||||
{
|
||||
name: 'User Requested Private Ticket',
|
||||
value: 'The user requested a private ticket be opened, but already has an open ticket. If additional information is needed, press the button below to open a ticket with the user.',
|
||||
inline: false
|
||||
}
|
||||
);
|
||||
|
||||
replyContent += " Could not open private help ticket since you already have one open. Staff have been notified that you'd like to have a ticket opened, and can make one for you if they deem it necessary.";
|
||||
}
|
||||
|
||||
const openTicketButton = new ButtonBuilder()
|
||||
.setCustomId('open-ticket-for-reported-message')
|
||||
.setLabel('Open Private Ticket')
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(openTicketButton);
|
||||
|
||||
const reportMessage = await reportsChannel.send({
|
||||
embeds: [embed],
|
||||
components: createPrivateHelpTicket && !wantsTicketButCantOpen ? [] : [row]
|
||||
});
|
||||
|
||||
await reportsChannel.send({ files: [new AttachmentBuilder(Buffer.from(reportedMessage.content), { name: 'message-content.txt' })] });
|
||||
|
||||
if (createPrivateHelpTicket && !wantsTicketButCantOpen) {
|
||||
if (!guildSettings.private_help_channel_id) {
|
||||
replyContent += ' Could not open private help ticket. Private help channel not set. Please report this to a staff member.';
|
||||
} else {
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, member, `Ticket created with message report (${reportMessage.url}). ${member}, use this channel to talk with staff privately about the reported message (${reportedMessage.url}). ${additionalInfo ? `\n\nAdditional information provided in report:\n${additionalInfo.split('\n').map(c => `> ${c}`).join('\n')}` : ''}`);
|
||||
if (thread) {
|
||||
replyContent += ` Private help ticket created: ${thread}.`;
|
||||
embed.addFields({
|
||||
name: 'Private Help Ticket',
|
||||
value: thread.url,
|
||||
inline: false
|
||||
});
|
||||
|
||||
await reportMessage.edit({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
replyContent += ' There was an issue opening a private help ticket, please report this to a staff member.';
|
||||
await reportMessage.edit({
|
||||
embeds: [embed],
|
||||
components: [row]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await interaction.editReply(replyContent);
|
||||
}
|
||||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder, GuildTextBasedChannel, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||
import { Database } from '../shared/Database';
|
||||
import { canOpenPrivateHelpTicket, createPrivateHelpTicketThread } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'report-message',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, channelId: string, messageId: string) {
|
||||
await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
|
||||
|
||||
const guild = await client.guilds.fetch(interaction.guildId!);
|
||||
const member = await guild.members.fetch(interaction.user.id);
|
||||
const reportedMessageChannel = await guild.channels.fetch(channelId) as GuildTextBasedChannel;
|
||||
const reportedMessage = await reportedMessageChannel?.messages.fetch(messageId);
|
||||
|
||||
const additionalInfo = interaction.fields.getTextInputValue('additional-info');
|
||||
const createPrivateHelpTicket = interaction.fields.getStringSelectValues('create-private-help-ticket')[0] == 'yes';
|
||||
|
||||
if (!reportedMessageChannel || !reportedMessage)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to submit report. Please report this to a staff member.' });
|
||||
|
||||
const guildSettings = await Database.getGuildSettings(interaction.guildId!);
|
||||
|
||||
if (!guildSettings || !guildSettings.moderator_channel_id)
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Report channel missing. Unable to submit report.' });
|
||||
|
||||
const reportsChannel = await interaction.guild!.channels.fetch(guildSettings.moderator_channel_id);
|
||||
|
||||
if (!reportsChannel || !reportsChannel.isSendable())
|
||||
return interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Report channel missing. Unable to submit report.' });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('New Message Report!')
|
||||
.setColor(0xFF0000)
|
||||
.addFields(
|
||||
{
|
||||
name: 'Message',
|
||||
value: reportedMessage.url,
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
name: 'Message Author',
|
||||
value: reportedMessage.author.toString(),
|
||||
inline: false
|
||||
},
|
||||
{
|
||||
name: 'Reporter',
|
||||
value: member.toString(),
|
||||
inline: false
|
||||
});
|
||||
|
||||
if (additionalInfo) {
|
||||
embed.addFields(
|
||||
{
|
||||
name: 'Additional Information',
|
||||
value: additionalInfo,
|
||||
inline: false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
let replyContent = "Thanks for making a report! I've notified the moderators who can take further action.";
|
||||
|
||||
const wantsTicketButCantOpen = createPrivateHelpTicket && !await canOpenPrivateHelpTicket(member.id);
|
||||
|
||||
if (wantsTicketButCantOpen) {
|
||||
embed.addFields(
|
||||
{
|
||||
name: 'User Requested Private Ticket',
|
||||
value: 'The user requested a private ticket be opened, but already has an open ticket. If additional information is needed, press the button below to open a ticket with the user.',
|
||||
inline: false
|
||||
}
|
||||
);
|
||||
|
||||
replyContent += " Could not open private help ticket since you already have one open. Staff have been notified that you'd like to have a ticket opened, and can make one for you if they deem it necessary.";
|
||||
}
|
||||
|
||||
const openTicketButton = new ButtonBuilder()
|
||||
.setCustomId('open-ticket-for-reported-message')
|
||||
.setLabel('Open Private Ticket')
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(openTicketButton);
|
||||
|
||||
const reportMessage = await reportsChannel.send({
|
||||
embeds: [embed],
|
||||
components: createPrivateHelpTicket && !wantsTicketButCantOpen ? [] : [row]
|
||||
});
|
||||
|
||||
await reportsChannel.send({ files: [new AttachmentBuilder(Buffer.from(reportedMessage.content), { name: 'message-content.txt' })] });
|
||||
|
||||
if (createPrivateHelpTicket && !wantsTicketButCantOpen) {
|
||||
if (!guildSettings.private_help_channel_id) {
|
||||
replyContent += ' Could not open private help ticket. Private help channel not set. Please report this to a staff member.';
|
||||
} else {
|
||||
const thread = await createPrivateHelpTicketThread(client, guild, member, `Ticket created with message report (${reportMessage.url}). ${member}, use this channel to talk with staff privately about the reported message (${reportedMessage.url}). ${additionalInfo ? `\n\nAdditional information provided in report:\n${additionalInfo.split('\n').map(c => `> ${c}`).join('\n')}` : ''}`);
|
||||
if (thread) {
|
||||
replyContent += ` Private help ticket created: ${thread}.`;
|
||||
embed.addFields({
|
||||
name: 'Private Help Ticket',
|
||||
value: thread.url,
|
||||
inline: false
|
||||
});
|
||||
|
||||
await reportMessage.edit({ embeds: [embed] });
|
||||
|
||||
} else {
|
||||
replyContent += ' There was an issue opening a private help ticket, please report this to a staff member.';
|
||||
await reportMessage.edit({
|
||||
embeds: [embed],
|
||||
components: [row]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await interaction.editReply(replyContent);
|
||||
}
|
||||
};
|
||||
@@ -1,34 +1,34 @@
|
||||
import { Client, ModalSubmitInteraction } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { deferInteraction, syncName } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'sync-name-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, id: string) {
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const e621Id = Number(interaction.fields.getTextInputValue('id') ?? 0);
|
||||
|
||||
console.log(e621Id);
|
||||
|
||||
if (isNaN(e621Id)) return await interaction.editReply('Provided id is not a number');
|
||||
|
||||
const member = await interaction.guild?.members.fetch(id);
|
||||
|
||||
if (!member) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
const guild = await interaction.client.guilds.fetch(config.DISCORD_GUILD_ID!);
|
||||
|
||||
if (!guild) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
if (!guild.members.me) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
await syncName(interaction, member, e621Id);
|
||||
}
|
||||
import { Client, ModalSubmitInteraction } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { deferInteraction, syncName } from '../utils';
|
||||
|
||||
export default {
|
||||
name: 'sync-name-modal',
|
||||
handler: async function (client: Client, interaction: ModalSubmitInteraction, id: string) {
|
||||
await deferInteraction(interaction);
|
||||
|
||||
const e621Id = Number(interaction.fields.getTextInputValue('id') ?? 0);
|
||||
|
||||
console.log(e621Id);
|
||||
|
||||
if (isNaN(e621Id)) return await interaction.editReply('Provided id is not a number');
|
||||
|
||||
const member = await interaction.guild?.members.fetch(id);
|
||||
|
||||
if (!member) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
const guild = await interaction.client.guilds.fetch(config.DISCORD_GUILD_ID!);
|
||||
|
||||
if (!guild) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
if (!guild.members.me) {
|
||||
return interaction.editReply('An error has occurred. Please try again later.');
|
||||
}
|
||||
|
||||
await syncName(interaction, member, e621Id);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user