-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
62 lines (49 loc) · 1.54 KB
/
bot.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
require('dotenv').config();
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('messageCreate', async message => {
if (message.author.bot) return;
if (message.content === '!ping') {
message.reply('Pong!');
}
});
// Your existing code, then at the bottom:
client.login('MTMyNjU4OTMzMDIxMDE2MDY2Mg.Gxggyq.w64Ua8OmgEoBCwIfY5UgrM7KxDFD9L9ElznkJA');
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', message => {
if (message.content === '!discordlink') {
message.channel.send('Join our Discord server: [https://discord.gg/9Z2cB5VUjy]');
}
});
client.login('MTMyNjU4OTMzMDIxMDE2MDY2Mg.Gxggyq.w64Ua8OmgEoBCwIfY5UgrM7KxDFD9L9ElznkJA');
// test/bot.test.js
const { expect } = require('chai');
const { Client } = require('discord.js');
const botCode = require('../bot');
describe('Discord Bot', () => {
let client;
before(() => {
client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
});
it('should initialize client', () => {
expect(client).to.be.an.instanceof(Client);
});
// Add more tests as needed
});