D
D
Deso Crew2020-08-11 16:11:27
JavaScript
Deso Crew, 2020-08-11 16:11:27

How to link a js file to another one?

The matter is that I made a command, but I do not know what line to bind it.

Here is the index.js code:

const Discord = require('discord.js');
const client = new Discord.Client();
const { Client, MessageEmbed } = require('discord.js');

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});


And here is the code of the file that needs to be linked (profile.js):
const Discord = module.require("discord.js");
const fs = require("fs");
module.exports.run = async (bot,message,args) => {
    let a = message.author
    let embed = new Discord.RichEmbed()
    .setDescription("Информация о сервере")
    .setColor('#10c7e2')
    .addField("Имя",a.username)
    .addField("Тэг",a.tag)
    .addField("Дискриминатор",a.discriminator)
    .addField("Создание аккаунта",a.createdAt)
    .addField("ID",a.id)
    .addField("Вы бот?",a.bot)
    .setThumbnail(a.avatarURL)

    bot.send(embed);

};
module.exports.help = {
    name: "userinfo"
};

spoiler
P.s. взял содержимое с profile.js на этом форуме.

How to bind them so that they work as a whole file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Rosin, 2020-08-11
@Rosin886

the easiest way is to attach the command to the main bot file:

const Discord = require('discord.js');
const client = new Discord.Client();
const { Client, MessageEmbed } = require('discord.js');

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', (message) =>{

if (message.content == prefix+'userinfo'){
let a = message.author
    let embed = new Discord.RichEmbed()
    .setDescription("Информация о сервере")
    .setColor('#10c7e2')
    .addField("Имя",a.username)
    .addField("Тэг",a.tag)
    .addField("Дискриминатор",a.discriminator)
    .addField("Создание аккаунта",a.createdAt)
    .addField("ID",a.id)
    .addField("Вы бот?",a.bot)
    .setThumbnail(a.avatarURL)

    message.channel.send(embed);
}
});
bot.login('your token');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question