Skip to content

Commit

Permalink
switch ban user selecter to a modal
Browse files Browse the repository at this point in the history
apparently user select menus can only select people in the current server

fourth times a charm
  • Loading branch information
mrhappyma committed Jan 18, 2025
1 parent 35c1cd3 commit 2cd332b
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/modules/bans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
UserSelectMenuBuilder,
} from "discord.js";
import * as chrono from "chrono-node";
import { getActiveOrdersForUser, updateOrder } from "../orders/cache";
import { getActiveOrdersForUser } from "../orders/cache";
import updateOrderStatus from "../orders/updateStatus";
import bot from "..";

Expand Down Expand Up @@ -53,18 +53,27 @@ const addBan = async (
};

messagesClient.registerButton("devtools:manage-bans", async (interaction) => {
const a1 = new ActionRowBuilder<UserSelectMenuBuilder>().addComponents([
new UserSelectMenuBuilder().setCustomId("devtools:manage-bans:user"),
]);
return await interaction.update({
components: [a1],
});
const modal = new ModalBuilder()
.setTitle("Manage bans")
.setCustomId("devtools:manage-bans:user")
.addComponents([
new ActionRowBuilder<TextInputBuilder>().addComponents([
new TextInputBuilder()
.setCustomId("user")
.setLabel("id")
.setStyle(TextInputStyle.Short),
]),
]);
return await interaction.showModal(modal);
});

messagesClient.registerUserSelectMenu(
messagesClient.registerModal(
"devtools:manage-bans:user",
async (interaction) => {
const user = interaction.users.first()!;
const id = interaction.fields.getTextInputValue("user");
const user = await bot.client.users.fetch(id);
if (!user) return interaction.reply({ content: "User not found" });

const bans = userActiveBans(user.id);
const embed = new EmbedBuilder()
.setTitle(`Bans for ${user.tag}`)
Expand Down Expand Up @@ -107,9 +116,10 @@ messagesClient.registerUserSelectMenu(
.setStyle(ButtonStyle.Danger)
.setEmoji("🔨"),
]);
return await interaction.update({
return await interaction.reply({
embeds: [embed],
components: [a1, a2],
ephemeral: true,
});
}
);
Expand Down

0 comments on commit 2cd332b

Please sign in to comment.