Обкуренный
Обкуренный
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 9/30/2023 in #djs-questions
Help
C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1
const chalk = require("chalk");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\User\Desktop\Музыкальный Бот\node_modules\chalk\source\index.js from C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js not supported.
Instead change the require of index.js in C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1:15)
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:29:19)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.0
PS C:\Users\User\Desktop\Музыкальный Бот\src> node .
C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1
const { chalk } = require("chalk");
^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\User\Desktop\Музыкальный Бот\node_modules\chalk\source\index.js from C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js not supported.
Instead change the require of index.js in C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1:19)
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:29:19)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.0
C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1
const chalk = require("chalk");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\User\Desktop\Музыкальный Бот\node_modules\chalk\source\index.js from C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js not supported.
Instead change the require of index.js in C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1:15)
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:29:19)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.0
PS C:\Users\User\Desktop\Музыкальный Бот\src> node .
C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1
const { chalk } = require("chalk");
^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\User\Desktop\Музыкальный Бот\node_modules\chalk\source\index.js from C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js not supported.
Instead change the require of index.js in C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\utils\logger.js:1:19)
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:29:19)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.0
9 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 9/30/2023 in #djs-questions
Help
const chalk = require("chalk");
const moment = require("moment");

module.exports = class Logger {
static log (content, type = "log") {
const date = `${moment().format("DD-MM-YYYY hh:mm:ss")}`;
switch (type) {

case "log": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgBlue(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "warn": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgYellow(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "error": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgRed(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "debug": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgGreen(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "cmd": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgWhite(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "event": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgHex('#e1f507')(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "ready": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgHex('#067032')(type.toUpperCase())}] ${chalk.blue(content)}`);
}
default: throw new TypeError("Logger type must be either warn, debug, log, ready, cmd or error.");
}
}
};
const chalk = require("chalk");
const moment = require("moment");

module.exports = class Logger {
static log (content, type = "log") {
const date = `${moment().format("DD-MM-YYYY hh:mm:ss")}`;
switch (type) {

case "log": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgBlue(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "warn": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgYellow(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "error": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgRed(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "debug": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgGreen(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "cmd": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgWhite(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "event": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgHex('#e1f507')(type.toUpperCase())}] ${chalk.blue(content)}`);
}
case "ready": {
return console.log(`[${chalk.yellow(date)}]: [${chalk.black.bgHex('#067032')(type.toUpperCase())}] ${chalk.blue(content)}`);
}
default: throw new TypeError("Logger type must be either warn, debug, log, ready, cmd or error.");
}
}
};
9 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 9/30/2023 in #djs-questions
Help
C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:16
GatewayIntentBits.Guild,
^

ReferenceError: GatewayIntentBits is not defined
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:16:9)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.17.0
C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:16
GatewayIntentBits.Guild,
^

ReferenceError: GatewayIntentBits is not defined
at new MusicBot (C:\Users\User\Desktop\Музыкальный Бот\src\structures\MusicClient.js:16:9)
at Object.<anonymous> (C:\Users\User\Desktop\Музыкальный Бот\src\index.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Node.js v18.17.0
9 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
To be honest, I don't fully understand what I need to do now.
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
The bot thinks
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
interactionCreate.js
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\commands\Moderation\MemberInfo.js:69:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\events\interactionCreate.js:15:13) {
code: 'InteractionAlreadyReplied'
}
C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\commands\Moderation\MemberInfo.js:69:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\events\interactionCreate.js:15:13) {
code: 'InteractionAlreadyReplied'
}
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/6/2023 in #djs-questions
MongoDB is not working
Okay
4 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
I found this only in index.js
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
What do you mean?
18 replies
DIAdiscord.js - Imagine a bot
Created by aboodooo on 8/5/2023 in #djs-questions
HELP
And can you throw off the code?
22 replies
DIAdiscord.js - Imagine a bot
Created by aboodooo on 8/5/2023 in #djs-questions
HELP
yes
22 replies
DIAdiscord.js - Imagine a bot
Created by aboodooo on 8/5/2023 in #djs-questions
HELP
Try installing again
22 replies
DIAdiscord.js - Imagine a bot
Created by aboodooo on 8/5/2023 in #djs-questions
HELP
You have installed the module discord.js ?
22 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
Maybe, but I didn't quite understand, is it possible somehow in the code?
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/5/2023 in #djs-questions
Made a command for user information, gives an error
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
18 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/4/2023 in #djs-questions
Buttons
There are no errors in the console
4 replies
DIAdiscord.js - Imagine a bot
Created by Обкуренный on 8/4/2023 in #djs-questions
Buttons
const { ButtonInteraction } = require("discord.js");

const votedMembers = new Set();

module.exports = {
name: "interactionCreate",
/**
*
* @param {ButtonInteraction} interaction
*/
async execute(interaction) {
if(!interaction.isButton()) return;

const splittedArray = interaction.customId.split('-');
if(splittedArray[0] !== "Poll") return;

if(votedMembers.has(`${interaction.user.id}-${interaction.message.id}`))
return interaction.reply({content: "Вы уже проголосовали!", ephemeral: true});

votedMembers.add(`${interaction.user.id}-${interaction.message.id}`);

const pollEmbed = interaction.message.embeds[0];
if(!pollEmbed) return interaction.reply({
content: "",
ephemeral: true
});

const yesField = pollEmbed.fields[0];
const noField = pollEmbed.fields[1];

const VoteCountedReply = "Ваш голос был успешно учтён!";

switch(splittedArray[1]) {
case "Yes" : {
const newYesCount = parseInt(yesField.value) + 1;
yesField.value = newYesCount;

interaction.reply({content: VoteCountedReply, ephemeral: true});
interaction.message.edit({embeds: [pollEmbed]});
}
break;
case "No": {
const newNoCount = parseInt(noField.value) + 1;
noField.value = newNoCount;

interaction.reply({content: VoteCountedReply, ephemeral: true});
interaction.message.edit({embeds: [pollEmbed]});
}
break;
}
}
}
const { ButtonInteraction } = require("discord.js");

const votedMembers = new Set();

module.exports = {
name: "interactionCreate",
/**
*
* @param {ButtonInteraction} interaction
*/
async execute(interaction) {
if(!interaction.isButton()) return;

const splittedArray = interaction.customId.split('-');
if(splittedArray[0] !== "Poll") return;

if(votedMembers.has(`${interaction.user.id}-${interaction.message.id}`))
return interaction.reply({content: "Вы уже проголосовали!", ephemeral: true});

votedMembers.add(`${interaction.user.id}-${interaction.message.id}`);

const pollEmbed = interaction.message.embeds[0];
if(!pollEmbed) return interaction.reply({
content: "",
ephemeral: true
});

const yesField = pollEmbed.fields[0];
const noField = pollEmbed.fields[1];

const VoteCountedReply = "Ваш голос был успешно учтён!";

switch(splittedArray[1]) {
case "Yes" : {
const newYesCount = parseInt(yesField.value) + 1;
yesField.value = newYesCount;

interaction.reply({content: VoteCountedReply, ephemeral: true});
interaction.message.edit({embeds: [pollEmbed]});
}
break;
case "No": {
const newNoCount = parseInt(noField.value) + 1;
noField.value = newNoCount;

interaction.reply({content: VoteCountedReply, ephemeral: true});
interaction.message.edit({embeds: [pollEmbed]});
}
break;
}
}
}
4 replies