mongodb error

events/messageCreate.js
const { Events } = require('discord.js');
const model = require('../schema/profileschema')

module.exports = {
name: Events.MessageCreate,
execute(Message) {
let profileData;
try {
profileData = model.findOne({ userId: Message.author.id });
if (!profileData) {
profileData = model.create({
userId: Message.author.id,
});
}
} catch(err) {
console.log(err)
}`
}
}
const { Events } = require('discord.js');
const model = require('../schema/profileschema')

module.exports = {
name: Events.MessageCreate,
execute(Message) {
let profileData;
try {
profileData = model.findOne({ userId: Message.author.id });
if (!profileData) {
profileData = model.create({
userId: Message.author.id,
});
}
} catch(err) {
console.log(err)
}`
}
}
const { EmbedBuilder } = require("discord.js"); const model = require("../schema/profileschema"); const profileData = require('../eventler/messageCreate') param.js
module.exports = {
name: 'param',
description: 'Param komiti.',
execute(message, args, profileData) {
const {para, banka} = profileData;
const username = message.author.username;

const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setURL('https://discord.js.org/')
.setAuthor({ name: `${message.author.username} adlı kişinin bakiye bilgileri.`, iconURL: `${message.author.displayAvatarURL()}`})
.setDescription('Some description here')
.setThumbnail(message.author.displayAvatarURL())
.addFields(
{ name: 'Para', value: para, inline: true },
{ name: 'Banka', value: banka, inline: true },
)
.setTimestamp()

message.channel.send({ embeds: [exampleEmbed] });
},
};
module.exports = {
name: 'param',
description: 'Param komiti.',
execute(message, args, profileData) {
const {para, banka} = profileData;
const username = message.author.username;

const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setURL('https://discord.js.org/')
.setAuthor({ name: `${message.author.username} adlı kişinin bakiye bilgileri.`, iconURL: `${message.author.displayAvatarURL()}`})
.setDescription('Some description here')
.setThumbnail(message.author.displayAvatarURL())
.addFields(
{ name: 'Para', value: para, inline: true },
{ name: 'Banka', value: banka, inline: true },
)
.setTimestamp()

message.channel.send({ embeds: [exampleEmbed] });
},
};
2 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Fhyrox
FhyroxOP15mo ago
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)
});
Want results from more Discord servers?
Add your server