-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
33 lines (29 loc) · 1.07 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
// Coding a Bot with discord.js
// Discord Bots
import { Client } from 'discord.js';
import dotenv from 'dotenv';
import Command from './all_bot_feature/command_management.js';
dotenv.config();
const command_management = new Command();
const botnaja = new Client();
const PREFIX_COMMAND = "$"; //to make all command begins with '$'
// login bot token is in .env file
botnaja.login(process.env.TOKEN);
//to make sure your bot log in
botnaja.on("ready", () => {
console.log("Botnaja has logged in");
});
//get user input
botnaja.on("message", (msg) => {
console.log(`${msg.author.tag} : ${msg.content}`);
if (msg.author.bot) return;
if (msg.content === "เกิดไรขึ้น") {
msg.reply("เออไรวะ");
}
if(msg.content.startsWith('!')){
let reply = ['นอนได้ละครับ เป็นห่วง', 'เปิดไรนักหนา', 'นอนตะ'];
const randomElement = reply[Math.floor(Math.random() * reply.length)];
msg.reply(randomElement);
}
command_management.command(botnaja, msg, PREFIX_COMMAND);
});