Izzibaby
Izzibaby
DIdiscord.js - Imagine ❄
Created by Izzibaby on 1/7/2025 in #djs-questions
Require Vs Import, trying to "import" another script via the require method.
So I was following the discordjs.guide site on setting up the bot and they used require for everything,
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
Example ^ So now in one of my slash-commands I'm trying to get one of my scripts, which normally I'd do, for example:
import { getHydraAccess } from "./apiAccess/hydra.js";
import { getHydraAccess } from "./apiAccess/hydra.js";
However I need to choose require instead of import, and I followed the code along, so it's a bit too much for me to try and make all the rest of the code and the way it's written utilize the import feature versus require. So I followed the same format as the others and wrote:
const { getHydraAccess } = require('./apiAccess/hydra.js');
const { getHydraAccess } = require('./apiAccess/hydra.js');
However now I'm getting the error: Error: Cannot find module './apiAccess/hydra.js' No matter what I do, it can't find it properly and I'm not sure what to change as I'm used to the import/export method, and attempting to figure out the require method for this.
5 replies
DIdiscord.js - Imagine ❄
Created by Izzibaby on 10/17/2024 in #djs-questions
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
I'm used to the old days of just doing commands with text in the chat !commands for example. Slash commands and such are quite new so I was going over the documentation page from Discord themselves, and have been trying to figure out "DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE".
res.send({
type: InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
});
res.send({
type: InteractionResponseType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
});
I have this part.. but now I'm trying to figure out.. where do I end up sending the "DEFERRED_UPDATE_MESSAGE" to update the message, and how do I do it specifically? There wasn't much on the topic of editing messages much in a clear way that I could figure out myself.
19 replies