Skip to content

Commit

Permalink
Dashboard Half Made
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroGizmo committed Jul 18, 2022
1 parent 78c36f7 commit 0f3e96a
Show file tree
Hide file tree
Showing 23 changed files with 1,344 additions and 101 deletions.
55 changes: 48 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ const ora = require('ora')
const config = require('./config')
const fs = require('fs')

// Express
const express = require('express');
const app = express();

// Slash Commands
const { Client, Collection } = require('discord.js')
const { Collection } = require('discord.js')
const discord = require('discord.js')
const slash = require('./src/util/slash')
const { builtinModules } = require('module')

Expand All @@ -29,11 +34,10 @@ if (!Array.isArray(config.bot.intents)) {
intentsLoader.succeed('Loaded intents successfully from the config file')
}

const client = new Client({ intents: finalIntents })
module.exports = client;
const Client = new discord.Client({ intents: finalIntents })

// Commands
client.commands = new Collection()
Client.commands = new Collection()

const events = fs
.readdirSync('./src/events')
Expand All @@ -42,10 +46,47 @@ const events = fs
events.forEach(event => {
const eventFile = require(`./src/events/${event}`)
if (eventFile.oneTime) {
client.once(eventFile.event, (...args) => eventFile.run(...args))
Client.once(eventFile.event, (...args) => eventFile.run(...args))
} else {
client.on(eventFile.event, (...args) => eventFile.run(...args))
Client.on(eventFile.event, (...args) => eventFile.run(...args))
}
})

client.login(config.bot.token)
Client.login(config.bot.token)

const expresscli = ora('Registering Express').start()

const files = fs.readdirSync('./src/express/requests').filter(f => f .endsWith('.js'))
files.forEach(f => {
const file = require(`./src/express/requests/${f}`)
if(file && file.name) {
try {
app.get(file.name, file.run)
expresscli.succeed(`Successfully Loaded Express System`)
} catch(err) {
expresscli.warn(`[ERROR] ${err}`)
}
}
})
const array = []
const info = []
app.get('/', (req, res) => {
let commands = fs.readdirSync(`./src/commands/`).filter(f => f.endsWith('.js')).forEach((cmd) => {
let prop = require(`./src/commands/${cmd}`)
array.push(prop.name)
info.push(prop.info)
})

const infomation = info.join("<br>")

const cmds = array.join("<br>")

let file = fs.readFileSync('./src/express/html/index.html', { encoding: 'utf8'})
file = file.replace('$$cmds$$', cmds)
res.send(file)
})
app.use('/css', express.static('./src/express/css'))
app.use('/bootstrap', express.static('./node_modules/bootstrap'))
app.listen(3000)
module.exports.Client = Client;
module.exports = Client;
8 changes: 8 additions & 0 deletions models/infoModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const mongoose = require('mongoose');
const warnSchema = mongoose.Schema({
userId: String,
msg: String,
timestamp: String,
})

module.exports = mongoose.model('Info', warnSchema);
6 changes: 0 additions & 6 deletions models/statusModel.js

This file was deleted.

Loading

0 comments on commit 0f3e96a

Please sign in to comment.