new games snapshot
This commit is contained in:
@@ -1,41 +1,141 @@
|
||||
const { Client, GatewayIntentBits, Collection, Partials } = require('discord.js')
|
||||
const { MongoClient } = require('mongodb')
|
||||
require('dotenv').config()
|
||||
const mClient = new MongoClient(process.env.M_URI)
|
||||
exports.mClient = mClient;
|
||||
const fs = require('node:fs')
|
||||
const {
|
||||
Client,
|
||||
GatewayIntentBits,
|
||||
Collection,
|
||||
Partials
|
||||
} = require("discord.js");
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildPresences,
|
||||
GatewayIntentBits.GuildMessageReactions,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
|
||||
],
|
||||
partials: [
|
||||
Partials.Channel,
|
||||
Partials.Message,
|
||||
Partials.User,
|
||||
Partials.GuildMember,
|
||||
Partials.Reaction
|
||||
]
|
||||
});
|
||||
exports.client = client
|
||||
const {
|
||||
MongoClient
|
||||
} = require("mongodb");
|
||||
|
||||
client.commands = new Collection() // slash commands collection
|
||||
client.legacyCommands = new Collection() // legacy commands collection
|
||||
client.aliases = new Collection() // list of command aliases
|
||||
client.buttons = new Collection() // list of buttons
|
||||
client.selectMenus = new Collection() // list of selectMenus
|
||||
client.modals = new Collection();
|
||||
const fs = require("node:fs");
|
||||
|
||||
fs.readdirSync('./handlers').forEach((handler) => {
|
||||
require(`./handlers/${handler}`)(client)
|
||||
});
|
||||
require("dotenv").config();
|
||||
|
||||
client.login(process.env.D_TOKEN)
|
||||
|
||||
/*
|
||||
* MONGODB
|
||||
*/
|
||||
|
||||
const mClient =
|
||||
new MongoClient(
|
||||
process.env.M_URI
|
||||
);
|
||||
|
||||
exports.mClient =
|
||||
mClient;
|
||||
|
||||
|
||||
/*
|
||||
* DISCORD CLIENT
|
||||
*/
|
||||
|
||||
const client =
|
||||
new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildPresences,
|
||||
GatewayIntentBits.GuildMessageReactions,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.MessageContent
|
||||
],
|
||||
|
||||
partials: [
|
||||
Partials.Channel,
|
||||
Partials.Message,
|
||||
Partials.User,
|
||||
Partials.GuildMember,
|
||||
Partials.Reaction
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
exports.client =
|
||||
client;
|
||||
|
||||
|
||||
/*
|
||||
* COLLECTIONS
|
||||
*/
|
||||
|
||||
client.commands =
|
||||
new Collection();
|
||||
|
||||
client.legacyCommands =
|
||||
new Collection();
|
||||
|
||||
client.aliases =
|
||||
new Collection();
|
||||
|
||||
client.buttons =
|
||||
new Collection();
|
||||
|
||||
client.selectMenus =
|
||||
new Collection();
|
||||
|
||||
client.modals =
|
||||
new Collection();
|
||||
|
||||
|
||||
/*
|
||||
* START APPLICATION
|
||||
*/
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
|
||||
/*
|
||||
* Connect Mongo first.
|
||||
*/
|
||||
|
||||
await mClient.connect();
|
||||
|
||||
console.log(
|
||||
"MongoDB connected"
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Load handlers.
|
||||
*/
|
||||
|
||||
const handlerFiles =
|
||||
fs.readdirSync(
|
||||
"./handlers"
|
||||
);
|
||||
|
||||
|
||||
for (
|
||||
const handler
|
||||
of handlerFiles
|
||||
) {
|
||||
require(
|
||||
`./handlers/${handler}`
|
||||
)(client);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Login Discord.
|
||||
*/
|
||||
|
||||
await client.login(
|
||||
process.env.D_TOKEN
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"Failed to start ShaiBot:",
|
||||
error
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
start();
|
||||
Reference in New Issue
Block a user