Visual Studio Code
Visual Studio Code
Explore posts from servers
SIASapphire - Imagine a framework
Created by Visual Studio Code on 2/13/2024 in #sapphire-support
Using Paths w/ TypeScript
I'm trying to use TypeScripts Paths to make it easier and cleaner to import modules, although I always get: Cannot find package '@modules/mongodb' imported from C:\ExampleDirectory I've tried using node -r tsconfig-paths/register ., but that doesn't work and it still shows the same error above. The only thing that did manage to work was using tsx, but unfortunately that's not supported by Sapphire so no commands, listeners, or interaction handlers loaded.
6 replies
SIASapphire - Imagine a framework
Created by Visual Studio Code on 2/1/2024 in #discordjs-support
Getting the deleter of a deleted message
Hi, I'm trying to get the deleter of a deleted message using .fetchAuditLogs() and .entries.first(), but sometimes they don't work... If I were to create a message and delete it, it would show me as the deleter. If I then created a message and then someone else deleted it, it would still show me as the deleter. Then, eventually it would switch and then always show the other person as the deleter. (I tried asking in the DiscordJS server but they always say I'm wrong and don't actually help 😔)
2 replies
SIASapphire - Imagine a framework
Created by Visual Studio Code on 12/12/2023 in #discordjs-support
Editing an ephemeral reply from an interaction handler
How can I edit an ephemeral reply from an interaction handler? Say that I have ping.js with an embed and a button in an ephemeral message, I want to be able to click that button and then edit the original ephemeral message from pinghandler.js.
9 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Visual Studio Code on 11/12/2023 in #djs-questions
Fetching a slash command reply's ID before it's sent
Title basically explains what I'm trying to do. I'm creating a post system, but instead of constantly doing a chain of replies, I want to just edit the topmost message by passing it's ID throughout all components. postCommand.js
// Deferred Reply
const deferredReply = await interaction.deferReply();

// Send Reply
const reply = await interaction.editReply({
content: "Posting System",
});

// Select Menu
const newSelectMenu = new StringSelectMenuBuilder()
.addOptions(
new SSMOB()
.setLabel("Option1")
.setDescription("The first option.")
.setValue("Option1")
)
.setCustomId(
`postChooseType.${interaction.user.id}.${fetchedReply.id}`
);

// Action Row
const AR = new ActionRowBuilder().addComponents(newSelectMenu);

// Add Components
reply.edit({
components: [AR],
});
// Deferred Reply
const deferredReply = await interaction.deferReply();

// Send Reply
const reply = await interaction.editReply({
content: "Posting System",
});

// Select Menu
const newSelectMenu = new StringSelectMenuBuilder()
.addOptions(
new SSMOB()
.setLabel("Option1")
.setDescription("The first option.")
.setValue("Option1")
)
.setCustomId(
`postChooseType.${interaction.user.id}.${fetchedReply.id}`
);

// Action Row
const AR = new ActionRowBuilder().addComponents(newSelectMenu);

// Add Components
reply.edit({
components: [AR],
});
I tried getting the reply ID from the deferredReply, but that returns a completely different ID to the one that get's sent. The only method that works is by setting the customId after the message was sent, and then editing the reply to add the selectMenu. I want to do this all before the event is sent.
6 replies
SIASapphire - Imagine a framework
Created by Visual Studio Code on 11/8/2023 in #discordjs-support
Making multi-line embed descriptions cleaner
No description
7 replies
SIASapphire - Imagine a framework
Created by Visual Studio Code on 10/16/2023 in #sapphire-support
guild.roles.everyone but for boosters?
Wondering if there's a guild.roles.everyone version for the booster role?
4 replies
SIASapphire - Imagine a framework
Created by Visual Studio Code on 10/7/2023 in #sapphire-support
Specifying Types
No description
5 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Visual Studio Code on 7/25/2023 in #djs-questions
Error when trying to show modal after clicking button.
I'm trying to show a modal when the user clicks a button included in the reply, but I keep getting the 'InteractionAlreadyReplied' error.
// Dependencies
const { ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require("discord.js");

module.exports = async function (interaction) {
// Variables
let msg;
let collector;

// Buttons
const editDataButton = new ButtonBuilder()
.setCustomId("editDataButton")
.setLabel("EditID")
.setStyle(ButtonStyle.Primary);
const editDataRow = new ActionRowBuilder().addComponents(editDataButton);

// Modals
const editIDModal = new ModalBuilder()
.setCustomId("editIDModal")
.setTitle("EditID")

// Text Inputs
const IDInput = new TextInputBuilder()
.setCustomId("IDInput")
.setPlaceholder("ID")
.setStyle(TextInputStyle.Short)
.setMinLength(1)
.setMaxLength(20)
.setRequired(true);

// Set Modal Components
editIDModal.addComponents(IDInput);

msg = await interaction.reply({
content: "Please edit your account ID below.",
components: [editDataRow],
});

collector = msg.createMessageComponentCollector();

collector.on("collect", async (i) => {
if (i.customId == "editDataButton") {
await interaction.showModal(editIDModal)
}
});
};
// Dependencies
const { ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require("discord.js");

module.exports = async function (interaction) {
// Variables
let msg;
let collector;

// Buttons
const editDataButton = new ButtonBuilder()
.setCustomId("editDataButton")
.setLabel("EditID")
.setStyle(ButtonStyle.Primary);
const editDataRow = new ActionRowBuilder().addComponents(editDataButton);

// Modals
const editIDModal = new ModalBuilder()
.setCustomId("editIDModal")
.setTitle("EditID")

// Text Inputs
const IDInput = new TextInputBuilder()
.setCustomId("IDInput")
.setPlaceholder("ID")
.setStyle(TextInputStyle.Short)
.setMinLength(1)
.setMaxLength(20)
.setRequired(true);

// Set Modal Components
editIDModal.addComponents(IDInput);

msg = await interaction.reply({
content: "Please edit your account ID below.",
components: [editDataRow],
});

collector = msg.createMessageComponentCollector();

collector.on("collect", async (i) => {
if (i.customId == "editDataButton") {
await interaction.showModal(editIDModal)
}
});
};
I was told using deferReply was previously stopping it from working, so I switched it to a normal reply. Still getting the same error. P.S. There's other variables in there due to there being database management things, I removed them to clear up what's causing the issue.
17 replies