-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetupResponse.ts
More file actions
60 lines (53 loc) · 1.91 KB
/
Copy pathsetupResponse.ts
File metadata and controls
60 lines (53 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {
ChannelType,
Client,
ContainerBuilder,
Events,
Interaction,
MessageFlags
} from "discord.js";
import { prisma } from "../libs/database.js";
import { SystemColors } from "../libs/colors.js";
export default {
name: Events.InteractionCreate,
async execute(_client: Client, interaction: Interaction) {
if (!interaction.isModalSubmit()) return;
if (!interaction.guild) return;
if (interaction.customId != 'setupboostifymodal' && interaction.customId != 'configboostifymodal') return;
const boostchannel = interaction.fields.getSelectedChannels('boostchannel', true, [ChannelType.GuildText, ChannelType.GuildAnnouncement]);
const logsChannel = interaction.fields.getSelectedChannels('logs', true, [ChannelType.GuildText]);
const setup = await prisma.guildSetting.findFirst({ where: { gid: interaction.guild.id }})
const boostChannelId = boostchannel.first()
const logChannelId = logsChannel.first()
if (!boostChannelId || !logChannelId) {
return interaction.reply({ content: 'Please select both channels.', ephemeral: true });
}
await prisma.guildSetting.upsert({
where: {
gid: interaction.guild.id
},
update: {
greetChannelId: boostChannelId.id,
logChannelId: logChannelId.id
},
create: {
uid: crypto.randomUUID(),
gid: interaction.guild.id,
greetChannelId: boostChannelId.id,
logChannelId: logChannelId.id
}
});
const container = new ContainerBuilder()
.setAccentColor(SystemColors.main)
.addTextDisplayComponents(
(txt) => txt.setContent([
`## ${!setup ? "Aaannndd... we're done!" : "Configuration changed" }`,
`- Boost notifications: ${boostChannelId}\n- Logs: ${logChannelId}`
].join('\n'))
);
await interaction.reply({
components: [container],
flags: [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2]
})
}
};