11import {
22 ChannelType ,
33 Client ,
4+ ContainerBuilder ,
45 Events ,
56 Interaction ,
67 MessageFlags
78} from "discord.js" ;
89import { prisma } from "../libs/database.js" ;
10+ import { SystemColors } from "../libs/colors.js" ;
911
1012export default {
1113 name : Events . InteractionCreate ,
1214 async execute ( _client : Client , interaction : Interaction ) {
1315 if ( ! interaction . isModalSubmit ( ) ) return ;
1416 if ( ! interaction . guild ) return ;
15- if ( interaction . customId != 'setupboostifymodal' ) return ;
17+ if ( interaction . customId != 'setupboostifymodal' && interaction . customId != 'configboostifymodal' ) return ;
1618 const boostchannel = interaction . fields . getSelectedChannels ( 'boostchannel' , true , [ ChannelType . GuildText , ChannelType . GuildAnnouncement ] ) ;
1719 const logsChannel = interaction . fields . getSelectedChannels ( 'logs' , true , [ ChannelType . GuildText ] ) ;
1820
21+ const setup = await prisma . guildSetting . findFirst ( { where : { gid : interaction . guild . id } } )
22+
1923 const boostChannelId = boostchannel . first ( )
2024 const logChannelId = logsChannel . first ( )
2125
2226 if ( ! boostChannelId || ! logChannelId ) {
2327 return interaction . reply ( { content : 'Please select both channels.' , ephemeral : true } ) ;
2428 }
2529
26- await prisma . guildSetting . create ( {
27- data : {
30+ await prisma . guildSetting . upsert ( {
31+ where : {
32+ gid : interaction . guild . id
33+ } ,
34+ update : {
35+ greetChannelId : boostChannelId . id ,
36+ logChannelId : logChannelId . id
37+ } ,
38+ create : {
2839 uid : crypto . randomUUID ( ) ,
29- gid : interaction . guild ! . id ,
40+ gid : interaction . guild . id ,
3041 greetChannelId : boostChannelId . id ,
31- logChannelId : logChannelId . id ,
42+ logChannelId : logChannelId . id
3243 }
3344 } ) ;
3445
46+ const container = new ContainerBuilder ( )
47+ . setAccentColor ( SystemColors . main )
48+ . addTextDisplayComponents (
49+ ( txt ) => txt . setContent ( [
50+ `## ${ ! setup ? "Aaannndd... we're done!" : "Configuration changed" } ` ,
51+ `- Boost notifications: ${ boostChannelId } \n- Logs: ${ logChannelId } `
52+ ] . join ( '\n' ) )
53+ ) ;
54+
3555 await interaction . reply ( {
36- content : `Setup complete!\n- Boost notifications: ${ boostChannelId } \n- Logs: ${ logChannelId } ` ,
37- flags : MessageFlags . Ephemeral ,
38- } ) ;
56+ components : [ container ] ,
57+ flags : [ MessageFlags . Ephemeral , MessageFlags . IsComponentsV2 ]
58+ } )
3959 }
4060} ;
0 commit comments