-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
49 lines (46 loc) · 1.52 KB
/
bot.js
File metadata and controls
49 lines (46 loc) · 1.52 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
var Discord = require('discord.js');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
const myIntents = new Discord.Intents();
myIntents.add(Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_INTEGRATIONS);
var bot = new Discord.Client({
intents: myIntents
});
bot.login(auth.token);
bot.on('ready', function(evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
console.log('FML');
});
bot.on('messageCreate', function(message) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
const { member, content, guild } = message;
console.log('message Member: ' + member);
console.log('message Content: ' + content);
console.log('message Guild: ' + guild);
try {
if (content.substring(0, 1) == '!') {
var args = content.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch (cmd) {
// !ping
case 'ping':
message.channel.send('Pong!');
break;
// Just add any case commands if you want to..
}
}
} catch (error) {
console.log(error);
}
});