it’s raining outside
it’s raining outside
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
>have an issue >dont know why >"incorrect type" >replace it with any >works perfectly
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
wdym?
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
ah ok i see now
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
when i ran everything in js, it worked perfectly fine, but after switching to ts, everything fell apart
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
this page
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
im just reading the docs
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
🤷
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
tihis is my whole code
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
import * as fs from 'fs';
import * as path from 'path';

import { readFileSync } from "fs";
import { Client, Collection, Events, GatewayIntentBits } from 'discord.js';
const token = readFileSync('./token.txt', 'utf-8');

const client = new Client({intents: [GatewayIntentBits.Guilds]});

const commands = new Collection();

const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commands.Path).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);

if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`)
})

client.login(token);
import * as fs from 'fs';
import * as path from 'path';

import { readFileSync } from "fs";
import { Client, Collection, Events, GatewayIntentBits } from 'discord.js';
const token = readFileSync('./token.txt', 'utf-8');

const client = new Client({intents: [GatewayIntentBits.Guilds]});

const commands = new Collection();

const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commands.Path).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);

if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`)
})

client.login(token);
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
apologies if im bothering you btw i dont mean to
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
getting this now
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
alr thank you 👍
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
confused why this wont let me assign the collection instance to the commands attribute like it says in the docs 🤷
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
hm ok i see
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
ah i see
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
2 things: 1. what do i do then? im going off the docs as a basic guide 2. what does "destructure" mean in javascript terms?
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
import { fs } from 'node:fs';
^^
SyntaxError: The requested module 'node:fs' does not provide an export named 'fs'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.10.0
import { fs } from 'node:fs';
^^
SyntaxError: The requested module 'node:fs' does not provide an export named 'fs'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.10.0
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
then fs cant be imported from node:fs
96 replies
DIAdiscord.js - Imagine an app
Created by it’s raining outside on 5/17/2024 in #djs-questions
hopefully two simple questions
i changed it to .cjs then it told me to change it to .mjs
96 replies