@@ -68,12 +68,24 @@ export async function ticketHelper(
6868
6969 // Validate Ticket
7070 if ( data . TicketPermissions . length <= 0 ) {
71- const isOneTicketMod = data . TicketPermissions . some ( ( p ) => p . IsHandler == true )
72- if ( ! isOneTicketMod ) {
71+ if ( ticketType == "event" ) {
72+ ( messageEvent . channel as TextChannel ) . send ( {
73+ content : `-# ${ await convertToEmojiPng ( "ticket" , client . user . id ) } I can't create a Ticket without Moderators `
74+ } ) . then ( async ( m ) => {
75+ setTimeout ( async ( ) => {
76+ await m . delete ( )
77+ } , 5000 )
78+ } )
79+ return ;
80+ } else if ( ticketType == "interaction" ) {
81+ await interaction . editReply ( {
82+ content : `-# ${ await convertToEmojiPng ( "ticket" , client . user . id ) } I can't create a Ticket without Moderators `
83+ } )
7384 return ;
7485 }
7586 }
7687
88+
7789 // EnableTicketsOnlyFromTime
7890 if ( data . EnableTicketsOnlyFromTime ) {
7991
@@ -272,8 +284,16 @@ export async function ticketHelper(
272284 return
273285 }
274286
275- // Channel Permissions
276- if ( ( IsChannel || IsThread ) && data . TicketPermissions ) {
287+ // Pre Permissions
288+ if ( IsChannel ) await ( channel as TextChannel ) . permissionOverwrites . create ( user . id , {
289+ ViewChannel : true ,
290+ SendMessages : true
291+ } ) ;
292+ if ( IsThread ) await ( channel as ThreadChannel ) . members . add ( user . id )
293+
294+ // Ticket Permissions
295+ if ( data . TicketPermissions ) {
296+ // Channel Perms
277297 if ( IsChannel ) {
278298 for ( const perms of data . TicketPermissions ) {
279299 const permissions : Record < string , boolean > = { } ;
@@ -301,23 +321,29 @@ export async function ticketHelper(
301321 ViewChannel : false ,
302322 } ) ;
303323 }
304-
324+ // Thread Perms
325+ if ( IsThread ) {
326+ for ( const perms of data . TicketPermissions ) {
327+ if ( perms . DiscordRoleId ) {
328+ channel . send ( {
329+ content : `<@&${ perms . DiscordRoleId } >`
330+ } ) . then ( async ( m ) => {
331+ await m . delete ( )
332+ } )
333+ } else if ( perms . DiscordUserId ) {
334+ await ( channel as ThreadChannel ) . members . add ( perms . DiscordUserId )
335+ }
336+ }
337+ }
305338
306339 // Shadow Ping
307340 for ( const perms of data . TicketPermissions ) {
308341 if ( perms . HasShadowPing ) {
309342 // Thread
310- if ( IsThread && perms . DiscordRoleId ) {
311- const roleMembers = guild . roles . cache . get ( perms . DiscordRoleId )
312- for ( const member of roleMembers . members . keys ( ) ) {
313- await ( channel as ThreadChannel ) . members . add ( member )
314- }
343+ // Has beed Pinged
315344
316- } else if ( IsThread && perms . DiscordUserId ) {
317- await ( channel as ThreadChannel ) . members . add ( perms . DiscordUserId )
318- }
319345 // Channel
320- else if ( IsChannel && perms . DiscordRoleId ) {
346+ if ( IsChannel && perms . DiscordRoleId ) {
321347 channel . send ( {
322348 content : `<@&${ perms . DiscordRoleId } >`
323349 } ) . then ( async ( m ) => {
0 commit comments