Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ticketing): option to change visibility of thread ticket #348

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/commands/ticketing/ticket-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ const command: Command = {
subcommand
.setName('text-channel-ping')
.setDescription('Toggle to ping the managers when a ticket is created in a text channel')
)
.addSubcommand((subcommand) =>
subcommand
.setName('private-threads')
.setDescription('Toggle between using public and private threads')
),
execute: async function ({ interaction }) {
try {
Expand Down Expand Up @@ -343,6 +348,30 @@ const command: Command = {

return interaction.reply({ embeds: [embed] });
}
case 'private-threads': {
if (!record) {
return interaction.reply({
content: 'You need to create the managers first before editing this config',
ephemeral: true
});
}

await conn.execute('UPDATE TicketingManagers SET PrivateThreads = ? WHERE GuildID = ?', [
!record.PrivateThreads,
interaction.guildId
]);

embed.setTitle('Changed Visibility for Ticket Threads');
embed.setDescription(
`${userMention(
interaction.user.id
)} changed the visibility of ticket threads to ${inlineCode(
!record.PrivateThreads ? 'private' : 'public'
)}`
);

return interaction.reply({ embeds: [embed] });
}
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/other/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE TABLE IF NOT EXISTS TicketingManagers (
SupportCategory bigint(20) DEFAULT 0,
UseTextChannels boolean DEFAULT 0,
TextChannelPing boolean DEFAULT 0,
PrivateThreads boolean DEFAULT 0,
PRIMARY KEY (ID)
)
`;
Expand Down
1 change: 1 addition & 0 deletions src/types/Tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TicketingManagers {
SupportCategory: Snowflake;
UseTextChannels: boolean;
TextChannelPing: boolean;
PrivateThreads: boolean;
}

export interface GuildMemberEvent {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/handleTicketCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const handleTicketCreation = async (
const thread = await channel.threads.create({
name,
autoArchiveDuration: 'MAX',
type: 'GUILD_PRIVATE_THREAD',
type: record.PrivateThreads ? 'GUILD_PRIVATE_THREAD' : 'GUILD_PUBLIC_THREAD',
invitable: false
});

Expand Down