-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.js
95 lines (85 loc) · 2.2 KB
/
save.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const http = require("http");
http
.createServer(function (req, res) {
res.write("save.js is active.\nPlease check it.");
res.end();
})
.listen(8080);
const {
Client,
GatewayIntentBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
} = require("discord.js");
const discordTranscripts = require("discord-html-transcripts");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
],
});
require("dotenv").config();
//起動確認
client.on("ready", () => {
// コンソールに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イベントここまで
});
//返答
client.on("messageCreate", async (message) => {
if (message.author.bot) {
return;
}
if (message.content == "hi") {
message.channel.send("hi!");
}
if (message.content == "pj!save") {
const options = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("transcript")
.setLabel("保存する")
.setStyle(ButtonStyle.Secondary)
.setEmoji("📥")
);
await message.channel.send({
embeds: [
{
title: "save",
color: 0x808080,
},
],
components: [options],
});
}
});
client.on("interactionCreate", async (interaction) => {
const channel = interaction.channel; // or however you get your TextChannel
const channel_topic = channel.topic;
const customer_user_id = channel_topic.substr(6);
// Must be awaited
const attachment = await discordTranscripts.createTranscript(channel, {
limit: -1,
filename: `support_transcript_with_${customer_user_id}.html`,
});
await interaction.channel.send({
embeds: [
{
title: "save",
color: 0x20ff20,
},
],
files: [attachment],
});
});
//Discordへの接続
const token = process.env.token;
client.login(token);