Javascript 网页包+;Discord.js+;电子

Javascript 网页包+;Discord.js+;电子,javascript,webpack,electron,discord.js,Javascript,Webpack,Electron,Discord.js,我在构建网页包时遇到了一个问题 未初始化Discord客户端 这是我在电子方面的第一个应用。请帮忙 错误:未捕获类型错误:i(…)。客户端不是Web包文件中的构造函数 如果我请求帮助,我会很高兴得到一个好的答案。下面我将提供所有文件的代码。 main.js const path = require('path'); const url = require('url'); const {app,BrowserWindow} = require('electron'); const {sendMe

我在构建网页包时遇到了一个问题

未初始化Discord客户端

这是我在电子方面的第一个应用。请帮忙

错误:未捕获类型错误:i(…)。客户端不是Web包文件中的构造函数

如果我请求帮助,我会很高兴得到一个好的答案。下面我将提供所有文件的代码。

main.js

const path = require('path');
const url = require('url');
const {app,BrowserWindow} = require('electron');
const {sendMessage,isValidForm} = require('./back.js');


let win;

function createWindow() {
    win = new BrowserWindow({
        width: 1200,
        height : 800,
        icon : __dirname + "/img/icon.png"
    });

    win.loadURL(url.format({
        pathname: path.join(__dirname,"/html/index.html"),
        protocol: 'file:',
        slashes: true
    }));

    win.webContents.openDevTools();

    win.on('closed', () => {
        win = null;
    });
}

app.on('ready', createWindow);

app.on('window-all-closed',() => {
    app.quit();
});
var path = require('path');
  module.exports = {
    entry: './src/components/main.js',
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    },
    externals: [
      (function () {
        var IGNORES = [
          'electron',
          'fs'
        ];
        return function (context, request, callback) {
          if (IGNORES.indexOf(request) >= 0) {
            return callback(null, "require('" + request + "')");
          }
          return callback();
        };
      })()
    ]
  }; 
const Discord = require('discord.js');
const bot = new Discord.Client();


bot.login("token")
function isValidForm (first,second) {
    if(first.value == "" || second.value == "") {
        return alert('Одна из форм не заполненна')
    }
    sendMessage(first.value, second.value);
}

function sendMessage (channelName,message) {
    const channel = bot.channels.cache.find(ch => ch.name === channelName);
    if(!channel) {
        return alert("Канал с таним названием не найден!");
    }
    channel.send(message);
}

module.exports = {sendMessage,isValidForm};


webpack.config.js

const path = require('path');
const url = require('url');
const {app,BrowserWindow} = require('electron');
const {sendMessage,isValidForm} = require('./back.js');


let win;

function createWindow() {
    win = new BrowserWindow({
        width: 1200,
        height : 800,
        icon : __dirname + "/img/icon.png"
    });

    win.loadURL(url.format({
        pathname: path.join(__dirname,"/html/index.html"),
        protocol: 'file:',
        slashes: true
    }));

    win.webContents.openDevTools();

    win.on('closed', () => {
        win = null;
    });
}

app.on('ready', createWindow);

app.on('window-all-closed',() => {
    app.quit();
});
var path = require('path');
  module.exports = {
    entry: './src/components/main.js',
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    },
    externals: [
      (function () {
        var IGNORES = [
          'electron',
          'fs'
        ];
        return function (context, request, callback) {
          if (IGNORES.indexOf(request) >= 0) {
            return callback(null, "require('" + request + "')");
          }
          return callback();
        };
      })()
    ]
  }; 
const Discord = require('discord.js');
const bot = new Discord.Client();


bot.login("token")
function isValidForm (first,second) {
    if(first.value == "" || second.value == "") {
        return alert('Одна из форм не заполненна')
    }
    sendMessage(first.value, second.value);
}

function sendMessage (channelName,message) {
    const channel = bot.channels.cache.find(ch => ch.name === channelName);
    if(!channel) {
        return alert("Канал с таним названием не найден!");
    }
    channel.send(message);
}

module.exports = {sendMessage,isValidForm};


back.js

const path = require('path');
const url = require('url');
const {app,BrowserWindow} = require('electron');
const {sendMessage,isValidForm} = require('./back.js');


let win;

function createWindow() {
    win = new BrowserWindow({
        width: 1200,
        height : 800,
        icon : __dirname + "/img/icon.png"
    });

    win.loadURL(url.format({
        pathname: path.join(__dirname,"/html/index.html"),
        protocol: 'file:',
        slashes: true
    }));

    win.webContents.openDevTools();

    win.on('closed', () => {
        win = null;
    });
}

app.on('ready', createWindow);

app.on('window-all-closed',() => {
    app.quit();
});
var path = require('path');
  module.exports = {
    entry: './src/components/main.js',
    output: {
      filename: 'bundle.js',
      path: path.resolve(__dirname, 'dist')
    },
    externals: [
      (function () {
        var IGNORES = [
          'electron',
          'fs'
        ];
        return function (context, request, callback) {
          if (IGNORES.indexOf(request) >= 0) {
            return callback(null, "require('" + request + "')");
          }
          return callback();
        };
      })()
    ]
  }; 
const Discord = require('discord.js');
const bot = new Discord.Client();


bot.login("token")
function isValidForm (first,second) {
    if(first.value == "" || second.value == "") {
        return alert('Одна из форм не заполненна')
    }
    sendMessage(first.value, second.value);
}

function sendMessage (channelName,message) {
    const channel = bot.channels.cache.find(ch => ch.name === channelName);
    if(!channel) {
        return alert("Канал с таним названием не найден!");
    }
    channel.send(message);
}

module.exports = {sendMessage,isValidForm};