Fhyrox
DIAdiscord.js - Imagine an app
•Created by Fhyrox on 9/16/2023 in #djs-questions
mongodb error
index.js
const fs = require('node:fs');
const path = require('node:path');
require("dotenv").config()
const { readdirSync } = require("node:fs");
const { Client, IntentsBitField, Message, GatewayIntentBits, Collection } = require("discord.js");
const mongoose = require('mongoose');
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent
]
})
client.commands = new Collection();
const commandFiles = fs.readdirSync('./komutlar').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./komutlar/${file}`);
client.commands.set(command.name, command);
}
client.on('messageCreate', message => {
if (message.author.bot) return;
const args = message.content.slice("!".length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
}});
const eventsPath = path.join(__dirname, 'eventler');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
mongoose.connect(process.env['mongo'], {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('EŞŞEK')
})
.catch((err) => {
console.log(err)
});
const fs = require('node:fs');
const path = require('node:path');
require("dotenv").config()
const { readdirSync } = require("node:fs");
const { Client, IntentsBitField, Message, GatewayIntentBits, Collection } = require("discord.js");
const mongoose = require('mongoose');
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent
]
})
client.commands = new Collection();
const commandFiles = fs.readdirSync('./komutlar').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./komutlar/${file}`);
client.commands.set(command.name, command);
}
client.on('messageCreate', message => {
if (message.author.bot) return;
const args = message.content.slice("!".length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
try {
command.execute(message, args);
} catch (error) {
console.error(error);
}});
const eventsPath = path.join(__dirname, 'eventler');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
mongoose.connect(process.env['mongo'], {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('EŞŞEK')
})
.catch((err) => {
console.log(err)
});
3 replies