当我需要代码并将其加载到我的 Discord 机器人的主代码中时,即使它们是在主代码中定义的,它也无法找到它们的变量或子部分。
所需代码:
module.exports.stupid = () => {
bot.on('messageCreate', (msg) => {
if (msg.content === 'yes'){
bot.createMessage(msg.channel.id,'yes!!')
}
});
}
-- 主脚本中的代码
const Eris = require('eris');
const axios = require('axios');
const firebase = require('firebase/app');
const FieldValue = require('firebase-admin').firestore.FieldValue
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccount.json');
// Commands
const cm1 = require('./staff.js')
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
})
let db = admin.firestore()
const bot = new Eris('token_removed');
let prefix = ';'
const sprefix = ">"
const botname = "bee"
const version = '0.6.6'
const emoji = '<:bee_logo:730125457638425039>'
const semoji = '<:bshield:729463155587022860>'
const remoji = 'buzz:683498511341191245'
const bee_check = '<:bee_check:729878268811018300>'
const bee_dash = '<:bee_dash:729878268790177862>'
const bee_x = '<:bee_x:729878268848898159>'
const hex = 0xF3DC3E
const gethex = 'F3DC3E'
const server = "Amazon (Linux/UNIX)"
const today = new Date();
const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
cm1.stupid()