This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
38 lines (30 loc) · 1.73 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
const PBot = require('./index.js');
const { Client, Intents } = require('discord.js');
const fs = require('fs');
const date = new Date();
const formattedDate = `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()} ${date.getHours()}.${date.getMinutes()}`;
const logStream = fs.createWriteStream(`logs/${formattedDate}.txt`, { flags: 'a' });
const bot = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES]
});
bot.on('ready', () => {
console.log(`${bot.user.tag}: i am ready!`);
});
bot.on('messageCreate', async (message) => {
const channel = message.channel;
if(message.author.bot) {return;}
let pBot = new PBot(process.env.NAME, process.env.LANG);
channel.sendTyping();
logStream.write(`┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n`);
logStream.write(` Server: ${message.guild.name} | ID: ${message.guild.id}\n | Created At: ${message.createdAt}`);
logStream.write(`\n ${message.author.username}: ${message.content}\n - ${message.createdTimestamp}`);
await pBot.init();
messageBot = await pBot.say(message.content);
logStream.write(`\n Bot: ${messageBot}\n | Created At: ${new Date()}\n`);
message.reply(messageBot);
logStream.write(`┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n`);
pBot.destroy();
});
bot.login(process.env.TOKEN).then(() => {
bot.user.setPresence({ activities: [{ name: 'by Nikori#8953', type: 'PLAYING' }], status: 'online' });
});