Skip to content
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
101 changes: 0 additions & 101 deletions src/commands/example_all.test.ts

This file was deleted.

40 changes: 40 additions & 0 deletions src/commands/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
SlashCommandBuilder,
ModalBuilder,
ChannelType,
LabelBuilder,
} from "discord.js";
import { Command } from "../base/classes/command.js";

export default new Command({
info: new SlashCommandBuilder()
.setName("config")
.setDescription("Change the configuration of this server."),
async execute(interaction) {
if (!interaction.guild) return;

const modal = new ModalBuilder().setTitle('Configuration').setCustomId('configboostifymodal')
const GreetingChannelRes = new LabelBuilder()
.setLabel('Where should boosts be sent?')
.setChannelSelectMenuComponent(
(channel) =>
channel.addChannelTypes(ChannelType.GuildAnnouncement, ChannelType.GuildText)
.setCustomId('boostchannel')
.setRequired(true)
);

const LoggingChannel = new LabelBuilder()
.setLabel('Where should logs be sent?')
.setChannelSelectMenuComponent(
(channel) =>
channel.addChannelTypes(ChannelType.GuildText)
.setCustomId('logs')
.setRequired(true)
);

modal.addLabelComponents(GreetingChannelRes, LoggingChannel);
interaction.showModal(modal);
},
ownerOnly: true,
})

36 changes: 28 additions & 8 deletions src/events/setupResponse.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,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') 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.create({
data: {
await prisma.guildSetting.upsert({
where: {
gid: interaction.guild.id
},
update: {
greetChannelId: boostChannelId.id,
logChannelId: logChannelId.id
},
create: {
uid: crypto.randomUUID(),
gid: interaction.guild!.id,
gid: interaction.guild.id,
greetChannelId: boostChannelId.id,
logChannelId: logChannelId.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({
content: `Setup complete!\n- Boost notifications: ${boostChannelId}\n- Logs: ${logChannelId}`,
flags: MessageFlags.Ephemeral,
});
components: [container],
flags: [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2]
})
}
};
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ client.commands = new Collection();
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
.filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map"));

const eventsPath = path.join(__dirname, "events");
const eventFiles = fs
.readdirSync(eventsPath)
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
.filter((file) => file.endsWith(".js") || file.endsWith(".ts") || !file.endsWith(".map"));

(async () => {
for (const file of commandFiles) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/loadCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function loadCommands(): Promise<void> {

const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".ts") || !file.endsWith("test.ts") ||file.endsWith(".js") || !file.endsWith("test.js"));
.filter((file) => file.endsWith(".ts") ||file.endsWith(".js"));

if (commandFiles.length === 0) {
logger.warn("No command files found — nothing to register.");
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
"exclude": ["**/*.map", "node_modules", "dist"]
}
Loading