This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
51 lines (44 loc) · 1.59 KB
/
app.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
const Discord = require('discord.js')
const bot = new Discord.Client()
const Message = require('./modules/message.js')
const Usr = require('./modules/user.js')
const Guild = require('./modules/guild.js')
const Config = require('./data/config.json')
bot.on('ready', () => {
console.log('Bot is Online')
Usr.initiateSave()
Guild.initGuildSave()
})
bot.on('guildMemberAdd', member => {
if (Config.server.id === member.guild.id) {
// Log user
Usr.logUser(member)
// Send welcome message
Usr.welcomeMessage(member)
}
if (member.guild.id === '149632998055215105') {
console.log('New user joined TGC')
const channel = member.guild.channels.find('id', '149632998055215105')
if (!channel) console.log('Channel not found!')
channel.send(`Welcome to TGC ${member}!`)
}
})
bot.on('guildMemberRemove', member => {
if (Config.server.id === member.guild.id) {
Usr.logUserLeave(member)
}
})
bot.on('message', message => {
if (message.channel.type === 'dm' && message.author.id !== Config.id) return message.reply('I currently cannot communicate via DM. Please use !commands in a regular server channel.')
Usr.addExperience(message)
if (!message.content.startsWith(Config.prefix)) return
Message.cmds(message)
})
bot.on('disconnected', () => {
console.log('Bot Disconnected.')
})
process.on('unhandledRejection', err => {
if (err.toString().indexOf('Forbidden') > 0) return console.log('Bot cannot talk in this channel.')
console.error('Uncaught Promise Error: \n' + err.stack)
})
bot.login(process.env.HOUND_BOT_TOKEN)