-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord.js
45 lines (34 loc) · 1.22 KB
/
discord.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
import { Client, Intents } from 'discord.js';
import { handle } from './logic.js';
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { token } = require('./discord.json');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES
]
});
client.on('ready', async (ctx) => {
console.log(`Logged in as ${client.user.tag}!`);
// ctx.on('message', async message => {
// console.log(message.content);
// })
// can only message users, with whom we have a server in common
// try {
// const user = await ctx.users.fetch('174617873182883841')
// console.log("DC:", user)
// await user.send("Hello!")
// } catch (error) {
// console.error(error)
// }
});
// https://discord.com/api/oauth2/authorize?client_id=912811979557716018&permissions=274877910016&scope=bot%20applications.commands
client.on('messageCreate', async message => {
if (message.author.bot) return;
return handle(message.content, (response) => {
return message.reply(response);
}, { username: message.author.username })
})
export function run() {
client.login(token)
}