-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
90 lines (67 loc) · 2.36 KB
/
index.js
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
const concurrently = require('concurrently');
const express = require("express");
const { InteractionType, ApplicationCommandType, ApplicationCommandOptionType, ActionRowBuilder, ButtonBuilder, ButtonStyle, } = require('discord.js');
const fs = require("fs");
const ascii = require("ascii-table");
this.fetch = require("node-fetch");
let fetch = require("node-fetch");
const bodyparser = require("body-parser");
const session = require("express-session");
const path = require("path");
const ejs = require("ejs");
const url = require("url");
const moment = require('moment')
var clc = require("cli-color");
const cnfg = require("./config.json");
const { Client, Collection, GatewayIntentBits, EmbedBuilder } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
//GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
// GatewayIntentBits.GuildMembers,
],
});
client.slash = new Collection();
['slashCommand',].forEach((handler) => {
require(`./handlers/${handler}`)(client)
});
// process.on("uncaughtException", (err) => {
// console.log("Uncaught Exception: " + err);
// });
process.on("unhandledRejection", (reason, p) => {
console.log(reason, p);
});
const app = express();
const port = 3000
app.get('/', (req, res) => res.send('Yo new gen bot!!'))
app.listen(port, () =>
console.log(`Your app is listening a http://localhost:${port}`)
);
client.login(process.env.token).then(() => {
console.log(
` Successfully logged in as: ${client.user.tag} ${client.user.id}`);
});
client.on(`interactionCreate`, async interaction => {
if (interaction.type === InteractionType.ApplicationCommand) {
const command = client.slash.get(interaction.commandName);
if (!command) return interaction.reply({ content: 'tf.' });
const args = [];
for (let option of interaction.options.data) {
if (option.type === 'SUB_COMMAND') {
if (option.name) args.push(option.name);
option.options?.forEach(x => {
if (x.value) args.push(x.value);
});
} else if (option.value) args.push(option.value);
}
try {
command.run(client, interaction, args)
} catch (e) {
interaction.reply({ content: e.message });
}
}
})