Skip to content

Commit b84bed6

Browse files
authored
Merge pull request #9 from teamboostify/revamp/codebase
aaa
2 parents 117b03c + b84cefe commit b84bed6

6 files changed

Lines changed: 72 additions & 113 deletions

File tree

src/commands/example_all.test.ts

Lines changed: 0 additions & 101 deletions
This file was deleted.

src/commands/settings.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
SlashCommandBuilder,
3+
ModalBuilder,
4+
ChannelType,
5+
LabelBuilder,
6+
} from "discord.js";
7+
import { Command } from "../base/classes/command.js";
8+
9+
export default new Command({
10+
info: new SlashCommandBuilder()
11+
.setName("config")
12+
.setDescription("Change the configuration of this server."),
13+
async execute(interaction) {
14+
if (!interaction.guild) return;
15+
16+
const modal = new ModalBuilder().setTitle('Configuration').setCustomId('configboostifymodal')
17+
const GreetingChannelRes = new LabelBuilder()
18+
.setLabel('Where should boosts be sent?')
19+
.setChannelSelectMenuComponent(
20+
(channel) =>
21+
channel.addChannelTypes(ChannelType.GuildAnnouncement, ChannelType.GuildText)
22+
.setCustomId('boostchannel')
23+
.setRequired(true)
24+
);
25+
26+
const LoggingChannel = new LabelBuilder()
27+
.setLabel('Where should logs be sent?')
28+
.setChannelSelectMenuComponent(
29+
(channel) =>
30+
channel.addChannelTypes(ChannelType.GuildText)
31+
.setCustomId('logs')
32+
.setRequired(true)
33+
);
34+
35+
modal.addLabelComponents(GreetingChannelRes, LoggingChannel);
36+
interaction.showModal(modal);
37+
},
38+
ownerOnly: true,
39+
})
40+

src/events/setupResponse.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
11
import {
22
ChannelType,
33
Client,
4+
ContainerBuilder,
45
Events,
56
Interaction,
67
MessageFlags
78
} from "discord.js";
89
import { prisma } from "../libs/database.js";
10+
import { SystemColors } from "../libs/colors.js";
911

1012
export 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
};

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ client.commands = new Collection();
7070
const commandsPath = path.join(__dirname, "commands");
7171
const commandFiles = fs
7272
.readdirSync(commandsPath)
73-
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
73+
.filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map"));
7474

7575
const eventsPath = path.join(__dirname, "events");
7676
const eventFiles = fs
7777
.readdirSync(eventsPath)
78-
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
78+
.filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map"));
7979

8080
(async () => {
8181
for (const file of commandFiles) {

src/libs/loadCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function loadCommands(): Promise<void> {
3535

3636
const commandFiles = fs
3737
.readdirSync(commandsPath)
38-
.filter((file) => file.endsWith(".ts") || !file.endsWith("test.ts") ||file.endsWith(".js") || !file.endsWith("test.js"));
38+
.filter((file) => file.endsWith(".ts") ||file.endsWith(".js"));
3939

4040
if (commandFiles.length === 0) {
4141
logger.warn("No command files found — nothing to register.");

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"sourceMap": true
1616
},
1717
"include": ["src/**/*"],
18-
"exclude": ["node_modules", "dist"]
18+
"exclude": ["**/*.map", "node_modules", "dist"]
1919
}

0 commit comments

Comments
 (0)