-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (57 loc) · 1.97 KB
/
index.js
File metadata and controls
67 lines (57 loc) · 1.97 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
const { Client, Events, GatewayIntentBits } = require("discord.js")
const { REST, Routes } = require('discord.js')
const config = require('./src/config')
const db = require("./src/database")
//Require Commands Functions
const commands = require('./src/commands')
const getCommandsData = commands.map(command => {
return command.data
})
//Require Event Functions
const guildMemberAdd = require("./src/Events/guildMemberAdd")
const messageCreate = require('./src/Events/messageCreate')
const guildMemberRemove = require('./src/Events/guildMemberRemove')
//Regiter of commands
const rest = new REST({ version: '10' }).setToken(config.token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationCommands(config.app_id), { body: getCommandsData });
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})()
//Set new client
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates
]
})
//Events
client.on("guildMemberAdd", member => guildMemberAdd(member, client, db).welcomeMessage())
client.on("messageCreate", msg => messageCreate().levelSys(msg))
client.on("guildMemberRemove", member=> guildMemberRemove().levelSys(member))
client.once("ready", () => {
console.log(`Logged in as ${client.user.tag}`);
});
//Execute command by interaction
client.on(Events.InteractionCreate, (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.channel) {
const getCommand = commands.find(command => command.data.name == interaction.commandName)
if (getCommand) {
getCommand.execute(interaction, client)
}
} else {
interaction.reply('💁♀️ Eu não sou compatível com mensagens privadas!')
}
})
client.login(config.token)
module.exports = {
client
}