Merge pull request #2 from nkrystik/report-interaction
Report Message interaction for server members.
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
import { ButtonInteraction, Client, MessageFlags, MessageMentions } from 'discord.js';
|
||||||
|
import { createPrivateHelpTicketThread } from '../utils';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'open-ticket-for-reported-message',
|
||||||
|
handler: async function (client: Client, interaction: ButtonInteraction) {
|
||||||
|
const message = await interaction.message.fetch();
|
||||||
|
const guild = await interaction.guild!.fetch();
|
||||||
|
|
||||||
|
const reportEmbed = message.embeds[0]!;
|
||||||
|
|
||||||
|
const regex = new RegExp(MessageMentions.UsersPattern);
|
||||||
|
|
||||||
|
const reportedMessageUrl = reportEmbed.fields[0].value;
|
||||||
|
const reporterId = regex.exec(reportEmbed.fields[2].value)!.groups!.id;
|
||||||
|
const additionalInfo = reportEmbed.fields[3]?.name == 'Additional Information' ? reportEmbed.fields[3].value : '';
|
||||||
|
|
||||||
|
const reporter = await guild.members.fetch(reporterId) ?? await client.users.fetch(reporterId);
|
||||||
|
|
||||||
|
const thread = await createPrivateHelpTicketThread(client, guild, null, `Ticket creted by staff in response to message report: ${message.url}. Reported message: ${reportedMessageUrl}. ${additionalInfo ? `\n\nAdditional information provided in report:\n${additionalInfo.split('\n').map(c => `> ${c}`).join('\n')}` : ''}`, `Mod Ticket For Message Report From ${reporter.displayName}`, [reporterId, interaction.user.id]);
|
||||||
|
|
||||||
|
if (thread) {
|
||||||
|
await interaction.reply({
|
||||||
|
flags: [MessageFlags.Ephemeral],
|
||||||
|
content: `Ticket created: ${thread}`
|
||||||
|
});
|
||||||
|
|
||||||
|
const requestIndex = reportEmbed.fields.findIndex(f => f.name == 'User Requested Private Ticket');
|
||||||
|
if (requestIndex != -1) reportEmbed.fields.splice(requestIndex, 1);
|
||||||
|
|
||||||
|
reportEmbed.fields.push({
|
||||||
|
name: 'Private Help Ticket',
|
||||||
|
value: thread.url,
|
||||||
|
inline: false
|
||||||
|
});
|
||||||
|
|
||||||
|
await message.edit({ embeds: [reportEmbed], components: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ActionRowBuilder, ApplicationIntegrationType, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, Client, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
import { ActionRowBuilder, ApplicationIntegrationType, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, Client, InteractionContextType, MessageFlags, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { Database } from '../shared/Database';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'private-help',
|
name: 'private-help',
|
||||||
@@ -37,6 +38,8 @@ export default {
|
|||||||
|
|
||||||
await interaction.channel.send({ components: [row], content });
|
await interaction.channel.send({ components: [row], content });
|
||||||
|
|
||||||
|
await Database.setPrivateHelpChannel(interaction.guildId!, interaction.channelId);
|
||||||
|
|
||||||
interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Sent.' });
|
interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Sent.' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import { ApplicationCommandType, ApplicationIntegrationType, Client, ContextMenuCommandBuilder, InteractionContextType, LabelBuilder, MessageContextMenuCommandInteraction, MessageFlags, ModalBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
|
||||||
|
|
||||||
|
import { Database } from '../shared/Database';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Report Message',
|
||||||
|
|
||||||
|
data: new ContextMenuCommandBuilder()
|
||||||
|
.setName('Report Message')
|
||||||
|
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
|
||||||
|
.setContexts(InteractionContextType.Guild)
|
||||||
|
.setType(ApplicationCommandType.Message),
|
||||||
|
|
||||||
|
handler: async function (client: Client, interaction: MessageContextMenuCommandInteraction) {
|
||||||
|
try {
|
||||||
|
const modal = new ModalBuilder()
|
||||||
|
.setCustomId(`report-message_${interaction.targetMessage.channelId}_${interaction.targetMessage.id}`)
|
||||||
|
.setTitle(`Report message from ${interaction.targetMessage.member?.displayName ?? interaction.targetMessage.author.displayName}`);
|
||||||
|
|
||||||
|
const additionalInfoInput = new TextInputBuilder()
|
||||||
|
.setCustomId('additional-info')
|
||||||
|
.setMaxLength(1000)
|
||||||
|
.setStyle(TextInputStyle.Paragraph)
|
||||||
|
.setRequired(false);
|
||||||
|
|
||||||
|
const additionalInfoLabel = new LabelBuilder()
|
||||||
|
.setLabel('Additional Information')
|
||||||
|
.setDescription('Any additional information? This will help staff understand your report. 1000 characters maximum.')
|
||||||
|
.setTextInputComponent(additionalInfoInput);
|
||||||
|
|
||||||
|
const yesNoMenu = new StringSelectMenuBuilder()
|
||||||
|
.setCustomId('create-private-help-ticket')
|
||||||
|
.setRequired(false)
|
||||||
|
.addOptions(
|
||||||
|
new StringSelectMenuOptionBuilder()
|
||||||
|
.setLabel('No')
|
||||||
|
.setDefault(true)
|
||||||
|
.setValue('no'),
|
||||||
|
new StringSelectMenuOptionBuilder()
|
||||||
|
.setLabel('Yes')
|
||||||
|
.setDefault(false)
|
||||||
|
.setValue('yes')
|
||||||
|
);
|
||||||
|
|
||||||
|
const createPrivateTicket = new LabelBuilder()
|
||||||
|
.setLabel('Create Private Help Ticket')
|
||||||
|
.setDescription('Should a private help ticket be opened with this report? (Does not bypass ticket restrictions)')
|
||||||
|
.setStringSelectMenuComponent(yesNoMenu);
|
||||||
|
|
||||||
|
modal.addLabelComponents(additionalInfoLabel, createPrivateTicket);
|
||||||
|
|
||||||
|
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' });
|
||||||
|
|
||||||
|
await interaction.showModal(modal);
|
||||||
|
|
||||||
|
// await reportsChannel.send({
|
||||||
|
// embeds: [{
|
||||||
|
// title: 'New Message Report!',
|
||||||
|
// fields: [
|
||||||
|
// {
|
||||||
|
// name: 'Message',
|
||||||
|
// value: interaction.targetMessage.url,
|
||||||
|
// inline: false
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'Author',
|
||||||
|
// value: interaction.targetMessage.author.toString(),
|
||||||
|
// inline: false
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'Reporter',
|
||||||
|
// value: interaction.user.toString(),
|
||||||
|
// inline: false
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }]
|
||||||
|
// });
|
||||||
|
|
||||||
|
// await interaction.reply({
|
||||||
|
// embeds: [{
|
||||||
|
// color: 0x014995,
|
||||||
|
// description:
|
||||||
|
// "Thanks for making a report! I've notified the moderators who can take further action."
|
||||||
|
// }],
|
||||||
|
// flags: [MessageFlags.Ephemeral]
|
||||||
|
// });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
if (!interaction.replied) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Hmm, an error occurred while processing your request. If you receive this error more than once, DM a moderator for further assistance.',
|
||||||
|
flags: [MessageFlags.Ephemeral]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -121,7 +121,7 @@ client.on('interactionCreate', async (interaction) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('ready', async () => {
|
client.on('clientReady', async () => {
|
||||||
console.log(`Logged in as ${client.user!.tag}!`);
|
console.log(`Logged in as ${client.user!.tag}!`);
|
||||||
|
|
||||||
await refreshCommands(client);
|
await refreshCommands(client);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, MessageFlags, ModalSubmitInteraction, TextChannel, ThreadAutoArchiveDuration } from 'discord.js';
|
import { Client, MessageFlags, ModalSubmitInteraction } from 'discord.js';
|
||||||
import { Database } from '../shared/Database';
|
import { Database } from '../shared/Database';
|
||||||
|
import { createPrivateHelpTicketThread } from '../utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'open-ticket-modal',
|
name: 'open-ticket-modal',
|
||||||
@@ -14,38 +15,9 @@ export default {
|
|||||||
|
|
||||||
const reason = interaction.fields.getTextInputValue('ticket-message');
|
const reason = interaction.fields.getTextInputValue('ticket-message');
|
||||||
|
|
||||||
const channel = (await interaction.channel?.fetch()) as TextChannel;
|
const thread = await createPrivateHelpTicketThread(client, guild, member, reason);
|
||||||
|
|
||||||
const thread = await channel.threads.create({
|
if (thread) interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Your ticket has been created: ${thread}` });
|
||||||
name: `${member.displayName}'s Ticket`,
|
else interaction.reply({ flags: [MessageFlags.Ephemeral], content: 'Failed to create ticket. Please report this to a staff member.' });
|
||||||
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
|
|
||||||
invitable: false,
|
|
||||||
type: ChannelType.PrivateThread
|
|
||||||
});
|
|
||||||
|
|
||||||
await Database.createPrivateHelpTicket(interaction.user.id, thread.id);
|
|
||||||
|
|
||||||
const closeButton = new ButtonBuilder()
|
|
||||||
.setCustomId('close-ticket')
|
|
||||||
.setLabel('Click here if you no longer need help')
|
|
||||||
.setStyle(ButtonStyle.Danger);
|
|
||||||
|
|
||||||
const claimButton = new ButtonBuilder()
|
|
||||||
.setCustomId('claim-ticket')
|
|
||||||
.setLabel('Claim ticket')
|
|
||||||
.setStyle(ButtonStyle.Primary);
|
|
||||||
|
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(closeButton, claimButton);
|
|
||||||
|
|
||||||
await thread.send({
|
|
||||||
content: `${interaction.user} feel free to direct your questions at any <@&${guildSettings.private_help_role_id}>. Only you and staff members can see this channel.\n\n**Reason for contact:**\n${reason}\n\n-# Tickets will automatically close after 5 days of inactivity.`,
|
|
||||||
components: [row],
|
|
||||||
allowedMentions: {
|
|
||||||
users: [interaction.user.id],
|
|
||||||
roles: [guildSettings.private_help_role_id]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
interaction.reply({ flags: [MessageFlags.Ephemeral], content: `Your ticket has been created: ${thread}` });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +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);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -29,7 +29,8 @@ const DB_SCHEMA = `
|
|||||||
safe_channels TEXT,
|
safe_channels TEXT,
|
||||||
link_skip_channels TEXT,
|
link_skip_channels TEXT,
|
||||||
github_release_channel TEXT,
|
github_release_channel TEXT,
|
||||||
moderator_channel_id TEXT
|
moderator_channel_id TEXT,
|
||||||
|
private_help_channel_id TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS messages (
|
CREATE TABLE IF NOT EXISTS messages (
|
||||||
@@ -231,6 +232,10 @@ export class Database {
|
|||||||
await Database.db.run('UPDATE settings SET github_release_channel = ? WHERE guild_id = ?', id, guildId);
|
await Database.db.run('UPDATE settings SET github_release_channel = ? WHERE guild_id = ?', id, guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async setPrivateHelpChannel(guildId: string, id: string) {
|
||||||
|
await Database.db.run('UPDATE settings SET private_help_channel_id = ? WHERE guild_id = ?', id, guildId);
|
||||||
|
}
|
||||||
|
|
||||||
// Since "setting" has guaranteed values and is never set by the user, this shouldn't cause any security issues.
|
// Since "setting" has guaranteed values and is never set by the user, this shouldn't cause any security issues.
|
||||||
// But it does allow me to skip rewriting this a bunch.
|
// But it does allow me to skip rewriting this a bunch.
|
||||||
static async getGuildArraySetting(setting: GuildArraySetting, guildId: string): Promise<string[]> {
|
static async getGuildArraySetting(setting: GuildArraySetting, guildId: string): Promise<string[]> {
|
||||||
|
|||||||
Vendored
+1
@@ -25,6 +25,7 @@ export type GuildSettings = {
|
|||||||
link_skip_channels?: string
|
link_skip_channels?: string
|
||||||
github_release_channel?: string
|
github_release_channel?: string
|
||||||
moderator_channel_id?: string
|
moderator_channel_id?: string
|
||||||
|
private_help_channel_id?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels';
|
export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Client, ThreadChannel } from 'discord.js';
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, Guild, GuildMember, PrivateThreadChannel, TextChannel, ThreadAutoArchiveDuration, ThreadChannel } from 'discord.js';
|
||||||
import { Database } from '../shared/Database';
|
import { Database } from '../shared/Database';
|
||||||
|
|
||||||
export async function closeOldTickets(client: Client) {
|
export async function closeOldTickets(client: Client) {
|
||||||
@@ -21,4 +21,65 @@ export async function closeOldTickets(client: Client) {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createPrivateHelpTicketThread(client: Client, guild: Guild, creator: GuildMember | null, reason: string, customTitle: string = '', additionalMembersToAdd: string[] = []): Promise<PrivateThreadChannel | null> {
|
||||||
|
const guildSettings = await Database.getGuildSettings(guild.id);
|
||||||
|
|
||||||
|
if (!guildSettings || !guildSettings.private_help_channel_id || !guildSettings.private_help_role_id) return null;
|
||||||
|
|
||||||
|
const channel = await client.channels.fetch(guildSettings.private_help_channel_id) as TextChannel;
|
||||||
|
|
||||||
|
const thread = await channel.threads.create({
|
||||||
|
name: customTitle ? customTitle : (creator ? `${creator.displayName}'s Ticket` : 'Mod Ticket'),
|
||||||
|
autoArchiveDuration: ThreadAutoArchiveDuration.OneWeek,
|
||||||
|
invitable: false,
|
||||||
|
type: ChannelType.PrivateThread
|
||||||
|
}) as PrivateThreadChannel;
|
||||||
|
|
||||||
|
if (creator) await Database.createPrivateHelpTicket(creator.id, thread.id);
|
||||||
|
|
||||||
|
if (creator) {
|
||||||
|
const closeButton = new ButtonBuilder()
|
||||||
|
.setCustomId('close-ticket')
|
||||||
|
.setLabel('Click here if you no longer need help')
|
||||||
|
.setStyle(ButtonStyle.Danger);
|
||||||
|
|
||||||
|
const claimButton = new ButtonBuilder()
|
||||||
|
.setCustomId('claim-ticket')
|
||||||
|
.setLabel('Claim ticket')
|
||||||
|
.setStyle(ButtonStyle.Primary);
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(closeButton, claimButton);
|
||||||
|
|
||||||
|
await thread.send({
|
||||||
|
content: `${creator} feel free to direct your questions at any <@&${guildSettings.private_help_role_id}>. Only you and staff members can see this channel.\n\n**Reason for contact:**\n${reason}\n\n-# Tickets will automatically close after 5 days of inactivity.`,
|
||||||
|
components: [row],
|
||||||
|
allowedMentions: {
|
||||||
|
users: [creator.id],
|
||||||
|
roles: [guildSettings.private_help_role_id]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const closeButton = new ButtonBuilder()
|
||||||
|
.setCustomId('close-mod-ticket')
|
||||||
|
.setLabel('Close Mod Ticket')
|
||||||
|
.setStyle(ButtonStyle.Danger);
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(closeButton);
|
||||||
|
|
||||||
|
await thread.send({
|
||||||
|
content: reason,
|
||||||
|
components: [row],
|
||||||
|
allowedMentions: {
|
||||||
|
users: Array.from(new Set(additionalMembersToAdd))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const id of additionalMembersToAdd) {
|
||||||
|
await thread.members.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return thread;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user