Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
94 lines (62 loc) · 2.54 KB
/
Copy pathmain.js
File metadata and controls
94 lines (62 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const fs = require('fs');
const { Client, Collection, Intents,MessageEmbed } = require('discord.js');
const mongoose = require('mongoose');
const { stringify } = require('querystring');
const { StringDecoder } = require('string_decoder');
const { builtinModules } = require('module');
const { hyperlink } = require('@discordjs/builders');
const dailyreward = require('./utility/events/dailyEvent.js')
const questReset = require('./utility/events/questReset.js')
require('dotenv').config()
const abilityCollection = new Collection()
const abilityFiles = fs.readdirSync(`abilities`).filter(filter => filter.endsWith('.js'))
for (const file of abilityFiles) {
const ability = require(`./abilities/${file}`)
const abilityName = file.replace(/.js/g, '')
abilityCollection.set(abilityName, ability)
}
module.exports.abilityCollection = abilityCollection
const statusCollection = new Collection()
const statusFiles = fs.readdirSync(`status`).filter(filter => filter.endsWith('.js'))
for (const file of statusFiles) {
const status = require(`./status/${file}`)
const statusName = file.replace(/.js/g, '')
statusCollection.set(statusName, status)
}
module.exports.statusCollection = statusCollection
main().catch(err => console.log(err));
async function main() {
await mongoose.connect(process.env.DB_HOST, { useNewUrlParser: true, useUnifiedTopology: true,autoIndex:true });
}
// collection and stuff, will organise later
const client = new Client({ intents: [Intents.FLAGS.GUILD_MEMBERS,Intents.FLAGS.GUILDS] });
i = 0
client.commands = new Collection();
const commandFiles = fs.readdirSync(`commands`).filter(filter => filter.endsWith('.js'))
for ( const file of commandFiles) {
const command = require(`./commands/${file}`)
let commandsArr = ['fight','market','quest','register','remove_ability','shop','stats','test','train','use']
let cmdName = commandsArr[i]
client.commands.set(cmdName, command)
i++
}
client.on('interactionCreate', async interaction => {
client.user.setPresence({activities: [{name: `Co founder: Sunny \nCo founder: Lakshmish `}],status: 'offline'})
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName)
if (!command) return
try{
await command.execute(interaction,client)
} catch(e){
console.log(e)
}
});
// section for events schedules
dailyreward
questReset
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('ready');
});
// Login to Discord with your client's token
client.login(process.env.TOKEN);