-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
83 lines (74 loc) · 2.07 KB
/
example.js
File metadata and controls
83 lines (74 loc) · 2.07 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const http = require('http');
http
.createServer((req, res) => {
res.write('example.js is active.\nPlease check it.');
res.end();
})
.listen(8080);
// Discord bot implements
const { Client, GatewayIntentBits } = require('discord.js');
require('dotenv').config({ quiet: true });
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
],
});
const prefix = 'pj!';
const token = process.env.token;
// botが準備できれば発動され、 上から順に処理される。
client.on('clientReady', () => {
// コンソールにReady!!と表示
console.log('Ready!!');
// ステータスを設定する
setInterval(() => {
client.user.setActivity({
name: `所属サーバー数は、${client.guilds.cache.size}サーバー| Ping値は、${client.ws.ping}msです`,
});
}, 10000);
client.channels.cache.get('889486664760721418').send('起動しました!');
// readyイベントここまで
});
// botがメッセージを受信すると発動され、 上から順に処理される。
client.on('messageCreate', (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (command === 'about') {
message.channel.send({
embeds: [
{
title: 'HoshimiTech Betaについて',
description: 'node.jsで作成された、BOT開発テスト用のbotです。',
color: 3823616,
timestamp: new Date(),
thumbnail: {
url: 'attachment://logo.png',
},
footer: {
text: 'This bot is made by Hoshimikan6490',
icon_url: 'attachment://me.png',
},
},
],
files: [
{
attachment: 'images/logo.png',
name: 'logo.png',
},
{
attachment: 'images/me.png',
name: 'me.png',
},
],
});
}
});
client.on('interactionCreate', async (interaction) => {
if (interaction.customId === 'support') {
await interaction.reply('hi!!!');
}
});
// botログイン
client.login(token);